fbtorch:cmake找不到火炬目录

时间:2016-07-27 21:06:08

标签: cmake torch

我正在尝试构建和安装fbtorch,但是当我使用cmake时出现以下错误:

CMake Error at CMakeLists.txt:9 (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.

我在网上搜索并找到了一些解决方案,例如使用

source ~/torch/install/bin/torch-activate

或重新安装火炬,但没有任何帮助。 有人能帮助我吗?谢谢。

2 个答案:

答案 0 :(得分:1)

遇到了同样的问题。

解决方案:在cmake之前将Torch_DIR导出为env变量

例如我在Linux上使用python virtual env,并使用“ pip”安装了pytorch。

export Torch_DIR=/home/my/pyenv/py3.7-torch1.0/lib/python3.7/site-packages/torch/share/cmake/Torch

cmake blablabla
make

答案 1 :(得分:0)

如果使用clion:

  

clion首选项->环境---> / some_path_to / torchscript / libtorch / share / cmake / Torch