zoukankan      html  css  js  c++  java
  • 关于windows10用c++部署libtorch过程中遇到的一些问题

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

    用c++调用pytorch模型官网上面有详细教程,也有很多博客,可以参考以下链接:https://blog.csdn.net/dou3516/article/details/82912480

    以及:https://zhuanlan.zhihu.com/p/55292836

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

    问题一: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 - done
    CMake 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文件,如图:

    解决方法:将路径为pathlibtorchlib中对应的torch.dll等对应缺失的文件复制到路径为uildDebug和uildRelease中去即可解决.

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

  • 相关阅读:
    H264码流解析及NALU
    pflua:用Lua编写的高性能网络包过滤工具箱
    最新版FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用简介
    JNI和NDK的区别
    按两次回退键退出系统
    在当前界面停留几秒然后跳到另一个界面
    解决ScrollView 与ListView共存显示不完全的问题
    设置ListView每条数据之间的间隔
    通过布局文件来显示ListView内容并注册 ListView事件
    Android 改变标题栏的背景色
  • 原文地址:https://www.cnblogs.com/yeshengCqupt/p/10448476.html
Copyright © 2011-2022 走看看