pytorch报错:RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capacity; 3.41 GiB already allocated; 37.88 MiB free; 98.29 MiB cached)

如果是训练时遇到该问题,说明模型的参数太多了,将模型的参数减少该问题就解决了,改小batch_size是不能解决的(我将batch_size设为1都没解决,而且报错时的内存数据都没变)

如果是测试时遇到该问题,在测试代码前面加上:with torch.no_grad():

with torch.no_grad():# test process

ps:程序运行中可以通过watch -n 0.1 -d nvidia-smi命令来实时查看GPU占用情况,按Ctrl+c退出:

因为我使用的是2号GPU,当我的程序一运行,可以看到2号GPU的占用内存从1MiB一直飙升,直至接近4043MiB,然后就报错上面的RuntimeError

RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capacity; 3.41相关推荐

  1. RuntimeError: CUDA out of memory.Tried to allocate 20.00 MiB GPU 0 ,3.94 GiB total capacity 3.36 G

    RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 3.94 GiB total capacity; 3.36 ...

  2. 报错`RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 9.78 GiB total capaci

    报错RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 9.78 GiB total capacity; 8. ...

  3. 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; ...

  4. RuntimeError: CUDA out of memory. Tried to allocate 50.00 MiB (GPU 0; 4.00 GiB total capacity; 682.9

    1. 问题 训练模型时报错: RuntimeError: CUDA error: out of memory CUDA kernel errors might be asynchronously re ...

  5. 解决:RuntimeError: CUDA out of memory. Tried to allocate 64.00 MiB (GPU 0; 4.00 GiB total capacity; 2

    引发pytorch:CUDA out of memory错误的原因有两个: 1.当前要使用的GPU正在被占用,导致显存不足以运行你要运行的模型训练命令不能正常运行 解决方法: 1.换另外的GPU 2. ...

  6. [881]内存不足RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total cap...

    今天第一次在服务器上跑代码 也是第一次接触cuda显存卡 碰到了标题问题 将解决办法记录下来 1. 首先去查看cuda显存占用情况: nvidia-smi 显示所有GPU的当前信息状态(图源网络 不想 ...

  7. RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 4.00 GiB total capacity; 2.44

    调试手写数字识别代码时出现的问题,将cpu的代码改用gpu训练时虽然可以训练,详见上一条博客(Mnist手写数字识别cpu训练与gpu训练),但是会出现Error.查找资料后以下是解决过程. 先说结论 ...

  8. CUDA out of memory. Tried to allocate 392.00 MiB (GPU 0; 10.76 GiB total capacity; 652.77 MiB alread

    在使用Pytorch中,出现CUDA out of memory. Tried to allocate 392.00 MiB (GPU 0; 10.76 GiB total capacity; 652 ...

  9. 已解决yolov5报错RuntimeError: CUDA out of memory. Tried to allocate 14.00 MiB

    问题 RuntimeError: CUDA out of memory. Tried to allocate 14.00 MiB (GPU 0; 4.00 GiB total capacity; 2. ...

最新文章

  1. 蓝桥杯练习系统习题-算法训练3
  2. ORA-20000 exec dbms_space 错误
  3. 阿里雷卷:RSocket从入门到落地,RSocket让AJP换发青春
  4. 每日一笑 | 男朋友整天沉迷游戏怎么办...?
  5. 服务器文件每天备份重新命名,定时备份服务器文件至本地电脑
  6. 每日一题(49)—— 有符号数与无符号数
  7. edge浏览器扩展插件中心10月发布 可直接安装Chrome扩展
  8. html5设置data,HTML5自定义data属性
  9. opencv qt5安装linux,Ubuntu OpenCV安装和设置(Qt5吗?)
  10. 上计算机绘图的心得,计算机绘图学习心得体会.doc
  11. mod sim tcp配置_ModSim32和ModScan32两种Modbus调试工具使用说明
  12. Linkedin领英如何添加或更改账号的邮箱地址的方法和细节,让我们更高效的运用领英
  13. plsql破解的办法
  14. 输出数组元素(c语言)
  15. 单片机程序运行在哪里
  16. 10年后,程序员的薪资还会这么高么?
  17. 数据结构-单链表基本操作带图完整详解
  18. 20220509数据结构绿书读书笔记
  19. C++求1-20的阶乘之和
  20. 阿里开源支持10万亿模型的自研分布式训练框架EPL

热门文章

  1. html炫酷弹幕特效,jQuery文字弹幕特效
  2. AcWing之从尾到头打印链表
  3. 一份北大信科内部流传的 “CS 自救指南”
  4. Intel PAUSE指令变化影响到MySQL的性能,该如何解决?
  5. 论文浅尝 - ICLR2020 | 通过神经逻辑归纳学习有效地解释
  6. 论文浅尝 | 重新实验评估知识图谱补全方法
  7. python 异常处理相关说明
  8. MySQL-Front的安装简介
  9. 五十个小技巧提高PHP执行效率
  10. 在POM 4中,dependency中还引入了scope可以使用5个值