本文主要是介绍RuntimeError: CUDA error: out of memory,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题背景
执行 torch.load
导入某个 .pt
文件的时候出现了如下错误:
RuntimeError: CUDA error: out of memory
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
解决方案
将其导入到cpu上即可解决:
model = torch.load('/path/to/model.pt', map_location='cpu')
这篇关于RuntimeError: CUDA error: out of memory的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!