运行mmsegmentation的image_demo.py时报ValueError: SyncBatchNorm expected input tensor to be on GPU

我的电脑是cpu,如题目所示,在运行mmsegmentation的image_demo.py时报如下错误:

ValueError: SyncBatchNorm expected input tensor to be on GPU

具体见截图:
运行mmsegmentation的image_demo.py时报ValueError: SyncBatchNorm expected input tensor to be on GPU_第1张图片
参考如下链接解决
https://github.com/open-mmlab/mmsegmentation/issues/292
代码如下:

    # build the model from a config file and a checkpoint file
    config = mmcv.Config.fromfile(args.config)
    # Remove pretrain model download for testing
    config.model.pretrained = None
    # Replace SyncBN with BN to inference on CPU
    norm_cfg = dict(type='BN', requires_grad=True)
    config.model.backbone.norm_cfg = norm_cfg
    config.model.decode_head.norm_cfg = norm_cfg
    config.model.auxiliary_head.norm_cfg = norm_cfg

你可能感兴趣的:(python,深度学习,pytorch)