HemHem
HemHem

Reputation: 55

fbtorch: cmake can not find torch directories

I am trying to build and install fbtorch, however when I used cmake I got the following error:

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.

I searched online and found some solutions such as using

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

or reinstalling torch, but nothing helps. Could someone help me? Thank you.

Upvotes: 4

Views: 7641

Answers (2)

wucc
wucc

Reputation: 11

if use clion:

clion preference --> Environment ---> /some_path_to/torchscript/libtorch/share/cmake/Torch

Upvotes: 1

user3617536
user3617536

Reputation: 51

Got the same issue.

Solution: export Torch_DIR as env variable before cmake

e.g. i am using python virtual env on linux, and installed pytorch using 'pip'.

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

cmake blablabla
make

Upvotes: 5

Related Questions