I want to use the trained model in C++ with libtorch.
However, it failed when I want to load a gpu model
using torch::jit::script::Module;
Module module = torch::jit::load("resnetGPU.pt", torch::kCUDA);

The gpu model is trained in linux, and the pytorch version is: 1.9.0+cu111, and the libtorch version is libtorch-win-shared-with-deps-debug-1.9.0+cu111.
The c++ project is built in win10, and the vs version is vs2022.
The code to generate the model is:
import torch
import torchvision.models as models
model = models.resnet50(pretrained=True).cuda()
model=model.eval()
resnet = torch.jit.trace(model, torch.rand(1, 3, 224, 224).cuda())
resnet.save('resnetGPU.pt')


Any suggestion is appreciated~~