博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于windows10用c++部署libtorch过程中遇到的一些问题
阅读量:4548 次
发布时间:2019-06-08

本文共 2068 字,大约阅读时间需要 6 分钟。

  • libtorch1.0
  • vs2017
  • CMake3.14
  • windows10
  • 无cuda

用c++调用pytorch模型官网上面有详细教程,也有很多博客,可以参考以下链接:

以及:

在操作的过程中,主要遇到三个比较大的问题:

问题一:cmake编译时以及找不到torch和opencv相关的cmake文件(以下代码是复制的stackoverflow上别人的报错,我当时没有把自己的报错截图下来,但问题是一样的)

-- The C compiler identification is GNU 7.3.0-- The CXX compiler identification is GNU 7.3.0-- 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 - doneCMake Error at CMakeLists.txt:10 (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!

原因:它无法找到TorchConfig.cmaketorch-config.cmake文件

解决方法:通过编辑CMakeLists.txt解决,将libtorch文件中的path/libtorch/share/cmake/Torch 加到路径中去,如图所示

 

以及将opencv安装路径的build添加到系统环境变量中去:(变量名为如图所示,地址根据个人地址修改)

 

问题二:编译成功后,运行.cpp显示程序无法启动ALL_BUILD 拒绝访问

解决方法:CMake编译成功后会生成三个工程文件,分别是ALL_BUILD,工程本身文件(我的叫lenet),以及ZERO_CHECK,将ALL_BUILD和ZERO_CHECK在工程文件中移除即可以解决.

问题三:找不到dll文件,如图:

解决方法:将路径为\path\libtorch\lib中对应的torch.dll等对应缺失的文件复制到路径为\build\Debug和\build\Release中去即可解决.

注:用vs运行.cpp时要讲解决方案配置改为Release x64的方式,不然会报错.

 

转载于:https://www.cnblogs.com/yeshengCqupt/p/10448476.html

你可能感兴趣的文章
SharePoint DataFormWebPart 通过Caml和xslt聚合内容
查看>>
第二天学习
查看>>
排序算法----基数排序(RadixSort(L))单链表智能版本
查看>>
Bootstrap(九):组件--下拉菜单
查看>>
python 文件处理
查看>>
HTTP状态码大全
查看>>
char 数组互相转换成String
查看>>
ASCII码字符对照表
查看>>
IOS-Create UIActionSheet 'otherButtons' by passing in array
查看>>
angualrJs实现图片上传功能
查看>>
Python_selenium之执行JavaScript
查看>>
js 获取数组最后一个元素
查看>>
聊聊CSS3中的transition
查看>>
进程间通信IPC与Binder机制原理
查看>>
shell编程
查看>>
深度学习5牛顿法
查看>>
实验1dos命令
查看>>
二叉树(树的简介)
查看>>
C语言解释器的实现--存储结构(一)
查看>>
jquery mobile 栅格化
查看>>