SOTS icon indicating copy to clipboard operation
SOTS copied to clipboard

你好,我运行CSTrack的训练代码,为什么会出现错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.恕我愚笨,我感觉您的源代码很好,但是为什么会出现这个错误?望指教

Open ljfAdmin opened this issue 2 years ago • 5 comments

File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 526, in train(hyp, opt, device, tb_writer) File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 380, in train save_dir=log_dir) File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\eval.py", line 197, in test plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\general.py", line 1142, in output_to_target return np.array(targets) File "\site-packages\torch\tensor.py", line 630, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

ljfAdmin avatar Jan 30 '23 14:01 ljfAdmin

File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 526, in train(hyp, opt, device, tb_writer) File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 380, in train save_dir=log_dir) File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\eval.py", line 197, in test plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\general.py", line 1142, in output_to_target return np.array(targets) File "\site-packages\torch\tensor.py", line 630, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

我也有同样的问题。我先将targets转化为tensor再转换为numpy就可以了。

ninxin avatar Feb 15 '23 13:02 ninxin

谢谢您,我也解决了,用的别的方法

| | ljf | | 18340354730 @.*** |

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年02月15日 21:33 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [JudasDie/SOTS] 你好,我运行CSTrack的训练代码,为什么会出现错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.恕我愚笨,我感觉您的源代码很好,但是为什么会出现这个错误?望指教 (Issue #78) |

File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 526, in train(hyp, opt, device, tb_writer) File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 380, in train save_dir=log_dir) File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\eval.py", line 197, in test plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\general.py", line 1142, in output_to_target return np.array(targets) File "\site-packages\torch\tensor.py", line 630, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

我也有同样的问题。我先将targets转化为tensor再转换为numpy就可以了。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ljfAdmin avatar Feb 15 '23 14:02 ljfAdmin

谢谢您,我也解决了,用的别的方法 | | ljf | | 18340354730 @.*** | ---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年02月15日 21:33 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [JudasDie/SOTS] 你好,我运行CSTrack的训练代码,为什么会出现错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.恕我愚笨,我感觉您的源代码很好,但是为什么会出现这个错误?望指教 (Issue #78) | File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 526, in train(hyp, opt, device, tb_writer) File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 380, in train save_dir=log_dir) File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\eval.py", line 197, in test plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\general.py", line 1142, in output_to_target return np.array(targets) File "\site-packages\torch\tensor.py", line 630, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. 我也有同样的问题。我先将targets转化为tensor再转换为numpy就可以了。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

请问您复现了论文中的结果了吗

Bian-666 avatar Apr 01 '23 13:04 Bian-666

只是运行成功了,后面没有在测试集上进行测试

| | ljf | | 18340354730 @.*** |

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年04月01日 21:42 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [JudasDie/SOTS] 你好,我运行CSTrack的训练代码,为什么会出现错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.恕我愚笨,我感觉您的源代码很好,但是为什么会出现这个错误?望指教 (Issue #78) |

谢谢您,我也解决了,用的别的方法 | | ljf | | 18340354730 @.*** | … ---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年02月15日 21:33 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [JudasDie/SOTS] 你好,我运行CSTrack的训练代码,为什么会出现错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.恕我愚笨,我感觉您的源代码很好,但是为什么会出现这个错误?望指教 (Issue #78) | File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 526, in train(hyp, opt, device, tb_writer) File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 380, in train save_dir=log_dir) File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\eval.py", line 197, in test plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\general.py", line 1142, in output_to_target return np.array(targets) File "\site-packages\torch\tensor.py", line 630, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. 我也有同样的问题。我先将targets转化为tensor再转换为numpy就可以了。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

请问您复现了论文中的结果了吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ljfAdmin avatar Apr 02 '23 02:04 ljfAdmin

谢谢您,我也解决了,用的别的方法 | | ljf | | 18340354730 @.*** | ---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年02月15日 21:33 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [JudasDie/SOTS] 你好,我运行CSTrack的训练代码,为什么会出现错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.恕我愚笨,我感觉您的源代码很好,但是为什么会出现这个错误?望指教 (Issue #78) | File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 526, in train(hyp, opt, device, tb_writer) File "/SOTS-MOT/CSTrack/tracking/train_cstrack.py", line 380, in train save_dir=log_dir) File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\eval.py", line 197, in test plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions File "\SOTS-MOT\CSTrack\tracking..\lib\core\mot\general.py", line 1142, in output_to_target return np.array(targets) File "\site-packages\torch\tensor.py", line 630, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. 我也有同样的问题。我先将targets转化为tensor再转换为numpy就可以了。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

请问您用的什么方法呀?可以详细说说嘛?

SmallGGgg avatar Nov 09 '23 07:11 SmallGGgg