'libtorch throws c10::error after build on Windows 10 (VS2019)

I've tried to build libtorch on Windows 10 using VS 2019 without CUDA and Python. Independent if I compile it with or without MKL, a simple test program crashes directly after start. After building the debug version, libtorch throws a c10:error in a function called torchCheckFail.

The function seems to complain about ATen/core/jit_type.h.

The problem is part of torch_cpu.dll. The problem disappears when I'm using the precompiled binaries for Windows.

Here's the function:

void torchCheckFail(
    const char* func,
    const char* file,
    uint32_t line,
    const std::string& msg) {
  throw ::c10::Error({func, file, line}, msg);
}

And here's the call stack:

Call Stack



Solution 1:[1]

I encountered the same exact error with the same environment.

A solution that worked for me was to take a release version of pytorch and not a non-release one (i.e. a release version + some commits).

Hope it helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 R_B