Lightning-AI / Lightning-AI/pytorch-lightning

can't fit with ddp_notebook on a Vertex AI Workbench instance (CUDA initialized)

Open
#19,880 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug strategy: ddp
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Bug description

Using this minimal code example:
```
import torch
import lightning as L

print(torch.cuda.is_initialized())
trainer = L.Trainer(
accelerator="auto",
strategy="ddp_notebook",
devices="auto",
max_epochs=1,
# callbacks=callbacks,
log_every_n_steps=1
)
print(torch.cuda.is_initialized())
```

On Google Colab with a T4 attached, both print statements print "False" as expected.

On a Vertex AI Workbench instance with a T4 attached, the second statement prints "True"; merely instantiating the Trainer initializes cuda. This prevents fitting with DDP.

What could be causing this, and is there any way to work around it?

### What version are you seeing the problem on?

v2.2

### How to reproduce the bug

_No response_

### Error messages and logs

```
# Error messages and logs here please
```

### Environment

Current environment

```
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):
```

### More info

_No response_

cc @justusschock @lantiga

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Trainer example in the issue and compare torch.cuda.is_initialized() before and after Trainer construction on Vertex AI Workbench versus Colab. Check the Vertex environment details and DDP notebook initialization path; done means identifying why Trainer initializes CUDA there and documenting a verified workaround or fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.