Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument max in method wrapper_clamp_Tensor) #61

Closed
kaiwendulantediyiren opened this issue Sep 10, 2022 · 9 comments

Comments

@kaiwendulantediyiren
Copy link

Swin_V2运行报这个错,想问问要怎么解决呢?

@yang-0201
Copy link
Contributor

训练命令加了“--device 0”嘛

@kaiwendulantediyiren
Copy link
Author

训练命令加了“--device 0”嘛

加了,一样报这个错

@kaiwendulantediyiren
Copy link
Author

训练命令加了“--device 0”嘛
你的能跑起来吗?

@kaiwendulantediyiren
Copy link
Author

Who can solve this problem?

@yang-0201
Copy link
Contributor

You can chat with me privately to see what your problem is, Wechat: 1111554

@iscyy
Copy link
Owner

iscyy commented Sep 13, 2022

You can try
!pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

@kaiwendulantediyiren
Copy link
Author

It has been resolved. You can replace the torch and cuda versions.
!pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f

@iscyy iscyy closed this as completed Sep 14, 2022
@lixiangMindSpore
Copy link

It has been resolved. You can replace the torch and cuda versions. !pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f

你下发命令是什么?

@zxp771
Copy link

zxp771 commented Mar 29, 2023

@iscyy
hi,i followed you suggestion,but the error still there.
image

Traceback (most recent call last):
File "D:\yy\yolov7-main\test.py", line 320, in
test(opt.data,
File "D:\yy\yolov7-main\test.py", line 88, in test
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
File "D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "D:\yy\yolov7-main\utils\torch_utils.py", line 372, in forward
out = self.model(x)
File "D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
D:\yy\yolov7-main\models\common.py(1688): forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1039): _slow_forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1051): _call_impl
D:\yy\yolov7-main\models\common.py(1828): forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1039): _slow_forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1051): _call_impl
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\container.py(139): forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1039): _slow_forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1051): _call_impl
D:\yy\yolov7-main\models\common.py(1867): forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1039): _slow_forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1051): _call_impl
D:\yy\yolov7-main\models\common.py(516): forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1039): _slow_forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1051): _call_impl
D:\yy\yolov7-main\models\yolo.py(625): forward_once
D:\yy\yolov7-main\models\yolo.py(599): forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1039): _slow_forward
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\nn\modules\module.py(1051): _call_impl
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\jit_trace.py(952): trace_module
D:\Anaconda\envs\yolo-hornet\lib\site-packages\torch\jit_trace.py(735): trace
D:\yy\yolov7-main\utils\torch_utils.py(362): init
D:\yy\yolov7-main\test.py(63): test
D:\yy\yolov7-main\test.py(320):
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants