Thanks for your advice.
The prediction and target use all GPUs (4 GPUs). This line is suitable for the prediction and target of the first GPU.
gen_dx = torch.abs(nn.Functional.conv2d((gen_frame_x).to('cuda:0'),self.filter_x))

I need
gen_dx = torch.abs(nn.Functional.conv2d((gen_frame_x).to('cuda:0'),self.filter_x))
gen_dx = torch.abs(nn.Functional.conv2d((gen_frame_x).to('cuda:1'),self.filter_x))
gen_dx = torch.abs(nn.Functional.conv2d((gen_frame_x).to('cuda:2'),self.filter_x))
gen_dx = torch.abs(nn.Functional.conv2d((gen_frame_x).to('cuda:3'),self.filter_x))

How to do this?