I’m trying to integrate libtoch to load a model into my application. My application does many CUDA stauff before I load the model with libtorch. Thus, the CUDA context has already been created.
For some reason, even the CUDA context has already been created and the calling thread has already a valid context, when I call
torch::jit::script::Module module = torch::jit::load(“test.pt”);
module.to(at::kCUDA);
a new context is created by libtorch. The new context is not event push to the stack of context, is overwritting the current context. I know because if after the module.to(at::kCUDA) I call cuCtxPopCurrent the current context is null.
This causes a lot of problems because I cannot interact with current allocated memory I have in my context.
Is there anyway I can initialize somehow the libtorch CUDA context to use mine?
Thanks