Skip to content

Experiments: Add note, update script on removing W&B env var#2112

Open
ngrayluna wants to merge 2 commits intomainfrom
experiments_shared_mode
Open

Experiments: Add note, update script on removing W&B env var#2112
ngrayluna wants to merge 2 commits intomainfrom
experiments_shared_mode

Conversation

@ngrayluna
Copy link
Contributor

Description

Customers reported issue running code snippet on local, single machine. This was caused from W&B-specific env vars that were already set.

PR shows how to remove W&B env var (and which one). Also shows how to define run ID as an env var.

Some word smithing was done as well.

Related issues

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

📚 Mintlify Preview Links

🔗 View Full Preview

📝 Changed (1 total)

📄 Pages (1)

File Preview
models/track/log/distributed-training.mdx Distributed Training

🤖 Generated automatically when Mintlify deployment succeeds
📍 Deployment: eb2e66d at 2026-02-05 17:04:38 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

🔗 Link Checker Results

All links are valid!

No broken links were detected.

Checked against: https://wb-21fd5541-experiments-shared-mode.mintlify.app

Comment on lines +178 to +189
```python
import wandb
import os

# Primary node
run = wandb.init( ... )
os.environ['WANDB_RUN_ID'] = run.id

# Worker node
run = wandb.init( ... , id=os.environ['WANDB_RUN_ID'])
```
</Tip>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example feels misleading to me because it looks like those statements run in the same script. I'm not sure this form is practical, since it requires somehow starting up worker nodes from the primary node's script to pass on the generated run ID.

The environment variable WANDB_RUN_ID is read automatically by wandb, and generally users should not read WANDB_ variables or use them for custom purposes. I also wouldn't advise anyone to modify os.environ at runtime, since changes might not be detected.

The essence of the original tip is to (1) generate your own ID and (2) set the WANDB_RUN_ID environment variable however you do it in the framework you're using to orchestrate the nodes. There's no general code sample we can provide as it's highly dependent on the user's setup.

Comment on lines +209 to +221
<Warning>
**Environment variable inheritance**

Worker processes may inherit W&B-related environment variables (such as `WANDB_SERVICE`) from parent processes in distributed environments. This can cause
initialization conflicts.

Clear inherited W&B environment variables (such as `WANDB_SERVICE`) before calling `wandb.init()` on worker nodes to avoid initialization conflicts:

```python
import os
os.environ.pop('WANDB_SERVICE', None)
```
</Warning>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, this one might be necessary in some cases, but that's definitely a bug on our side. Not sure about including this in the docs as it's a super janky thing to ask users to do.

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

Successfully merging this pull request may close these issues.

2 participants