linux安装VTM时报错Could not find a package configuration file provided by "Torch"
问题
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.
CMake Error at CMakeLists.txt:134 (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.
解决办法
报错显示没有torch,所以这一步最关键的是 在 CMakeLists.txt 里设置你的 libtorch 的路径,在CMakeLists.txt 里找到find_package(Torch REQUIRED)这一行代码,在这行代码前面加上set(Torch_DIR /home/book/libtorch/share/cmake/Torch) # 我的 libtorch 的路径
像下面这样就行了
set(Torch_DIR /home/book/libtorch/share/cmake/Torch) #/home/book/libtorch/share/cmake/Torch 是我的 libtorch 的路径
find_package(Torch REQUIRED)