I am making segmentation with libtorch.
Input is 2242243 and output will 2242241 mask image.
This is working well with CPU device, but when I try GPU it crashed at cv::convertTo  function.
My code is like this.
torch::NoGradGuard no_grad;
segmentation->eval();
torch::Tensor val_loss;
for (torch::data::Example<torch::Tensor, torch::Tensor>& batch : *data_loader_val) {
auto data = batch.data.to(device);
auto targets = batch.target.to(device);
				
try {
			torch::Tensor outputs = segmentation->forward(data);

			float* gt = targets.data_ptr<float>();
			float* pr = outputs.data_ptr<float>();
			char name[80];

			for (auto i = 0; i < outputs.sizes()[0]; i++)
			{
						auto gttmp = gt + i * 224 * 224;
						cv::Mat gtmat(224, 224, CV_32FC1, gttmp);
						gtmat.convertTo(gtmat, CV_8UC1, 255);

						sprintf_s(name, "gt%d", i);
						cv::imshow(name, gtmat);

						auto prtmp = pr + i * 224 * 224;
						cv::Mat ptmat(224, 224, CV_32FC1, prtmp);
						ptmat.convertTo(ptmat, CV_8UC1, 255);

						sprintf_s(name, "pr%d", i);
						cv::imshow(name, ptmat);
			}
}

Could I have a clue for this problem?