日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

Ubuntu下的onnxruntime(c++)编译

發布時間:2023/12/18 c/c++ 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ubuntu下的onnxruntime(c++)编译 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 倉庫下載
  • 編譯
    • GPU
    • TensorRT
  • install
  • 參考

倉庫下載

git clone --depth=1 --branch v1.12.1 https://github.com.cnpmjs.org/microsoft/onnxruntime.git

注意:需要更換國內鏡像源

編譯

GPU

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

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

onnxruntime版本和cuda、cudnn版本要對應,具體參考官方推薦https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html。

TensorRT

Tensorrt安裝參考這里。

./build.sh \--parallel 8 \--use_cuda \--cuda_version=11.1 \--cuda_home=/usr/local/cuda \--cudnn_home=/usr/local/cuda \--use_tensorrt --tensorrt_home=/usr/local/lib/python3.8/dist-packages/tensorrt \--build_shared_lib --enable_pybind \--build_wheel --update --build \--config Release

注意

  • cmake版本過低會導致編譯失敗;
  • 科學上網問題。編譯過程中會鏈接其他github倉庫,需要手動添加鏡像源。
  • cd ${your git repo root} cd .git vim config

    修改為:

    [core]repositoryformatversion = 0filemode = truebare = falselogallrefupdates = trueignorecase = trueprecomposeunicode = true [remote "origin"]url = https://github.com.cnpmjs.org/microsoft/onnxruntime.gitfetch = +refs/tags/v1.7.0:refs/tags/v1.7.0

    也不多,大概幾十個把

    編譯成功

    [ 98%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/xxx/Desktop/third_party/library/onnxruntime/onnxruntime/contrib_ops/cpu/skip_layer_norm.cc.o [ 98%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/xxx/Desktop/third_party/library/onnxruntime/onnxruntime/contrib_ops/cpu/tokenizer.cc.o [100%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/xxx/Desktop/third_party/library/onnxruntime/onnxruntime/contrib_ops/cpu/trilu.cc.o [100%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/xxx/Desktop/third_party/library/onnxruntime/onnxruntime/contrib_ops/cpu/unique.cc.o [100%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/xxx/Desktop/third_party/library/onnxruntime/onnxruntime/contrib_ops/cpu/word_conv_embedding.cc.o [100%] Linking CXX static library libonnxruntime_providers.a /Library/Developer/CommandLineTools/usr/bin/ranlib: file: libonnxruntime_providers.a(dft.cc.o) has no symbols /Library/Developer/CommandLineTools/usr/bin/ranlib: file: libonnxruntime_providers.a(window_functions.cc.o) has no symbols /Library/Developer/CommandLineTools/usr/bin/ranlib: file: libonnxruntime_providers.a(dft.cc.o) has no symbols /Library/Developer/CommandLineTools/usr/bin/ranlib: file: libonnxruntime_providers.a(window_functions.cc.o) has no symbols [100%] Built target onnxruntime_providers [100%] Building C object CMakeFiles/onnxruntime.dir/generated_source.c.o [100%] Linking CXX shared library libonnxruntime.dylib [100%] Built target onnxruntime 2021-04-15 22:39:10,495 util.run [DEBUG] - Subprocess completed. Return code: 0 2021-04-15 22:39:10,496 build [INFO] - Build complete

    install

    cd ./build/Linux/release make install

    參考

    https://zhuanlan.zhihu.com/p/411887386

    總結

    以上是生活随笔為你收集整理的Ubuntu下的onnxruntime(c++)编译的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。