Bobo-y / flexible-yolov5

More readable and flexible yolov5 with more backbone(gcn, resnet, shufflenet, moblienet, efficientnet, hrnet, swin-transformer, etc) and (cbam,dcn and so on), and tensorrt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ONNX: export failure: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument other in method wrapper__equal)

taoxunqiang opened this issue · comments

感谢这么棒的工作。
YOLOv5 + mobilenetv3 small转fp16的onnx:
python scripts/export.py --weights ./runs/train/YOLOv5-mobilenetv3s/weights/best.pt --include onnx --device 0 --half
出现如下的错误:
ONNX: export failure: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument other in method wrapper__equal)

commented

@taoxunqiang 导onnx 的时候建议不要指定gpu,不用--device 参数

@Bobo-y 程序里面要指定gpu,不然会出现:
AssertionError: --half only compatible with GPU export, i.e. use --device 0

commented

@taoxunqiang 🤔,我刚试了一下,我没加的确可以的啊,而且转 onnx 一版都不指定gpu 的

@Bobo-y 也是加--half吗,我需要转成半精度的

commented

@taoxunqiang add nothing, only add --weights