cmake를 사용하는 과정에서 에러가 발생합니다

이 튜토리얼을 이용해서 파이토치 모델을 C++로 변환하는 중입니다만
cmake를 이용하는 과정에서
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch .. 명령어를 입력할 때
TorchConfig.cmake torch-config.cmake를 찾을 수 없다는 에러가 계속 반복됩니다
깃허브나 스택오버플로의 글을 읽어봐도 완전히 에러가 해결된 해법은 찾지 못하고 있습니다.
아래는 로그입니다
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.32.31329.0
-- The CXX compiler identification is MSVC 19.32.31329.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:4 (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!
See also "C:/Users/com/source/repos/luda1/luda1/CMakeFiles/CMakeOutput.log".
libtorch의 파일을 찾지 못하는듯한데, 해결방법이 있을까요 ??

2개의 좋아요

위에서 입력하신 아래 명령어를

혹시 "/path/to/libtorch"를 입력하신 것은 아닌가요?
만약 그러시면 libtorch를 다운 받으신 다음 자신의 경로를 입력하시기 바랍니다.

1개의 좋아요

libtorch 들어가있는 폴더 경로 입력하였습니다

1개의 좋아요

CMakelist.txt.에서
find_package(Torch REQUIRED) 부분을
find_package(Torch) 로 바꾸고 컴파일하면 어떻게 되나요?

2개의 좋아요

제 컴퓨터에 Visual Studio 2022를 설치 + cmake 설치 + libtorch 다운 & 압축 풀기

일단 저는 문제가 없었고 결국 경로 문제가 아닐까 하는데요

  1. libtorch의 경로가 cmake를 실행하는 폴더 아래는 아닌지
  2. 경로 입력이 오타나 특수 기호 등 다른 문제가 있는것은 아닌지 확인이 필요합니다.
1개의 좋아요

https://github.com/pytorch/pytorch/issues/12449
저는 여기서 ganler님의 답변 참고해서 해결했습니다.

1개의 좋아요