【发布时间】:2019-07-13 05:59:16
【问题描述】:
我正在尝试从基于 pytorch 框架的 unet3D 进行模型预测。我正在使用多 GPU
import torch
import os
import torch.nn as nn
os.environ['CUDA_DEVICE_ORDER']='PCI_BUS_ID'
os.environ['CUDA_VISIBLE_DEVICES']='0,1,2'
model = unet3d()
model = nn.DataParallel(model)
model = model.to('cuda')
result = model.forward(torch.tensor(input).to('cuda').float())
但该模型仍然只使用 1 个 GPU(第一个),并且出现内存错误。
CUDA out of memory. Tried to allocate 64.00 MiB (GPU 0; 11.00 GiB total capacity; 8.43 GiB already allocated; 52.21 MiB free; 5.17 MiB cached)
在推理阶段我应该如何使用多 GPU?我上面的脚本有什么错误?
【问题讨论】: