当前位置:   article > 正文

问题 sr failed: CUDA out of memory. Tried to allocate 解决_if reserved but unallocated memory is large try se

if reserved but unallocated memory is large try setting max_split_size_mb to

一 错误信息:sr failed: CUDA out of memory

sr failed: CUDA out of memory. Tried to allocate 370.00 MiB. GPU 0 has a total capacty of 12.00 GiB of which 8.66 GiB is free. Of the allocated memory 969.24 MiB is allocated by PyTorch, and 306.76 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
0 Solvay_conference_1927

如下图:

二 解读错误信息 

这个报错信息表明你的CUDA程序在执行时遇到了内存不足的问题。以下是报错信息的解释:

  1. sr failed: CUDA out of memory.:CUDA是用于进行GPU加速的计算框架,这里报告了CUDA内存不足的错误。

  2. Tried to allocate 370.00 MiB.:尝试分配了370.00兆字节(MiB)的内存。

  3. GPU 0 has a total capacity of 12.00 GiB of which 8.66 GiB is free.:GPU 0的总内存容量为12.00吉字节(GiB),其中有8.66 GiB是空闲的。

  4. Of the allocated memory 969.24 MiB is allocated by PyTorch, and 306.76 MiB is reserved by PyTorch but unallocated.:已经分配的内存中,969.24 MiB被PyTorch使用,而另外的306.76 MiB被PyTorch保留但尚未分配。

  5. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation.:如果保留但未分配的内存很大,可以尝试设置max_split_size_mb以避免碎片化。这是一个建议,你可以尝试调整一些相关的参数来优化内存分配。

  6. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF:查看内存管理和PYTORCH_CUDA_ALLOC_CONF的文档,以获取更多关于内存管理和配置的信息。

三 分析原因与解决:

提示的是与gpu内存有关,根据本机环境查看本机gpu内存,如下图:

当前的 gpu总内存总12G,只有了3.7G,还有8G左右,与上面的错误描述对得上,部分gpu内存被占用,先清找出占用gpu内存进程优化掉先。

找出占用gpu的app,如下图:

 优化掉占用gpu的app后,gpu内存占用情况如下图:

再次运行项目,这时不会出现报“sr failed: CUDA out of memory”显存不够错误 ,成功解决该问题。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/220631
推荐阅读
相关标签
  

闽ICP备14008679号