Turoad/CLRNet

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

Opened this issue · 2 comments

Traceback (most recent call last):
File "main.py", line 75, in <module>
  main()
File "main.py", line 39, in main
  runner.train()
File "/root/Desktop/CLRNet/clrnet/engine/runner.py", line 92, in train
  self.train_epoch(epoch, train_loader)
File "/root/Desktop/CLRNet/clrnet/engine/runner.py", line 60, in train_epoch
  output = self.net(data)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
  result = self.forward(*input, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/mmcv-1.2.5-py3.8.egg/mmcv/parallel/data_parallel.py", line 42, in forward
  return super().forward(*inputs, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 159, in forward
  return self.module(*inputs[0], **kwargs[0])
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
  result = self.forward(*input, **kwargs)
File "/root/Desktop/CLRNet/clrnet/models/nets/detector.py", line 32, in forward
  output = self.heads(fea, batch=batch)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
  result = self.forward(*input, **kwargs)
File "/root/Desktop/CLRNet/clrnet/models/heads/clr_head.py", line 205, in forward
  self.priors, self.priors_on_featmap = self.generate_priors_from_embeddings()
File "/root/Desktop/CLRNet/clrnet/models/heads/clr_head.py", line 145, in generate_priors_from_embeddings
  ((1 - self.prior_ys.repeat(self.num_priors, 1) -
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

How can I solve this problem

楼主你好,请问此问题解决了吗?
我也是遇到这个问题,是在使用CLRNet-onnxruntime-and-tensorrt-demo这个项目将clr_head.py替换后重新训练出现的报错。

MrL-CV commented

楼主你好,请问此问题解决了吗? 我也是遇到这个问题,是在使用CLRNet-onnxruntime-and-tensorrt-demo这个项目将clr_head.py替换后重新训练出现的报错。

换回来就好了:)