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

Notebook_launcher: Importing libraries initializes CUDA #4015

Open
NHomer-Edi opened this issue Mar 11, 2024 · 0 comments
Open

Notebook_launcher: Importing libraries initializes CUDA #4015

NHomer-Edi opened this issue Mar 11, 2024 · 0 comments

Comments

@NHomer-Edi
Copy link

NHomer-Edi commented Mar 11, 2024

After importing the libraries, CUDA is initialized, which means that running notebook_launcher results in a ValueError.

print(f"{torch.cuda.is_initialized()}")

from fastai.distributed import *
from fastai.vision.all import *
from fastai.vision.models.xresnet import *
from accelerate import notebook_launcher
from accelerate.utils import write_basic_config

print(f"{torch.cuda.is_initialized()}")

Prints

False
True

Which results in the following error, when running notebook_launcher():

ValueError: To launch a multi-GPU training from your notebook, you need to avoid running any instruction using torch.cuda in any cell. Restart your notebook and make sure no cells use any CUDA function.

Documentation (https://docs.fast.ai/tutorial.distributed.html) could be made clearer to explain how/where to import libraries to avoid throwing this error.

@NHomer-Edi NHomer-Edi changed the title Importing libraries initializes CUDA Notebook_launcher: Importing libraries initializes CUDA Mar 11, 2024
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