Optimize pkl model to trt model

hi I’m new in using tensorrt. I have a .pkl model and I don’t know how to optimize it with tensorrt. I try to convert it to onnx or torch2trt but it return this error: TypeError: forward() missing 1 required positional argument: ‘x2’
I tried to convert pkl to pth model or json model but this work doesn’t work too and return this error: “_pickle.UnpicklingError”
can you please help me to optimize my model?

Based on the error message you should check the inputs to the forward method of your model and make sure all requires arguments are provided, such as the x2 argument in this case.
Besides that I don’t know what else might be causing it as only the error message was posted.

Also, please don’t tag specific users as it could demotivate others to post a valid answer.

thanks for your reply, I’ll check it again and my code is here:
device = torch.device(“cuda:0” if torch.cuda.is_available() else “cpu”)
net = torch.load(‘./train_model/best.pkl’)
x = torch.ones(1, 1, 256, 256).cuda()
model_trt = torch2trt(net, [x])

torch.save(model_trt, ‘best_trt.pkl’)
from torch2trt import TRTModule

model_trt = TRTModule()


total_score = demo(data_path, net, save_video=args.save,vis=args.vis)
print(f’score: {total_score}')`"