onnxruntime编译安装

克隆源码

git clone --recursive https://github.com/Microsoft/onnxruntime
cd onnxruntime/
git checkout v1.8.0
git submodule update --init --recursive

编译

./build.sh --skip_tests --use_cuda --config Release --build_shared_lib --parallel --cuda_home /usr/local/cuda-11.1 --cudnn_home /usr/local/cuda-11.1

其中的use_cuda表示你要使用CUDA的onnxruntime,cuda_home和cudnn_home均指向你的CUDA安装目录即可。

编译完成输出

[100%] Linking CXX executable onnxruntime_test_all
[100%] Built target onnxruntime_test_all
[100%] Linking CUDA shared module libonnxruntime_providers_cuda.so
[100%] Built target onnxruntime_providers_cuda
2022-03-15 13:49:03,260 util.run [DEBUG] - Subprocess completed. Return code: 0
2022-03-15 13:49:03,260 build [INFO] - Build complete

qt添加头文件和库

*.pro文件

#onnx
INCLUDEPATH += /home/online/mytest/onnx/onnxruntime/include/onnxruntime \
            /home/online/mytest/onnx/onnxruntime/include/onnxruntime/core/session


LIBS += /home/online/mytest/onnx/onnxruntime/build/Linux/Release/libonnxruntime.so.1.8.0
LIBS += /home/online/mytest/onnx/onnxruntime/build/Linux/Release/libonnxruntime_providers_cuda.so
LIBS += /home/online/mytest/onnx/onnxruntime/build/Linux/Release/libonnxruntime_providers_shared.so

你可能感兴趣的:(计算机视觉,人工智能)