报错`RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 9.78 GiB total capaci

报错RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 9.78 GiB total capacity; 8.10 GiB already allocated;
用的3080显卡,内存1MiB / 10018MiB
batch_size只能设置较小的值。

1 和网络结构有关

1)9个卷积块(每块包括两个卷积层),batch_size最大为1;

  self.Conv1 = conv_block(ch_in=3, ch_out=64)
  self.Conv2 = conv_block(ch_in=64, ch_out=128)
  self.Conv3 = conv_block(ch_in=128, ch_out=256)
  self.Conv4 = conv_block(ch_in=256, ch_out=512)
  self.Conv5 = conv_block(ch_in=512, ch_out=512)
  self.Conv6 = conv_block(ch_in=512, ch_out=256)
  self.Conv7 = conv_block(ch_in=256, ch_out=128)
  self.Conv8 = conv_block(ch_in=128, ch_out=64)
  self.Conv9 = conv_block(ch_in=64, ch_out=3)

2) 4个卷积块(每块包括两个卷积层),batch_size最大为8;

 self.Conv1 = conv_block(ch_in=3, ch_out=64)
 self.Conv2 = conv_block(ch_in=64, ch_out=128)
 self.Conv3 = conv_block(ch_in=128, ch_out=64)
 self.Conv4 = conv_block(ch_in=64, ch_out=3)

2 和通道数有关:

1)4个卷积块,通道数3-64-64-64-3,batch_size最大为8;

 self.Conv1 = conv_block(ch_in=3, ch_out=64)
 self.Conv2 = conv_block(ch_in=64, ch_out=64)
 self.Conv3 = conv_block(ch_in=64, ch_out=64)
 self.Conv4 = conv_block(ch_in=64, ch_out=3)

2)4个卷积块,通道数3-64-256-512-3,batch_size最大为2;

 self.Conv1 = conv_block(ch_in=3, ch_out=64)
 self.Conv2 = conv_block(ch_in=64, ch_out=256)
 self.Conv3 = conv_block(ch_in=256, ch_out=512)
 self.Conv4 = conv_block(ch_in=512, ch_out=3)

你可能感兴趣的:(计算机视觉,深度学习,tensorflow,cnn)