×

签到

分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

ubuntu18 yolov5 编译的pytorch cambricon 运行量化模型失败 已解决 Jerry30622022-09-28 10:47:09 回复 2 查看 使用求助
ubuntu18 yolov5 编译的pytorch cambricon 运行量化模型失败
分享到:

你好,我们公司正在适配MLU220设备,目前我使用的是按照官方步骤编译的pytorch cambricon,没有使用docker。我使用编译的版本,能将https://developer.cambricon.com/index/curriculum/expdetails/id/10/classid/8.html 这个教程的yolov5运行成功,不过当使用我们公司自己的yolov5模型时,检测不到目标。我又按照https://developer.cambricon.com/index/curriculum/expdetails/id/13/classid/8.html 一步一步去量化yolov5s.pt的模型,在运行到逐层那步时,出现了错误如下:

Fusing s... 

Model Summary: 224 s, 7266973 parameters, 229245 gradients

2022-09-28 10:23:27.222390: [cnrtError] [28079] [Card : NONE] input param  is invalid device handle in cnrtSetCurrentDevice

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][l

ine:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


Can not call cpu_data on an empty tensor.

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:68][copy_][thread:140045836075968][process:28079]: 

copy_ Op cannot run on MLU device, start running on CPU!

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


Can not call cpu_data on an empty tensor.

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:600][__and__][thread:140045836075968][process:28079]: 

__and__ Op cannot run on MLU device, start running on CPU!

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


Can not call cpu_data on an empty tensor.

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:68][copy_][thread:140045836075968][process:28079]: 

copy_ Op cannot run on MLU device, start running on CPU!

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


Can not call cpu_data on an empty tensor.

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:600][__and__][thread:140045836075968][process:28079]: 

__and__ Op cannot run on MLU device, start running on CPU!

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


Can not call cpu_data on an empty tensor.

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:68][copy_][thread:140045836075968][process:28079]: 

copy_ Op cannot run on MLU device, start running on CPU!

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/core/tensor_impl.cpp][line:866][cpu_data][thread:140045836075968][process:28079]: 


Both cpu_storage and mlu_storage are not initialized!

Please check is there any invalid tensor operates such as:

output = input.cpu() or output = input.to("cpu") in pytorch model when doing mlu/mfus inference.


Traceback (most recent call last):

  File "/home/dell/miniconda3/envs/cambricon/lib/python3.6/runpy.py", line 193, in _run_module_as_main

    "__main__", mod_spec)

  File "/home/dell/miniconda3/envs/cambricon/lib/python3.6/runpy.py", line 85, in _run_code

    exec(code, run_globals)

  File "/home/dell/.vscode-server/extensions/ms-python.python-2022.8.1/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>

    cli.main()

  File "/home/dell/.vscode-server/extensions/ms-python.python-2022.8.1/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main

    run()

  File "/home/dell/.vscode-server/extensions/ms-python.python-2022.8.1/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file

    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))

  File "/home/dell/miniconda3/envs/cambricon/lib/python3.6/runpy.py", line 263, in run_path

    pkg_name=pkg_name, _name=fname)

  File "/home/dell/miniconda3/envs/cambricon/lib/python3.6/runpy.py", line 96, in _run_module_code

    mod_name, mod_spec, pkg_name, _name)

  File "/home/dell/miniconda3/envs/cambricon/lib/python3.6/runpy.py", line 85, in _run_code

    exec(code, run_globals)

  File "/home/dell/project/py/yolov5/detect.py", line 251, in <module>

    detect()

  File "/home/dell/project/py/yolov5/detect.py", line 131, in detect

    pred = pred.to(torch.device('cpu'))

RuntimeError: Can not call cpu_data on an empty tensor.


我找了很久很久,超过一天,实在找不到什么原因,还请帮我看看具体什么问题,十分感谢。

我的yolov5代码如下:

yolov5.zip

版权所有 © 2024 寒武纪 Cambricon.com 备案/许可证号:京ICP备17003415号-1
关闭