1. 設(shè)備
2. 環(huán)境
sudo apt-get install protobuf-compiler libprotoc-dev
export PATH=/usr/local/cuda/bin:${PATH}
export CUDA_PATH=/usr/local/cuda
export cuDNN_PATH=/usr/lib/aarch64-linux-gnu
export CMAKE_ARGS="-DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc"
3.源碼
mkdir /code
cd /code
git clone --recursive https://github.com/Microsoft/onnxruntime.git
# 從 tag v1.16.0 切換分支進行編譯
git checkout -b v1.16.0 v1.16.0
git submodule update --init --recursive --progress
cd /code/onnxruntime
4.編譯
# --parallel 2 使用 2 個 cpu 進行編譯,防止內(nèi)存和CPU性能不足導(dǎo)致編譯識別
./build.sh --config Release --update --build --parallel 2 --build_wheel \
--use_tensorrt --cuda_home /usr/local/cuda --cudnn_home /usr/lib/aarch64-linux-gnu \
--tensorrt_home /usr/lib/aarch64-linux-gnu
若編譯識別,內(nèi)存不足,可進行擴大交換內(nèi)存
https://labelnet.blog.csdn.net/article/details/136538479
編譯完成標(biāo)識
...
build complate!
5. 安裝
cd /build/Linux/Release
sudo make install
6.查看
/usr/lcoal 查看安裝
7.下載
(1) 整個 build 目錄,包含 build/Linux/Relase
https://download.csdn.net/download/LABLENET/88943160
(2) 僅 Python3.8 安裝文件,onnxruntime-gpu-1.16.0-cp38-cp38-linux-aarch64.whl
https://download.csdn.net/download/LABLENET/88943155
8. 靜態(tài)庫編譯安裝
1)編譯
添加 l --build_shared_lib
./build.sh --config Release --update --build --parallel --build_shared_lib --build_wheel \
--use_tensorrt --cuda_home /usr/local/cuda --cudnn_home /usr/lib/aarch64-linux-gnu \
--tensorrt_home /usr/lib/aarch64-linux-gnu
2)安裝
sudo cmake install
9. 靜態(tài)庫下載使用
C++, 見文件 https://download.csdn.net/download/LABLENET/88943411
10 C++ 開發(fā)
CMakeList.txt 中配置使用
...
# onnxruntime
find_package(onnxruntime REQUIRED)
message(onnxruntime_dir: ${onnxruntime_DIR})
target_link_libraries (
${MODULE_NAME} PUBLIC
onnxruntime::onnxruntime
)
C++ 代碼
#include <onnxruntime_cxx_api.h>
int main()
{
auto providers = Ort::GetAvailableProviders();
cout << Ort::GetVersionString() << endl;
for (auto provider : providers)
{
cout << provider << endl;
}
}
11. Python 開發(fā)
安裝依賴包
pip3 install onnxruntime_gpu-1.16.0-cp38-cp38-linux_aarch64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
開發(fā)文章來源:http://www.zghlxwxcb.cn/news/detail-852238.html
import onnxruntime
print("OnnxRuntime Provider : ", onnxruntime.get_available_providers())
輸出文章來源地址http://www.zghlxwxcb.cn/news/detail-852238.html
OnnxRuntime Provider : ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider']
到了這里,關(guān)于【JetsonNano】onnxruntime-gpu 環(huán)境編譯和安裝,支持 Python 和 C++ 開發(fā)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!