I built my model with this code. And I load a model I already  have saved with torch.save(model, path_to_model).
CUDA_LAUNCH_BLOCKING="1"

torch.set_default_tensor_type(torch.DoubleTensor) 
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)

# CUDA for PyTorch
use_cuda = torch.cuda.is_available()
device = torch.device("cuda:0" if use_cuda else "cpu")
print("device is ", device)

num_classes = 2 

# get number of input channels fGénial or the classifier
in_features = model.roi_heads.box_predictor.cls_score.in_features
# replace the pre-trained head with a new one
model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)

model.to(device)

params = [p for p in model.parameters() if p.requires_grad]
optimizer = torch.optim.SGD(params, lr=0.001,
                            momentum=0.9, weight_decay=0.0005)
lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer,
                                               step_size=10,
                                               gamma=0.5)

model.load_state_dict(torch.load(path_to_model))

model.eval()

input_tensor = torch.rand(1,3,224,224)
script_model = torch.jit.trace(model, input_tensor)
script_model.save("models/fRCNN_resnet50.pt")


If this is not enough what should I send you to reproduce this error ?
Thanks!