I got error massage as follow
and memory usage is about 97%(14.8G),
GPU memory usage is about 6.8G :
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-10-f1bcb8a65b63> in <module>
     18     print('-' * 10)
     19     epoch_loss = fit(epoch,model,trainloader,phase='train')
---> 20     val_epoch_loss = fit(epoch,model,validloader,phase='valid')
     21     train_losses.append(epoch_loss)
     22     val_losses.append(val_epoch_loss)

<ipython-input-8-cb42f6cac88b> in fit(epoch, model, data_loader, phase, volatile)
     14             optimizer.zero_grad()
     15 
---> 16         output = model(inputs)
     17         pred = torch.sigmoid(output)
     18         loss = dice(pred,target)

C:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    491             result = self._slow_forward(*input, **kwargs)
    492         else:
--> 493             result = self.forward(*input, **kwargs)
    494         for hook in self._forward_hooks.values():
    495             hook_result = hook(self, input, result)

<ipython-input-5-ef5c656e99e9> in forward(self, x)
     45 
     46         x = self.dconv_up3(x)
---> 47         x = self.upsample(x)
     48         x = torch.cat([x, conv2], dim=1)
     49 

C:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    491             result = self._slow_forward(*input, **kwargs)
    492         else:
--> 493             result = self.forward(*input, **kwargs)
    494         for hook in self._forward_hooks.values():
    495             hook_result = hook(self, input, result)

C:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\upsampling.py in forward(self, input)
    129     @weak_script_method
    130     def forward(self, input):
--> 131         return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners)
    132 
    133     def extra_repr(self):

C:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py in interpolate(input, size, scale_factor, mode, align_corners)
   2561         raise NotImplementedError("Got 4D input, but linear mode needs 3D input")
   2562     elif input.dim() == 4 and mode == 'bilinear':
-> 2563         return torch._C._nn.upsample_bilinear2d(input, _output_size(2), align_corners)
   2564     elif input.dim() == 4 and mode == 'trilinear':
   2565         raise NotImplementedError("Got 4D input, but trilinear mode needs 5D input")

RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 11.00 GiB total capacity; 8.19 GiB already allocated; 174.59 MiB free; 96.81 MiB cached)

as you’ve advised, lowering the number of kernels in my UNet work! Thanks!
I tried to do a multi-organ classification, but now I want to do one organ classification.
my numpy file shapes are  image : [3600,512,512] , mask : [3600,512,512]
input tensor is  image : [4,512,512] , mask : [4,512,512] divied by batch
but output tensor is [4,1,512,512].
I think class should be 2 because of background+organ, but I don’t know how to include background in mask class.
Do you have a good idea?