when I am on CPU, I have the same problem. I tried [torch::NoGradGuard no_grad_guard;] but its of no use. I compile the code to dll for another program to use. There’s no problem when I run my code independently. In another program, its still ok when the function [forward] is annotated…I really dont know how to solve, anyone knows?please help thanks!