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.94 GiB already allocated; 169.19 MiB free; 1.96 GiB reserved in total by PyTorch)
我们可以看见内存是还有很多的,但是在运行程序的时候还是会出现
CUDA out of memory
解决方法
一、正确调用指定GPU
我们在调用GPU时,并没有使用到指定“内存”,使用的是显存,这样就会导致我们在跑程序的时出现内存溢出
将下面的代码添加到代码中
os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID'
os.environ['CUDA_VISIBLE_DEVICES'] = '1'
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")#判断CUDA是否能使用,不可以就使用CPU
二、杀死进程
这里我们杀死进程要注意的是,杀死进程是否可以pass掉,不然会导致你有的程序终止掉,切记切记
kill id号
eg:
三、减小batchSize
每次读取的数据减小,或者说减小每次训练的数据大小
四、关机重启
要是前面三个方法还是没有解决问题,关机重新启动试一试。
还是不行我也表示~~~~~~sorry
希望这篇文章对你有用!
谢谢点赞评论!
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 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. ...
- 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 ...
- 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 ...
- 解决: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. ...
- [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的当前信息状态(图源网络 不想 ...
- 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.查找资料后以下是解决过程. 先说结论 ...
- 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 ...
- 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 ...
- CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 6.00 GiB total capacity;总结(1)
CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 6.00 GiB total capacity; 4.54 GiB already al ...
最新文章
- 6.微信小程序的如何使用全局属性
- Asp.net单点登录解决方案
- Python3 中hasattr()、getattr()、setattr()、delattr()函数及示例代码数
- 最简单的c#Remoting编程
- 实训七(项目准备与创建)
- JSONP 初步学习--但是还是有疑问
- 一些开发点滴[java]
- python门牌制作
- python缓存memoryerror_Python安装会抛出大量MemoryError()的
- 含泪整理最优质平板Rhino犀牛模型素材,你想要的这里都有
- RabbitMQ安装问题
- 修改hexo的主题nexT中的Pisces主题宽度
- ChucK初步(8)
- C语言解析FLM(ELF)格式文件
- 上海浦东机场的wifi使用攻略
- linux在磁盘容量扩容后扩容文件系统
- WebRTC系列-Qos系列之接收NACK
- Conflux v2.2.0 网络 Hardfork 升级公告
- word转换成excel导致身份证错乱的解决办法
- 全球市场动荡持续,澳元和液化天然气(LNG)价格跌至近11年最低水平