AI软件下载
有趣网站推荐及实用软件下载

torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.88 GiB. GPU 0 has a total capacity of 44.40 GiB of which 1.59 GiB is free. Including non-PyTorch memory,

Python应用报错:

torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.88 GiB. GPU 0 has a total capacity of 44.40 GiB of which 1.59 GiB is free. Including non-PyTorch memory, this process has 42.80 GiB memory in use. Of the allocated memory 38.56 GiB is allocated by PyTorch, and 3.75 GiB 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)

出错原因就是显存不足,报错已经提示解决方法了,设置环境变量减少内存碎片化,在Python脚本里添加如下代码:

import os
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'

副业收入超主业,热门变现项目:点击查看>>

软件催更及1对1人工答疑支持: https://nuowa.net/1806
赞(0) 打赏
软件无法使用?点击查看常见问题说明>>

最近更新

UV包管理器用法基础教程

UV是一个用 Rust 编写的高性能工具,旨在替代 Python 传统的包管理工具链,速度比 pip 和 Conda 快数十甚至上百倍。 安装 uv 你可以通过一条命令安装 uv: 安装后,...

comfyui视频人物换主体工作流及模型下载-诺瓦小站

comfyui视频人物换主体工作流及模型下载

本次分享一个好玩的视频人物换主体工作流,本工作流可以使用一张图片中的主体替换视频中的人物主体。比如抖音上很多热门的猴子炒饭,奥特曼炒饭,猴子vlog等等,都可以使用人物主体替换把原来视频中的人物替换成指定的人物。 comfyui工作流节点使...

觉得文章对你有帮助就打赏一下作者

非常感谢你的打赏,我将有更多的动力继续提供优质内容,让我们一起创建更加美好的世界!

支付宝扫一扫

微信扫一扫