王康年
王康年

Reputation: 11

Pytorch 3-GPUs, just can only use 2 of them to train

I have three 1080TI, but when train I can only use 2 of them..

Code:

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.cuda()

criterion = nn.CrossEntropyLoss().cuda()
optimizer_conv = optim.SGD(model.classifier.parameters(), lr=0.0001, momentum=0.9)
exp_lr_scheduler = lr_scheduler.StepLR(optimizer_conv, step_size=7, gamma=0.1)

train part:

outputs = nn.parallel.data_parallel(model,inputs,device_ids=[0,1,2])

With "CUDA_VISIBLE_DEVICES="1,2,3" python train.py" Got this:

| 22%   35C    P8    10W / 250W |     12MiB / 11178MiB |      0%  
| 43%   59C    P2    92W / 250W |   1169MiB / 11178MiB |     49%   
| 44%   60C    P2    91W / 250W |   1045MiB / 11175MiB |     54% 

With "CUDA_VISIBLE_DEVICES="0,1,2" python train.py" Got this:

| 21%   38C    P2    95W / 250W |   1169MiB / 11178MiB |     78%      Default |  
| 42%   63C    P2    93W / 250W |    777MiB / 11178MiB |     76%      Default |  
| 43%   64C    P0    85W / 250W |    282MiB / 11175MiB |      0%      Default |

Upvotes: 0

Views: 897

Answers (1)

王康年
王康年

Reputation: 11

eeeee.. I found the reason:
my batchsize = 4 when there are three GPUs
so Change batchsize bigger can solve this "weird" problem

Upvotes: 1

Related Questions