Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
faf4r opened this issue Jul 6, 2024 · 0 comments
Open

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

faf4r opened this issue Jul 6, 2024 · 0 comments

Comments

@faf4r
Copy link

faf4r commented Jul 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant