pip install yacs ninja pycocotools cityscapesscripts git clone https://github.com/NVIDIA/apex.git cd apex python setup.py install cd MaskRCNN/ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" set DISTUTILS_USE_SDK=1 python setup.py build develop python setup.py install cd MaskRCNN/demo python demo.py C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include\crt/host_config.h(153): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! Fix: #if _MSC_VER < 1910 //|| _MSC_VER >= 1940 MaskRCNN\maskrcnn_benchmark\csrc\cuda\SigmoidFocalLoss_cuda.cu(8): fatal error C1083: 无法打开包括文件: “THC/THC.h”: No such file or directory Fix: //#include#include //const int col_blocks = THCCeilDiv(n_boxes, threadsPerBlock); const int col_blocks = at::ceil_div(n_boxes, threadsPerBlock); error: identifier "THCudaCheck" is undefined Fix: THCudaCheck 替换成 C10_CUDA_CHECK error: identifier "THCState" is undefined Fix: //THCState *state = at::globalContext().lazyInitCUDA(); error: identifier "THCudaMalloc" is undefined Fix: #include //mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long)); mask_dev = (unsigned long long*) c10::cuda::CUDACachingAllocator::raw_alloc(boxes_num * col_blocks * sizeof(unsigned long long)); error: identifier "THCudaFree" is undefined Fix: //THCudaFree(state, mask_dev); c10::cuda::CUDACachingAllocator::raw_delete(mask_dev); error: identifier "AT_CHECK" is undefined Fix: AT_CHECK 替换为 TORCH_CHECK ImportError: cannot import name '_C' from 'maskrcnn_benchmark' Fix: # from maskrcnn_benchmark import _C from ._utils import _C or from maskrcnn_benchmark.layers._utils import _C AttributeError: module 'torch' has no attribute '_six' Fix: 注释掉这一句 # if torch._six.PY3: ImportError: cannot import name '_download_url_to_file' from 'torch.hub' Fix: #from torch.hub import _download_url_to_file from torch.hub import download_url_to_file datasets/coco/annotations/instances_train2014.json datasets/coco/annotations/instances_minival2014.json datasets/coco/annotations/instances_valminusminival2014.json datasets/coco/train2014/COCO_train2014_000000051871.jpg datasets/coco/val2014/COCO_val2014_000000169097.jpg python tools/train_net.py --config-file ./configs/e2e_mask_rcnn_R_50_FPN_1x.yaml SOLVER.IMS_PER_BATCH 3 TEST.IMS_PER_BATCH 3 SOLVER.BASE_LR 0.01 python tools/test_net.py --config-file ./configs/e2e_mask_rcnn_R_50_FPN_1x.yaml --ckpt ./model_final_coco2014.pth