How to use Multiple GPUs?


(Shiv Gowda) #84

The above worked for me to use 2 GPUs on my desktop for 2 separate processes(devices 0 and 1). -Thanks.


(Hossain) #85

@hwasiti, when I am running
learn.model = torch.nn.DataParallel(learn.model, device_ids=[0, 1])
I get the following error

AttributeError: can’t set attribute

Can you please help?

Thanks in advance.


(Haider Alwasiti) #86

Can you share a snapshot of the code with the errors and few lines before this error? Where did you put this line exactly?

I have shared in my previous posts my github pet’s notebook. Can you try one of them and see whether it works for you?


(Hossain) #87

Thanks again. Can you please send me the link to your notebook again?

screenshot of my code is attached.


(Haider Alwasiti) #88

Look in cell number 32:

I have noticed that you have did this import:
import torch.nn as nn

Can you try this instead:
learn.model = nn.DataParallel(learn.model, device_ids=[0, 1])


(Hossain) #89

Thanks Haider. Afraid to say i am having same error. !


(Haider Alwasiti) #90

I am using fastai v1 and yours seems the older v0.7. I suspect that is the reason. Tried to check your code, but sorry to say I could not find anything wrong with your code. Maybe others with more knowledge can chime in for a solution.


(Hossain) #91

Thanks, Haider. I updated fastai to v1.0.0 but still get the same error. Yes, will be waiting for other’s reply.

when I am running
learn.model = torch.nn.DataParallel(learn.model, device_ids=[0, 1])
or
learn.model = nn.DataParallel(learn.model, device_ids=[0, 1])
I get the following error

AttributeError: can’t set attribute

Imported packages:

from fastai.imports import *
from fastai.torch_imports import *
from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *

Can you please help?

Thanks in advance.


(Haider Alwasiti) #92

Can you share your code? I will try to run it on my machine and see.

‘ConvLearner’ is no longer used in fastai v1. What is your exact version of fastai?

Can you please also try my notebook, which I can confirm it works fine.
Run Cell 1 to 11.
Then jump to cell 30 and run from cell 30 to 34.


(Hossain) #93

Please find my code from here

I am going to test yours.


(Haider Alwasiti) #94

I tried to run your code and it does not work on fastai v1.39

Please update your fastai to the latest version and try my code. Most likely then it will work

Your notebook seems from the older fastai and it is not compatible with fastai v1.39

conda install fastai -c fastai


(Hossain) #95

Hi Haider,
Thanks for your advice. Happy to let you know that after upgrading fastai to v1, coding is working fine.


(Armand Gerstenberger) #96

Running cifar example I seem to be stable at 68C (gpu: 1080) with driver 418.39. Note: computer near window in winter