Reputation: 1
I am trying to get started with DeepLearning using libtorch, pytorch's C++ version on my Windows machine.
However, problems have been arising throughout the installation process: Namely, I cannot seem to find my libtorch-library inside clion.
The error message I get is:
CMake Error at CMakeLists.txt:6 (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 am a little ashamed to even ask this question, because it looks like the error message is very descriptive, but I have been trying for a couple of hours now and cannot solve it. So far I have tried:
It looks like there is a very simple solution to this using cmake, however, I am fairly new to cmake, so I hope someone can help me in a way I can understand.
EDIT: Okay, I was able to fix it with all of your help, thank you guys and especially @drescherjm helping out my cmake-illiterate butt.
Upvotes: 0
Views: 2073
Reputation: 3678
The error instructs you to
set "Torch_DIR" to a directory containing one of the above files`.
You can set one by passing it as a command line argument:
cmake .. -G Ninja -DTorch_DIR="path_to_your_local_torch_dir
Do NOT include your local paths within your CMakeLists.txt like the other answers suggest you to.
Upvotes: 0
Reputation: 11
this is my CMakeLists.txt and it works:
cmake_minimum_required(VERSION 3.17)
project(libtorch_test)
set(CMAKE_CXX_STANDARD 14)
add_executable(libtorch_test main.cpp)
set(CMAKE_PREFIX_PATH /home/myhost/device/libtorch/share/cmake/Torch)
find_package( Torch REQUIRED )
key point for the issue is that set CMAKE_PREFIX_PATH as your/path//libtorch/share/cmake/Torch
Upvotes: 1