问题描述:
Traceback (most recent call last): File “D:/ssd-pytorch/predict.py”,
line 14, in
r_image = ssd.detect_image(image) File “D:\ssd-pytorch\ssd.py”, line 93, in detect_image
preds = self.net(photo) File “D:\ProgramData\Anaconda3\envs\faster_gpu\lib\site-packages\torch\nn\modules\module.py”,
line 547, in call
result = self.forward(*input, **kwargs) File “D:\ProgramData\Anaconda3\envs\faster_gpu\lib\site-packages\torch\nn\parallel\data_parallel.py”,
line 153, in forward
return self.gather(outputs, self.output_device) File “D:\ProgramData\Anaconda3\envs\faster_gpu\lib\site-packages\torch\nn\parallel\data_parallel.py”,
line 165, in gather
return gather(outputs, output_device, dim=self.dim) File “D:\ProgramData\Anaconda3\envs\faster_gpu\lib\site-packages\torch\nn\parallel\scatter_gather.py”,
line 68, in gather
res = gather_map(outputs)AssertionErrorError:Gather function not implemented for CPU tensors。
解决办法:
在出错代码开头加上以下代码:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
完美解决。。。