Sorry , I forgot to post the code. Do you mean that I should use gpuMat to load my image onto gpu firstly and then calculate it ?
/pytorch 1.2/
#include “torch/script.h”
#include “torch/torch.h”
#include <opencv2/opencv.hpp>
#include 
#include 
#include 
using namespace std;
using namespace cv;
int main()
{
int height = 1248;
int width = 384;
Mat img = imread("/media/usr515/ed65d8df-d015-4269-90bc-ac3cccb109a8/dsq/zz/stereo/train/2011_09_26_drive_0002_sync/image_02/data/0000000007.png");   
Mat temImg;
resize(img,temImg,Size(height,width),0,0,INTER_LINEAR);
cvtColor(temImg, temImg, CV_RGB2BGR);    
temImg.convertTo(temImg,CV_32FC3,1.0);
torch::Tensor tensor_image = torch::from_blob(temImg.data, {temImg.rows, temImg.cols , 3}, torch::kFloat);        
tensor_image = tensor_image.permute({2,0,1});
tensor_image = tensor_image.unsqueeze(0);
tensor_image = tensor_image.cuda();


Mat img_1 = imread("/media/usr515/ed65d8df-d015-4269-90bc-ac3cccb109a8/dsq/zz/stereo/train/2011_09_26_drive_0002_sync/image_03/data/0000000007.png");   
Mat temImg_1;
resize(img_1,temImg_1,Size(width,height),0,0,INTER_LINEAR);    
cvtColor(temImg_1, temImg_1, CV_RGB2BGR);
temImg_1.convertTo(temImg_1,CV_32FC3,1.0);
torch::Tensor tensor_image_1 = torch::from_blob(temImg_1.data, {temImg_1.rows, temImg_1.cols , 3}, torch::kFloat);        
tensor_image_1 = tensor_image_1.permute({2,0,1});
tensor_image_1 = tensor_image_1.unsqueeze(0);
tensor_image_1 = tensor_image_1.cuda();

torch::jit::script::Module module = torch::jit::load("/media/usr515/ed65d8df-d015-4269-90bc-ac3cccb109a8/dsq/zz/stereo/psmnet_256_1.pt" , torch::kCUDA);


torch::Tensor result = module.forward({tensor_image , tensor_image_1}).toTensor();

cout << result << endl;

return 1;

}