TORCHLIB/C++ crash Unreal Engine 4 when loading torch_cpu.dll

Hi, I’m facing an issue when trying to run a network inside Unreal Engine.

I was able to successfully compile the Unreal project with torchlib and I’m also able to perform some basic operations inside the engine, like tensors creation and jit modules loading.
The issue arises when trying to run the forward method. I’ve seen the issue reported some times in other posts online but without a definitive solution. Trying to understand where the issue is actually, I realized it is (at least it looks like that) on the loading of the torch_cpu.dll, which crashed the engine.
I’m not able to understand if it’s a libtorch or an Unreal related problem.

Any help would be appreciated.

hey, do you found any way to import libtorch onto unreal engine without using dark magic and huge amount of vodka?

upd: i traced loading process to WindowsPlatformProcess.cpp (1950th line) and it looks like its crashing on LoadLibrary() call with “torch_cpu” as an argument. So i have exactly the same problem

I was able to run torchscript models at runtime using a little wrapper over libtorch stuff in UE5 EarlyAccess2. But the exact same code doesn’t work since Prevew1. The engine started to mess up with libs at the dll loading stage (just stuck at 75%). Something is definitely broken there.

I have a similar problem. For me, everything works fine in UE4, but it freeze (no crash) when loading torch_cpu.dll in UE5.

Has anyone here come to a solution?

I experience freeze on 75% on this setup - UE 5.3.2, Win 11, MSVS 2022, libtorch - downloaded .zip from official site, versions 2.0.1, and 2.1.0
Unyone resolved this somehow?