Skip to content

it seems that it will never use gpus when use pytorch for training #1192

@faf4r

Description

@faf4r

if the framework is pytorch, it will from donkeycar.parts.pytorch.torch_train import train and use it to train.
in this train function, it has following codes

    if torch.cuda.is_available():
        print('Using CUDA')
        gpus = -1
    else:
        print('Not using CUDA')
        gpus = 0

however, when creating the trainer, it uses cpu flag and never use gpu

    trainer = pl.Trainer(accelerator='cpu', logger=logger,
                         max_epochs=cfg.MAX_EPOCHS, default_root_dir=output_dir)

so I combined them and can use gpus successfully

    if torch.cuda.is_available():
        print('Using CUDA')
        trainer = pl.Trainer(accelerator='gpu', devices=-1, logger=logger,
                         max_epochs=cfg.MAX_EPOCHS, default_root_dir=output_dir)
    else:
        print('Not using CUDA')
        trainer = pl.Trainer(accelerator='cpu', logger=logger,
                         max_epochs=cfg.MAX_EPOCHS, default_root_dir=output_dir)

If it serves no other purpose, I think it's a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions