TreB1eN / InsightFace_Pytorch

Pytorch0.4.1 codes for InsightFace
MIT License
1.73k stars 423 forks source link

how to train on multi-GPUs #32

Closed Royzon closed 5 years ago

Royzon commented 5 years ago

I want to train with multiple GPUs, where should I change?

ruiming46zrm commented 5 years ago

@Roython Use dataParalle , put codes in Learner.py ---> train() like this:

def train(self,conf,epochs):
        self.model.train()       
        conf.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        self.model = nn.DataParallel(self.model,device_ids=[0,1,2,3])
        self.model.to(conf.device)
        running_loss = 0. 
Royzon commented 5 years ago

Thank you very much, it works.