admin管理员组文章数量:1611528
CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 6.00 GiB total capacity; 4.54 GiB already allocated; 14.94 MiB free; 4.64 GiB reserved in total by PyTorch)
分析问题 CUDA内存超载
解决尝试一:GPU未被调用,
[881]内存不足RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total cap..._cuda out of memory. tried to allocate 4.88 gib (gp_周小董的博客-CSDN博客
实际上有那么一瞬间调用了。
按照上面的方法调用,还是这样。
我感觉主要问题是很多内存没有被调用,
上面的报错翻译是CUDA内存不足。尝试分配16.00 MiB(GPU 0;总容量6.00 GiB;4.54已分配的GiB;14.94无MiB;PyTorch共预留4.64个GiB)
我想到很多内存没有调用
于是查询了显存充足,但是却出现CUDA error:out of memory错误
方法二:https://wwwblogs/jisongxie/p/10276742.html
先输入代码
import os
import torch
print(torch.cuda.is_available())#是否有可用的gpu
print(torch.cuda.device_count())#有几个可用的gpu
os.environ["CUDA_VISIBLE_DEVICES"] = "0"#声明gpu
dev=torch.device('cuda:0')#调用哪个gpu
a=torch.rand(100,100).to(dev)
结果:
True
1
但是我明明有两个gpu,为什么只说有一个。
我有两个推断:
1.cuda默认选择第一个gpu。
2.cuda只能匹配合适的gpu,也就是我的第二个gpu。
torch.cuda的命令查询 torch.cuda命令查询 - 简书
import os
import torch
print(torch.cuda.is_available())#是否有可用的gpu
print(torch.cuda.device_count())#有几个可用的gpu
print(torch.cuda.current_device())#可用gpu编号
print( torch.cuda.get_device_capability(device=None), torch.cuda.get_device_name(device=None))#可用gpu内存大小,可用gpu的名字
os.environ["CUDA_VISIBLE_DEVICES"] = "0"#声明gpu
dev=torch.device('cuda:0')#调用哪个gpu
a=torch.rand(100,100).to(dev)
输出
True
1
0
(6, 1) GeForce GTX 1060
答案是推断2
解决方法和思路
torch代码运行时显存溢出问题 - 简书
本文标签: MIBallocateCUDAMemoryTotal
版权声明:本文标题:CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 6.00 GiB total capacity;总结(1) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728620776a1166330.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论