相关疑难解决方法(0)

如何避免 PyTorch 中的“CUDA 内存不足”

我认为对于 GPU 内存较低的 PyTorch 用户来说,这是一个非常普遍的信息:

RuntimeError: CUDA out of memory. Tried to allocate  MiB (GPU ;  GiB total capacity;  GiB already allocated;  MiB free;  cached)
Run Code Online (Sandbox Code Playgroud)

我想为我的课程研究对象检测算法。许多深度学习架构需要大容量的 GPU 内存,所以我的机器无法训练这些模型。我尝试通过将每一层加载到 GPU 然后将其加载回来来处理图像:

RuntimeError: CUDA out of memory. Tried to allocate  MiB (GPU ;  GiB total capacity;  GiB already allocated;  MiB free;  cached)
Run Code Online (Sandbox Code Playgroud)

但它似乎不是很有效。我想知道在使用很少的 GPU 内存的同时训练大型深度学习模型是否有任何提示和技巧。提前致谢!

编辑:我是深度学习的初学者。如果这是一个愚蠢的问题,请道歉:)

python object-detection low-memory deep-learning pytorch

39
推荐指数
6
解决办法
10万
查看次数