Ubuntu下跑Aplaca报错:torch.cuda.0utofMemoryError: CUDA out of memory.解决办法(查看CUDA占用情况&清除GPU缓存)

缓存不够!!!!并非内存容量不够

错误提示: torch.cuda.0utofMemoryError: CUDA out of memory.Tried to allocate 2.00 MiB (PU 0; 23.69 GiB total capacity; 237 BiB already allocated; 18.38 MiB fre; 2.50 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
在这里插入图片描述
通过查资料,说内存不够用,换个好显卡,可但是通过运行指示nvidia-smi发现在执行程序时仅使用极少的内存(图片-1%),因此不是内存不足,考虑可能是缓存爆了!
在这里插入图片描述
在这里插入图片描述
观察下面的进程发现12757(准备执行的程序aplaca)占比GPU显存很大,用sudo skill -9 12757 杀掉它后重新执行待训练的程序。
在这里插入图片描述
成功执行,再次验证一下猜想是否正确,再次在终端输入nvidia-smi,发现从1%升到95%,问题解决!
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/LZL2020LZL/article/details/130270895