训练模型时显示CUDA内容不足,我的显卡是4060-8G
错误是torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 8.00 GiB total capacity; 933.87 MiB already allocated; 4.95 GiB free; 948.00 MiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
请教大家如何解决 并且batchsize已经设置为1
训练模型时显示CUDA内容不足
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
关注 【相关推荐】
- 文章:报错记录torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 90.00 MiB (GPU 0; 7.93 GiB to 中也许有你想要的答案,请看下吧
- 除此之外, 这篇博客: RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total capacity; 1.34中的 1. with torch.no_grad() 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
注意pytorch在test时,一定要加上:
with torch.no_grad(): outputs = Net_(inputs) ---错误代码的位置。
不计算梯度,否则会使显存加倍导致OOM错误。
如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^解决 无用评论 打赏 举报
悬赏问题
- ¥15 表达式必须是可修改的左值
- ¥15 如何绘制动力学系统的相图
- ¥15 对接wps接口实现获取元数据
- ¥20 给自己本科IT专业毕业的妹m找个实习工作
- ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
- ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
- ¥50 mac mini外接显示器 画质字体模糊
- ¥15 TLS1.2协议通信解密
- ¥40 图书信息管理系统程序编写
- ¥20 Qcustomplot缩小曲线形状问题