赞
踩
这样子就能装上cpu版本的:
pip install scipy onnx-simplifier
onnx-simplifier项目地址:
https://github.com/daquexian/onnx-simplifier
setup.py中写的:
所以正常来说需要这么安装:
pip install onnx onnxoptimizer onnxruntime-gpu protobuf
cuda和onnxruntiem对应:https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html
参考:https://stackoverflow.com/questions/64452013/how-do-you-run-a-onnx-model-on-a-gpu
Step 1: uninstall your current onnxruntime
pip uninstall onnxruntime
Step 2: install GPU version of onnxruntime environment
pip install onnxruntime-gpu
Step 3: Verify the device support for onnxruntime environment
>> import onnxruntime as rt
>> rt.get_device()
'GPU'
Step 4: If you encounter any issue please check with your cuda and CuDNN versions, that must be compatible to each other. Please refer this link here to understand about the version compatibility between cuda and CuDNN.
rt.get_device()获取到的是安装的onnxruntime版本,但实际使用中需要注意兼容性,这才是重点。如果onnxruntime版本不兼容cuda,那还是会默认使用CPU版本。
代码中加断点,就可以看到自己当前的 onnxruntime session使用的是什么:
>>detector.session.get_providers()
['CPUExecutionProvider']
这里是官网的说明:
https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html
可知:
ONNX Runtime | CUDA | cuDNN | Notes |
---|---|---|---|
1.8 | 11.0.3 | 8.0.4 (Linux) 8.0.2.39 (Windows) | libcudart 11.0.221 libcufft 10.2.1.245 libcurand 10.2.1.245 libcublasLt 11.2.0.252 libcublas 11.2.0.252 libcudnn 8.0.4 libcupti.so 2020.1.1 |
1.7 | 11.0.3 | 8.0.4 (Linux) 8.0.2.39 (Windows) | libcudart 11.0.221 libcufft 10.2.1.245 libcurand 10.2.1.245 libcublasLt 11.2.0.252 libcublas 11.2.0.252 libcudnn 8.0.4 |
1.5-1.6 | 10.2 | 8.0.3 | CUDA 11 can be built from source |
1.2-1.4 | 10.1 | 7.6.5 | Requires cublas10-10.2.1.243; cublas 10.1.x will not work |
1.0-1.1 | 10.0 | 7.6.4 | CUDA versions from 9.1 up to 10.1, and cuDNN versions from 7.1 up to 7.4 should also work with Visual Studio 2017 |
所以我执行了:
pip uninstall onnxruntime-gpu
pip install onnxruntime-gpu==1.4
所以我再次查看:
>>detector.session.get_providers()
['CUDAExecutionProvider', 'CPUExecutionProvider']
这样就完美了:
pip install scipy onnx onnxoptimizer onnxruntime-gpu==1.4 protobuf
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。