pytorch出现RuntimeError: CUDA out of memory.
无论batch-size设置多小也是会出现这个问题的,我的原因是我将pytorch升级到了1.0.1,然后出现了这个问题
RuntimeError: CUDA out of memory. Tried to allocate 823.88 MiB (GPU 0; 7.93 GiB total capacity; 6.96 GiB already allocated; 189.31 MiB free; 10.26 MiB cached)
你可以监控一下之GPU的使用情况 ,使用下面的命令
watch -n 0.1 nvidia-smi
在期间会出现GPU的使用率达到99%,估计是没有释放GPU内存吧。
解决方法
我出现问题的代码,在输入到网络里面 ,如下:
output = net(input,inputcoord)
将这个代码做如下修改,其中torch.no_grad()是禁用梯度计算的上下文管理器,一般是在validate或者test会使用,只需要计算网络的输出,而无需计算梯度了。
with torch.no_grad():output = net(input,inputcoord)
附带
在调试低版本的pytorch源程序的时候也会出现警告
UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
也可以在前面添加下面的解决这个问题
with torch.no_grad():
参考
https://blog.csdn.net/xijuezhu8128/article/details/86594478
https://pytorch.org/docs/stable/generated/torch.no_grad.html?highlight=torch%20no_grad#torch.no_grad
pytorch出现RuntimeError: CUDA out of memory.相关推荐
- pytorch出现RuntimeError: CUDA out of memory的问题解决方法
pytorch出现RuntimeError: CUDA out of memory解决方法 将batch-size设置小些试试,如果不行,继续第二步 多线程num_works设置较小,最差设为0
- pytorch遇见RuntimeError: CUDA out of memory的解决
RuntimeError: CUDA out of memory 1.查看是否其他程序占用显存 遇到此类错误后,对于py格式的文件来说,程序会进行终止,也就是当前程序占用的显存将会被释放.此时可用 w ...
- python pytorch爆显存,内存溢出问题解决方法(总结)RuntimeError: CUDA out of memory.
问题描述 在运行python程序时,随运行时间增长,内存疯狂增加,直至运行内存爆满,出现以下错误: RuntimeError: CUDA out of memory. 解决方法: 1.在模型验证和测试 ...
- RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capacity; 3.41
pytorch报错:RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capa ...
- RuntimeError: CUDA out of memory. Tried to allocate 1.54 GiB...
报错 F:\Anaconda3\python.exe "E:/Program Files/PyCharm 2019.2/***/xxx.py" F:\Anaconda3\lib\s ...
- 显存不足问题(OOM、RuntimeError: CUDA out of memory)
显存不足问题(OOM.RuntimeError: CUDA out of memory). 记录一次pytorch yolov3爆显存(windows使用任务管理器查看显存为4G). 2G显存:SSD ...
- RuntimeError: CUDA out of memory
报错内容: RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total capacity; ...
- RuntimeError: CUDA out of memory. Tried to allocate 170.00 MiB (GPU 0; 3.82 GiB total capacity; 1.94
错误: RuntimeError: CUDA out of memory. Tried to allocate 170.00 MiB (GPU 0; 3.82 GiB total capacity; ...
- 【PyTorch问题】CUDA out of memory. Tried to allocate 4.69 GiB (GPU 0; 8.00 GiB total capacity...略
问题描述:RuntimeError: CUDA out of memory. Tried to allocate 4.69 GiB (GPU 0; 8.00 GiB total capacity; 5 ...
最新文章
- setuid和setgid
- Windows Socket 编程_ 简单的服务器/客户端程序 .
- mysql导入Excel数据
- 【Eclipse提高开发速度-插件篇】安装VJET插件,JS等提示开发插件
- 谁今天收到鸿蒙系统推送,鸿蒙系统正式推送,只有部分高端机才能收到
- webservice 原理
- asp.net mysql所有数据库_asp.net 如何获取sql数据库所有列名称
- 如何用html制作彩虹,使用transform和arc方法,怎么绘制彩虹效果。
- matlab绘制正弦波
- jeb安装教程_《教我兄弟学Android逆向番外02 jeb工具的使用》
- iPhone手机开启定位权限后,仍然无法定位
- SmartDNS设置和各个选项意义使用指南
- 为何电脑上不显示手机连接服务器,为什么我电脑都能连接上vpn手机却连不上
- dva学习-入门安装和目录介绍
- python实现基于SIFT算法的图像配准(仿射变换)
- 一种将pkl转成excel的弯道[可以实现有点奇怪,以防excel显示不全]
- Markdown插入图片操作
- 什么是RC高通滤波电路
- 解决 Request Entity Too Large问题
- 咸鱼ZTMR实例—板载LED
热门文章
- C# Reflection
- python - 编程规范问题
- HDU 6356.Glad You Came-线段树(区间更新+剪枝) (2018 Multi-University Training Contest 5 1007)...
- 测试工程方法:判定表驱动法
- 【LeetCode】231. Power of Two
- 图像预处理第4步:去离散杂点噪声
- 详解CSS position属性
- underscore javascript工具库支持seajs模块化
- 使用JavaScript弹出Confirm对话框
- SQLite入门笔记