I’ve downloaded the debug and release versions (current stable, v1.2) of libtorch and tried the example c++ program

#include <torch/torch.h>
#include 
int main() {
torch::Tensor tensor = torch::rand({ 2, 3 });
std::cout << tensor << std::endl;
return 0;
}

I successfully built debug and release versions of solution files for visual studio 2017 using cmake (I needed to set CMAKE_PREFIX_PATH in the CMakeLists.txt file to make it work though, because cmake failed work if I passed the argument to cmake on the command line)
After compiling in Visual Studio, I’m able to run the debug version of the program fine.
However, running the release version (sometimes) throws an exception.  It appears after the main function returns. An error dialog pops up with the text “Debug Assertion Failed!” The File is in a runtime library minkernel\crts\ucrt\src\apcrt\heap\debug_heap.cpp line:904.
The expression: _CrtlsValidHeapPointer(blk)
It runs fine if I comment out the line declaring the tensor and replace it with a default tensor constructor

// torch::Tensor tensor = torch::rand({ 2, 3 });
torch::Tensor tensor;

It does not seem to matter whether I build with v141 or v142 of MSVC toolchain or use 10.0.18362.0 or 10.0.17763.0 versions of the SDK.
I’ve also tried turning off all optimizations and in-lining. No help there either.
The only thing odd I noted is compiler warnings:

2>…\torch\libtorch-release\include\torch/csrc/jit/tracer.h(302): warning C4273: ‘torch::jit::tracer::addInputs’: inconsistent dll linkage



I don’t know why I have a debug assertion at all, since this is the release version of the app (I’ve confirmed it is compiled with /MD, not /MDd, which is for the multi-threaded dynamic link runtime)


Any other ideas what this is all about?