RuntimeError: CUDA out of memory. Tried to allocate 96.00 MiB
使用多个GPU进行深度学习任务的时候有时会出现明明显卡内存还有空间,但是会提示RuntimeError: CUDA out of memory. Tried to allocate 96.00 MiB的情况。使用nvidia-smi查看显卡使用情况发现,空间足够。参考了一些文章看总结得出可能原因:pytorch与tensorflow如果在同一个GPU上运行会出现冲突,因此选择空闲的GPU即可。具体
·
使用多个GPU进行深度学习任务的时候有时会出现明明显卡内存还有空间,但是会提示RuntimeError: CUDA out of memory. Tried to allocate 96.00 MiB的情况。使用nvidia-smi查看显卡使用情况发现,空间足够。
参考了一些文章看总结得出可能原因:
pytorch与tensorflow如果在同一个GPU上运行会出现冲突,因此选择空闲的GPU即可。
具体设置为使用CUDA_VISIBLE_DEVICES限制一下使用的GPU.
# 使用八块GPU中的2,3,6,7号(从0开始)
os.environ['CUDA_VISIBLE_DEVICES'] = '2,3,6,7'
device = torch.device('cuda')
if torch.cuda.device_count() > 1:
print('Let\'s use', torch.cuda.device_count(), 'GPUs!')
model = nn.DataParallel(model, device_ids=[0,1]) # 设置使用的GPU为0和1号,即上述可用GPU中的2和3号
model.to(device)
参考:
昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链
更多推荐


所有评论(0)