I am once again trying to use torch on windows 10, but it keeps giving me headaches. I have now tried to use the VC compiler (14.20) to compile the tutorial project, but the linking part seems to fail.
In detail:
I dont get these errors on Ubuntu and can work with torch fine on it. It should find and link the torch.dll automatically given the linking command in Cmake, shouldn’t it? Can someone point me towards the reason why this is failing for me on Windows?
I was facing the same problem as mentioned. I copied the DLLs in the build directory (where the executable file is located), but it gives the following error:
Environment:
Visual Studio 2019
CMake Version: 3.15.0-rc1
Windows 10
Not sure what’s going wrong. Can you help with this?
You are using the wrong libraries I guess. If you built PyTorch yourself, then you should use your own copy. Otherwise, please copy those from [PythonRoot]\Lib\site-packages\torch\lib if you build using the conda/pip version or [LibTorchRoot]\lib if you use LibTorch.
1> CMake generation started for configuration: 'x64-Release'.
1> Command line: "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\krshr\OneDrive\Documents\GitHub\Digit-3\out\install\x64-Release" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe" -DCMAKE_PREFIX_PATH=C:\Users\krshr\Downloads\libtorch\libtorch -DCMAKE_BUILD_TYPE="Release" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\krshr\OneDrive\Documents\GitHub\Digit-3"
1> Working directory: C:\Users\krshr\OneDrive\Documents\GitHub\Digit-3\out\build\x64-Release
1> [CMake] -- Looking for pthread.h
1> [CMake] -- Looking for pthread.h - not found
1> [CMake] -- Found Threads: TRUE
1> [CMake] CMake Warning (dev) at C:/Users/krshr/Downloads/libtorch/libtorch/share/cmake/Caffe2/public/utils.cmake:57 (if):
1> [CMake] Policy CMP0054 is not set: Only interpret if() arguments as variables or
1> [CMake] keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
1> [CMake] details. Use the cmake_policy command to set the policy and suppress this
1> [CMake] warning.
1> [CMake]
1> [CMake] Quoted variables like "MSVC" will no longer be dereferenced when the policy
1> [CMake] is set to NEW. Since the policy is not set the OLD behavior will be used.
1> [CMake] Call Stack (most recent call first):
1> [CMake] C:/Users/krshr/Downloads/libtorch/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:121 (caffe2_interface_library)
1> [CMake] C:/Users/krshr/Downloads/libtorch/libtorch/share/cmake/Torch/TorchConfig.cmake:40 (find_package)
1> [CMake] CMakeLists.txt:3 (find_package)
1> [CMake] This warning is for project developers. Use -Wno-dev to suppress it.
1> [CMake] CMake Warning (dev) at C:/Users/krshr/Downloads/libtorch/libtorch/share/cmake/Torch/TorchConfig.cmake:80 (if):
1> [CMake] Policy CMP0054 is not set: Only interpret if() arguments as variables or
1> [CMake] keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
1> [CMake] details. Use the cmake_policy command to set the policy and suppress this
1> [CMake] warning.
1> [CMake]
1> [CMake] Quoted variables like "MSVC" will no longer be dereferenced when the policy
1> [CMake] is set to NEW. Since the policy is not set the OLD behavior will be used.
1> [CMake] Call Stack (most recent call first):
1> [CMake] CMakeLists.txt:3 (find_package)
1> [CMake] This warning is for project developers. Use -Wno-dev to suppress it.
1> [CMake] -- Found torch: C:/Users/krshr/Downloads/libtorch/libtorch/lib/torch.lib
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: C:/Users/krshr/OneDrive/Documents/GitHub/Digit-3/out/build/x64-Release
1> [CMake]
1> Extracted includes paths.
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> CMake generation finished.