GPU video memory

gpu:4G
想要训练一个程序,但是总是显示显存不够,是否有方法可以解决这个问题,所有占用显存的进程已经关闭。谢谢大家。
下面是报错:
RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 4.00 GiB total capacity; 2.73 GiB already allocated; 3.35 MiB free; 2.82 GiB reserved in total by PyTorch)
gpu:4G
想要训练一个程序,但是总是显示显存不够,是否有方法可以解决这个问题,所有占用显存的进程已经关闭。谢谢大家。
下面是报错:
RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 4.00 GiB total capacity; 2.73 GiB already allocated; 3.35 MiB free; 2.82 GiB reserved in total by PyTorch)
gpu:4G

Want to train a program, but always show the video memory is not enough, whether there is a way to solve this problem, all the processes that occupy the video memory have been closed. Thank you.

Here is the error report:

RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 4.00 GiB total capacity; 2.73 GiB already allocated; 3.35 MiB free; 2.82 GiB reserved in total by PyTorch)

You could try to lower the batch size, use a smaller model, or use torch.utils.checkpoint to trade compute for memory.
If that doesn’t work, you could use e.g. Colab, which should provide a GPU with more memory.