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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > c/c++ >内容正文

c/c++

关于windows10用c++部署libtorch过程中遇到的一些问题

發(fā)布時(shí)間:2024/9/27 c/c++ 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关于windows10用c++部署libtorch过程中遇到的一些问题 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
  • libtorch1.0
  • vs2017
  • CMake3.14
  • windows10
  • 無(wú)cuda

用c++調(diào)用pytorch模型官網(wǎng)上面有詳細(xì)教程,也有很多博客,可以參考以下鏈接:pytorch怎么使用c++調(diào)用部署模型?_豆芽菜-CSDN博客_pytorch用c++

以及:Pytorch的C++前端(libtorch)在Windows下的預(yù)測(cè) - 知乎

在操作的過(guò)程中,主要遇到三個(gè)比較大的問(wèn)題:

問(wèn)題一:cmake編譯時(shí)以及找不到torch和opencv相關(guān)的cmake文件(以下代碼是復(fù)制的stackoverflow上別人的報(bào)錯(cuò),我當(dāng)時(shí)沒(méi)有把自己的報(bào)錯(cuò)截圖下來(lái),但問(wèn)題是一樣的)

  • -- The C compiler identification is GNU 7.3.
  • -- The CXX compiler identification is GNU 7.3.
  • -- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
  • -- Check for working C compiler: /usr/bin/cc
  • -- Check for working C compiler: /usr/bin/cc -- works
  • -- Detecting C compiler ABI info
  • -- Detecting C compiler ABI info - done
  • -- Detecting C compile features
  • -- Detecting C compile features - done
  • -- Check for working CXX compiler: /usr/bin/c++
  • -- Check for working CXX compiler: /usr/bin/c++ -- works
  • -- Detecting CXX compiler ABI info
  • -- Detecting CXX compiler ABI info - done
  • -- Detecting CXX compile features
  • -- Detecting CXX compile features - done
  • CMake Error at CMakeLists.txt: (find_package):
  • By not providing "FindTorch.cmake" in CMAKE_MODULE_PATH this project has
  • asked CMake to find a package configuration file provided by "Torch", but
  • CMake did not find one.
  • Could not find a package configuration file provided by "Torch" with any of
  • the following names:
  • TorchConfig.cmake
  • torch-config.cmake
  • Add the installation prefix of "Torch" to CMAKE_PREFIX_PATH or set
  • "Torch_DIR" to a directory containing one of the above files. If "Torch"
  • provides a separate development package or SDK, be sure it has been
  • installed.
  • -- Configuring incomplete, errors occurred!
  • 原因:它無(wú)法找到TorchConfig.cmake和torch-config.cmake文件

    解決方法:通過(guò)編輯CMakeLists.txt解決,將libtorch文件中的path/libtorch/share/cmake/Torch 加到路徑中去,如圖所示

    以及將opencv安裝路徑的build添加到系統(tǒng)環(huán)境變量中去:(變量名為如圖所示,地址根據(jù)個(gè)人地址修改)

    問(wèn)題二:編譯成功后,運(yùn)行.cpp顯示程序無(wú)法啟動(dòng)ALL_BUILD 拒絕訪問(wèn)

    解決方法:CMake編譯成功后會(huì)生成三個(gè)工程文件,分別是ALL_BUILD,工程本身文件(我的叫l(wèi)enet),以及ZERO_CHECK,將ALL_BUILD和ZERO_CHECK在工程文件中移除即可以解決.

    問(wèn)題三:找不到dll文件,如圖:

    解決方法:將路徑為\path\libtorch\lib中對(duì)應(yīng)的torch.dll等對(duì)應(yīng)缺失的文件復(fù)制到路徑為\build\Debug和\build\Release中去即可解決.

    注:用vs運(yùn)行.cpp時(shí)要講解決方案配置改為Release x64的方式,不然會(huì)報(bào)錯(cuò).

    總結(jié)

    以上是生活随笔為你收集整理的关于windows10用c++部署libtorch过程中遇到的一些问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。