RuntimeError: CUDA out of memory 的解决

    今晚在跑代码的时候出现这个问题,但是查看了一下GPU,命名内存是够的,后面发现虽然自己看到的内存是够的,但是真实的原因的确是因为内存不够导致,最后我调低了batchSize 问题就解决了!

Traceback (most recent call last):
  File "train_SCRN.py", line 84, in 
    pred_sal, pred_edge = model(images)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ihavc/PycharmProjects/SCRN-ASSP/model/ResNet_models.py", line 240, in forward
    x_s1, x_s2, x_s3, x_s4, x_e1, x_e2, x_e3, x_e4 = self.df4(x_s1, x_s2, x_s3, x_s4, x_e1, x_e2, x_e3, x_e4)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ihavc/PycharmProjects/SCRN-ASSP/model/ResNet_models.py", line 121, in forward
    self.conv8(x_s3, x_e1) *
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ihavc/PycharmProjects/SCRN-ASSP/model/ResNet_models.py", line 52, in forward
    x = self.conv(F.upsample(x, size=target.size()[2:], mode='bilinear', align_corners=True))
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ihavc/PycharmProjects/SCRN-ASSP/model/ResNet_models.py", line 28, in forward
    x = self.conv_bn(x)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/container.py", line 92, in forward
    input = module(input)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 81, in forward
    exponential_average_factor, self.eps)
  File "/home/ihavc/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/functional.py", line 1670, in batch_norm
    training, momentum, eps, torch.backends.cudnn.enabled
RuntimeError: CUDA out of memory. Tried to allocate 26.00 MiB (GPU 0; 10.73 GiB total capacity; 9.55 GiB already allocated; 28.31 MiB free; 19.44 MiB cached)

 

你可能感兴趣的:(pytorch,深度学习,python,python,深度学习)