测试Center的demo时报错:RuntimeError: CUDA error: out of memory

测试centernet的demo命令:

python demo.py ctdet --demo ../images/ --load_model ../models/ctdet_coco_dla_2x.pth 

如果你也有这个问题,千万别一遍又一遍的装cuda,网上都说什么版本不匹配,no!

报错:Fix size testing. training chunk_sizes: [32] The output will be saved to /home/sys507/CenterNet-master/src/lib/../../exp/ctdet/default heads {'hm': 1, 'wh': 2, 'reg': 2} Creating model... loaded ../models/ctdet_coco_dla_2x.pth, epoch 230 Skip loading parameter hm.2.weight, required shapetorch.Size([1, 256, 1, 1]), loaded shapetorch.Size([80, 256, 1, 1]). If you see this, your model does not fully load the pre-trained weight. Please make sure you have correctly specified --arch xxx or set the correct --num_classes for your own dataset. Skip loading parameter hm.2.bias, required shapetorch.Size([1]), loaded shapetorch.Size([80]). If you see this, your model does not fully load the pre-trained weight. Please make sure you have correctly specified --arch xxx or set the correct --num_classes for your own dataset. THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp line=663 error=11 : invalid argument Traceback (most recent call last): File "demo.py", line 56, in demo(opt) File "demo.py", line 49, in demo ret = detector.run(image_name) File "/home/sys507/CenterNet-master/src/lib/detectors/base_detector.py", line 116, in run output, dets, forward_time = self.process(images, return_time=True) File "/home/sys507/CenterNet-master/src/lib/detectors/ctdet.py", line 30, in process output = self.model(images)[-1] File "/home/sys507/anaconda3/envs/tianfang/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__ result = self.forward(*input, **kwargs) File "/home/sys507/CenterNet-master/src/lib/models/networks/pose_dla_dcn.py", line 481, in forward z[head] = self.__getattr__(head)(y[-1]) File "/home/sys507/anaconda3/envs/tianfang/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__ result = self.forward(*input, **kwargs) File "/home/sys507/anaconda3/envs/tianfang/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward input = module(input) File "/home/sys507/anaconda3/envs/tianfang/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__ result = self.forward(*input, **kwargs) File "/home/sys507/anaconda3/envs/tianfang/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 301, in forward self.padding, self.dilation, self.groups) RuntimeError: CUDA error: out of memory

解决办法:
在demo.py中加入:

import torch
torch.backends.cudnn.enabled = False

你可能感兴趣的:(深度学习,out,of,memory,cuda)