栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

RuntimeError: CUDA out of memory. Tried to allocate 32.00 MiB||查看GPU内存

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

RuntimeError: CUDA out of memory. Tried to allocate 32.00 MiB||查看GPU内存

RuntimeError: CUDA out of memory. Tried to allocate 32.00 MiB (GPU 0; 6.00 GiB total capacity; 4.40 GiB already allocated; 0 bytes free; 4.43 GiB reserved in total by PyTorch)

Traceback (most recent call last):
  File "D:/Papers to read/2022.07/DeamNet-main/DeamNet-main/train.py", line 170, in 
    train(epoch)
  File "D:/Papers to read/2022.07/DeamNet-main/DeamNet-main/train.py", line 73, in train
    prediction = model(input)
................
 File "D:ProgramDataAnaconda3envspython36libsite-packagestorchnnfunctional.py", line 1136, in relu
    result = torch.relu(input)
RuntimeError: CUDA out of memory. Tried to allocate 32.00 MiB (GPU 0; 6.00 GiB total capacity; 4.40 GiB already allocated; 0 bytes free; 4.43 GiB reserved in total by PyTorch)

Process finished with exit code 1
查到的方法

1. 查看电脑GPU内存 在cmd下输入:

nvidia-smi.exe -h

 然后再输入

nvidia-smi.exe -i 0

可以看到电脑的运行内存,

 关于搜到的调用GPU的方法,源代码里有,所以不是这个问题

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1"
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")  #修改:增加此行. 判断CUDA是否能使用,不可以就使用CPU

2. 另一个方法是修改batchsize

batchsize原来是8,改为1,可以运行了

parser.add_argument('--batchSize', type=int, default=1, help='training batch size') 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1018341.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号