I’m trying to build MNIST sample file from PyTorch Examples. Here’s what I’ve followed as of now:
Clone examples.
Open x64 Native tools Command prompt for VS 2019
Go to the directory and cmake -DCMAKE_PREFIX_PATH="C:\Users\krshr\Downloads\libtorch\libtorch" -G "NMake Makefiles"
The files were generated successfully.
I then ran “nmake”
It shows some warnings but at last it shows: “Build target mnist”.
I then copied the dll files (torch.dll, caffe2.dll and c10.dll) from unzipped libtorch (nightly version) to the directory having executable file.
Once done, I ran: “mnist.exe” in the prompt and looks like it wasn’t successful while loading MNIST data (I had 2 cout statements before and after loading data - only before one gets printed to the console). The error is: abort() has been called
set(Torch_DIR f:/libtorch_gpu/share/cmake/Torch/)
FIND_PACKAGE(Torch REQUIRED)
find_package(CUDA REQUIRED)
if(CUDA_FOUND)
# There is some bug in CMake (FindCUDA.cmake) that causes it to mess up the -std=c++11 option
# if you let it propagate it to nvcc in some cases.
if(NOT MSVC)
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
list(APPEND CUDA_NVCC_FLAGS -std=c++11)
endif()
endif()
Thanks for your response @dambo. I am trying to run non-CUDA version of libtorch. For the DLL files you mentioned, looks like most of the DLL files are for CUDA version.
As far as the CMake is concerned, I added Torch_DIR and CMAKE_PREFIX_PATH to CMakeLists.txt. It builds successfully as before, but exits abruptly without showing any error or message. [Also, the problem is with the data loading as the cout statement after data loader doesn’t get executed]
I tried to use cmake -g "Ninja" command and then did ninja to make. After running mnist.exe here is the assertion failed error. After ignoring, it ends immediately.