SpursLipu / YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone

YOLO ModelCompression MultidatasetTraining
GNU General Public License v3.0
444 stars 136 forks source link

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! #145

Open ivs-pychen opened 3 years ago

ivs-pychen commented 3 years ago

When I run the PTW.py or test.py, I encounter the following error. image

hellocodelxy commented 3 years ago

hi, I have the same problem. Have u already solve this problem?

liuxin116093 commented 2 years ago

你好!请问有解决这个问题吗?yolov3可以正常训练,但训练yolov4的时候就会出现这个错误。 Epoch gpu_mem GIoU obj cls total targets img_size 0%| | 0/341 [00:01<?, ?it/s] Traceback (most recent call last): File "train.py", line 714, in train(hyp) # train normally File "train.py", line 355, in train pred, feature_s = model(imgs) File "D:\Python\envs\yolov4\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl result = self.forward(*input, kwargs) File "G:\dataset\Model_Compression_For_YOLOV3-V4-main\models.py", line 447, in forward return self.forward_once(x) File "G:\dataset\Model_Compression_For_YOLOV3-V4-main\models.py", line 501, in forward_once x = module(x) File "D:\Python\envs\yolov4\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl result = self.forward(*input, *kwargs) File "D:\Python\envs\yolov4\lib\site-packages\torch\nn\modules\container.py", line 117, in forward input = module(input) File "D:\Python\envs\yolov4\lib\site-packages\torch\nn\modules\module.py", line 726, in _call_impl hook_result = hook(self, input, result) File "D:\Python\envs\yolov4\lib\site-packages\thop\vision\basic_hooks.py", line 31, in count_convNd m.total_ops += torch.DoubleTensor([int(total_ops)]) File "D:\Python\envs\yolov4\lib\site-packages\apex-0.1-py3.7.egg\apex\amp\wrap.py", line 53, in wrapper return orig_fn(args, kwargs) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! ``

lvy1999s commented 1 year ago

你好,我在也遇到了这个问题,请问你解决这个问题了吗?