OutOfMemoryError: CUDA out of memory.Tried to allocate 128.00 MiB.......却未占用显存,个人方法简单实用

完整报错提示OutOfMemoryError: CUDA out of memory. Tried to allocate 128.00 MiB. GPU 0 has a total capacity of 6.00 GiB of which 0 bytes is free. Of the allocated memory 5.25 GiB is allocated by PyTorch, and 834.00 KiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management  (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

笔者的显存大小为6g,但没有占用gpu,猜测是显存过小导致的问题

笔者直接在命令行运行相关python文件,因此找到目标文件

在右下角添加quantize(4),就保证代码的正常运行

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
torch.cuda.OutOfMemoryError: CUDA out of memory是指在使用PyTorch进行GPU计算时,出现了内存不足的错误。具体来说,在尝试分配810.00 MiB的内存时,由于已经分配了一部分内存并没有释放,导致了内存不足的情况。 解决这个问题的方法之一是调整max_split_size_mb参数,以避免内存碎片化。这个参数可以在代码中设置,具体的值可以根据情况进行调整。另外,可以查阅PyTorch的内存管理文档以及PYTORCH_CUDA_ALLOC_CONF文档,获取更多关于内存管理和配置的信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [报错记录torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 90.00 MiB (GPU 0; 7.93 ...](https://blog.csdn.net/gongkeguo/article/details/127674524)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [成功解决torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 86.00 MiB (GPU 0; 2.00 ...](https://blog.csdn.net/qq_41185868/article/details/131015210)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值