问题遇到的现象和发生背景
运行后直接报了这个错误,这个该怎么解决呀
RuntimeError: CUDA out of memory. Tried to allocate 64.00 MiB (GPU 0; 6.00 GiB total capacity; 4.65 GiB already allocated; 0 bytes free; 4.71 GiB reserved in total by PyTorch) If reserved
运行后直接报了这个错误,这个该怎么解决呀
RuntimeError: CUDA out of memory. Tried to allocate 64.00 MiB (GPU 0; 6.00 GiB total capacity; 4.65 GiB already allocated; 0 bytes free; 4.71 GiB reserved in total by PyTorch) If reserved
这种差不多有两种情况,一个是设置参数过大导致GPU内存不足一开始就无法承载模型,这时可以把输入数据长度或者训练批次逐步调小进行实验;二是GPU其实可以承载模型,参数也没问题,但是可能由于多次运行程序或其它因素导致GPU内存未释放,可以通过nvidia-smi查看系统GPU使用情况,使用相关命令关闭占用的进程