Libtorch torch::jit::load gives c10::Error unknown error when loading model in windows

I’m porting my model from ubuntu to Windows, but I cannot load the model using C++ in Windows.
The loading is fine using python in both OS, and C++ loading works fine in ubuntu.
But when I try to load the same model file using C++ in Windows, it gives me c10::Error unknown error.
Here is the model file and the CMakeList I’m using. (I’m using Visual Studio 15 2017 Win64 as CMAKE_GENERATOR)
https://drive.google.com/open?id=1xQlx2VFKg1fyFAP0HDcVKU-yLmW5tm3x

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(IKAI)
find_package(Torch REQUIRED)
add_library(IKAI SHARED IKAI.cpp IKAI.h)
target_link_libraries(IKAI "${TORCH_LIBRARIES}")
set_property(TARGET IKAI PROPERTY CXX_STANDARD 11)

add_executable(test_IKAI IKAI.cpp)
target_link_libraries(test_IKAI "${TORCH_LIBRARIES}")
set_property(TARGET test_IKAI PROPERTY CXX_STANDARD 11)

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")

I have tried different pytorch version and cuda version, but no progress.
Does anyone has the same problem?

Could you post the output of the compilation process?

Yes, here is it.
The command I used to build is

cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=C:\lib\libtorch -DCMAKE_BUILD_TYPE=Debug
msbuild IKAI.sln

This is the output from msbuild.
https://pastebin.com/81zcb30B
And the output from cmake.
https://pastebin.com/NuHfQjXE
https://pastebin.com/aCzNx6tr

I’m new to cmake and msbuild, so maybe I missed some important options. But things are fine in ubuntu without any additional options, so I have no idea what it should be.

I finally find an answer from here.


I have to build it in Release configuration.
Now it works.