Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

显卡在训练中,希望使用cpu推理,结果命令行输入--device cpu却更换不了设备 #13

Open
TYyqt opened this issue Jul 12, 2023 · 3 comments

Comments

@TYyqt
Copy link

TYyqt commented Jul 12, 2023

1.找到选择device的区域

Untitled

发现没有进入if语句,查看if语句之前的device.type确定是cpu,但是if判断语句中’cpu’是字符串,而device.type是cpu <class 'torch.device'>所以没有进入if语句。

2.device.type的类别是字符串,修改为device.type。还是报错

Untitled

分析:追溯是执行vdo_trk.run()是出现问题。查看self.image_track(img0)使用的设备,发现是cpu,没问题。接着查看time_synchronized,发现错误

/home/ahei/DeepSORT_YOLOv5_Pytorch-master/yolov5/utils/torch_utils.py line 53 time_synchronized

原来,首先检查了torch.cuda.is_available()有的话调用了torch.cuda.synchronize(),然而我们的gpu在跑代码显存满了,所以报错。修改如下,问题解决。

@TYyqt
Copy link
Author

TYyqt commented Jul 12, 2023

image

@TYyqt
Copy link
Author

TYyqt commented Jul 12, 2023

image

@TYyqt
Copy link
Author

TYyqt commented Jul 12, 2023

image
补图

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

No branches or pull requests

1 participant