YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone icon indicating copy to clipboard operation
YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone copied to clipboard

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

Open ivs-pychen opened this issue 4 years ago • 3 comments
trafficstars

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

ivs-pychen avatar Jul 19 '21 17:07 ivs-pychen

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

hellocodelxy avatar Aug 09 '21 04:08 hellocodelxy

你好!请问有解决这个问题吗?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! ``

liuxin116093 avatar Mar 30 '22 09:03 liuxin116093

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

lvy1999s avatar May 10 '23 11:05 lvy1999s