HybridNets icon indicating copy to clipboard operation
HybridNets copied to clipboard

Training issue on Multiple Gpu

Open DerrickXuNu opened this issue 2 years ago • 3 comments

Dear authors,

First of all, thanks for your great work and the efforts to opensource this project! I met some issues while training the model. I am able to train on single GPU, but when I give --num_gpus 2 to train.py, it throws me this error:

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor

Do you have any idea how to fix this? Thanks!

DerrickXuNu avatar Feb 20 '23 15:02 DerrickXuNu

Same error

yaoshanliang avatar Feb 25 '23 13:02 yaoshanliang

I'm also working on reproducing the training step according to the author's manual. I tried to revise the issue of train.py last week, so not sure my fix would resolve your issue. What I've changed is:

# original
    if opt.num_gpus > 0:
        model = model.cuda()
# revised
    if opt.num_gpus > 0:
        device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        _model = model.cuda()
        model = nn.DataParallel(_model).to(device)

Hope it helps you.

BTW, leveraging multi gpus with train.py script wasn't working for me since DDP functions are not included in the script. So in my case, I'm trying with train_ddp.py for training with multi gpus, but heading various issues as well.

ejhung avatar Mar 01 '23 05:03 ejhung

I'm also working on reproducing the training step according to the author's manual. I tried to revise the issue of train.py last week, so not sure my fix would resolve your issue. What I've changed is:

# original
    if opt.num_gpus > 0:
        model = model.cuda()
# revised
    if opt.num_gpus > 0:
        device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        _model = model.cuda()
        model = nn.DataParallel(_model).to(device)

Hope it helps you.

BTW, leveraging multi gpus with train.py script wasn't working for me since DDP functions are not included in the script. So in my case, I'm trying with train_ddp.py for training with multi gpus, but heading various issues as well.

Hello, I train the model with train_ddp.py for multi gpus, I meet some issues like https://github.com/datvuthanh/HybridNets/issues/90

happyday-lkj avatar May 25 '23 07:05 happyday-lkj