RuntimeError: CUDA out of memory

1.查看是否其他程序占用显存

遇到此类错误后,对于py格式的文件来说,程序会进行终止,也就是当前程序占用的显存将会被释放。此时可用 watch -n 1 nvidia-smi 命令查看当前显存的使用情况。如果此时显存依然有比较大的占用,说明存在其他程序占用显存,使用kill命令结束不必要的程序即可。

2.查看pytorch和cuda是否匹配

使用方法torch.cuda.is_available(),确认pytorch和cuda是否匹配,如果返回False,需要调整一下cuda或torch的版本,重新部署一下环境。

3.cuda.empty_cache()方法

如果使用的是jupyter notebook,遇到错误时显存并不会被释放,笔者在网上查到的方法是可用torch.cuda.empty_cache()删除一些不需要的变量,并且测试代码之前使用with torch.no_grad()。但是我尝试过后发现torch.cuda.empty_cache()貌似并不能解决notebook中的显存占用。查询官网API,官方的说明是:

Releases all unoccupied cached memory currently held by the caching allocator

https://pytorch.org/docs/stable/cuda.html?highlight=empty_cache#torch.cuda.empty_cache

pytorch遇见RuntimeError: CUDA out of memory的解决相关推荐

  1. pytorch出现RuntimeError: CUDA out of memory的问题解决方法

    pytorch出现RuntimeError: CUDA out of memory解决方法 将batch-size设置小些试试,如果不行,继续第二步 多线程num_works设置较小,最差设为0

  2. pytorch出现RuntimeError: CUDA out of memory.

    无论batch-size设置多小也是会出现这个问题的,我的原因是我将pytorch升级到了1.0.1,然后出现了这个问题 RuntimeError: CUDA out of memory. Tried ...

  3. RuntimeError: CUDA out of memory 已解决

    先说下我的电脑环境:win10 3060ti torch10 python3.8 cuda11.3 RuntimeError: CUDA out of memory. Tried to allocat ...

  4. python pytorch爆显存,内存溢出问题解决方法(总结)RuntimeError: CUDA out of memory.

    问题描述 在运行python程序时,随运行时间增长,内存疯狂增加,直至运行内存爆满,出现以下错误: RuntimeError: CUDA out of memory. 解决方法: 1.在模型验证和测试 ...

  5. 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 ...

  6. 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 ...

  7. 显存不足问题(OOM、RuntimeError: CUDA out of memory)

    显存不足问题(OOM.RuntimeError: CUDA out of memory). 记录一次pytorch yolov3爆显存(windows使用任务管理器查看显存为4G). 2G显存:SSD ...

  8. RuntimeError: CUDA out of memory

    报错内容: RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total capacity; ...

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

最新文章

  1. Jboss解决只能通过localhost访问而不能使用IP访问项目的问题
  2. CCS新建BIOS工程的设置问题
  3. Spring2 Hibernate3 Junit 应用示例1
  4. iftop 流量监控
  5. 条件编译用法(#ifndef #define #endif#else)
  6. java对象头_我的并发编程(二):java对象头以及synchronized升级过程
  7. 好久不更新这个博客了。
  8. 路由器信号总是无法与手机连接服务器,手机无法搜到路由器信号怎么办? | 192路由网...
  9. Item 22. 模板方法与曲线救国(Template Method)
  10. C# 图片exif信息
  11. 【视觉SLAM14讲】【汇总】
  12. 共轭梯度法python实现
  13. 最强代码审查工具报告
  14. SQL实现对销售表现重要指标的计算,对用户特征分层看销售贡献,并统计消费的二八法则
  15. 改变销售预测准确率的4个最佳实践!
  16. 现身说法,如何给上司送礼物
  17. 2021-10-01
  18. 华为鸿蒙os的内核是Linux,谈华为鸿蒙内核和操作系统
  19. 3D打印机的故障检测及排除
  20. attend,join,participate,take part in

热门文章

  1. MongoDB学习笔记~官方驱动嵌套数组对象的更新
  2. 谈python函数的参数处理
  3. 考考你:输入数字,判定空格和回车
  4. 祝大家春节快乐身体健康
  5. [Skr-Shop]购物车之架构设计
  6. 再见 FTP/SFTP,是时候拥抱下一代文件传输利器 Croc 了!
  7. 细说Redis分布式锁
  8. 大厂程序员和北京户口教师女友买房分歧,要求分配产权怕离婚扯皮
  9. 二胖写参数校验的坎坷之路
  10. 分布式与集群是一回事儿么?别让这么简单的问题难住你!