pytorch遇见RuntimeError: CUDA out of memory的解决
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的解决相关推荐
- pytorch出现RuntimeError: CUDA out of memory的问题解决方法
pytorch出现RuntimeError: CUDA out of memory解决方法 将batch-size设置小些试试,如果不行,继续第二步 多线程num_works设置较小,最差设为0
- pytorch出现RuntimeError: CUDA out of memory.
无论batch-size设置多小也是会出现这个问题的,我的原因是我将pytorch升级到了1.0.1,然后出现了这个问题 RuntimeError: CUDA out of memory. Tried ...
- RuntimeError: CUDA out of memory 已解决
先说下我的电脑环境:win10 3060ti torch10 python3.8 cuda11.3 RuntimeError: CUDA out of memory. Tried to allocat ...
- 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; ...
最新文章
- Jboss解决只能通过localhost访问而不能使用IP访问项目的问题
- CCS新建BIOS工程的设置问题
- Spring2 Hibernate3 Junit 应用示例1
- iftop 流量监控
- 条件编译用法(#ifndef #define #endif#else)
- java对象头_我的并发编程(二):java对象头以及synchronized升级过程
- 好久不更新这个博客了。
- 路由器信号总是无法与手机连接服务器,手机无法搜到路由器信号怎么办? | 192路由网...
- Item 22. 模板方法与曲线救国(Template Method)
- C# 图片exif信息
- 【视觉SLAM14讲】【汇总】
- 共轭梯度法python实现
- 最强代码审查工具报告
- SQL实现对销售表现重要指标的计算,对用户特征分层看销售贡献,并统计消费的二八法则
- 改变销售预测准确率的4个最佳实践!
- 现身说法,如何给上司送礼物
- 2021-10-01
- 华为鸿蒙os的内核是Linux,谈华为鸿蒙内核和操作系统
- 3D打印机的故障检测及排除
- attend,join,participate,take part in