-
Notifications
You must be signed in to change notification settings - Fork 977
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from EleutherAI/deeperspeed_and_wandb
Add wandb and deeperspeed
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
Helper script to enable wandb with deepspeed. Drop in replacement for `deepspeed` command. | ||
i.e. `$ deepy.py --hosts ....` == `$ deepspeed --hosts ....` | ||
""" | ||
|
||
import shortuuid | ||
import sys | ||
import os | ||
import deepspeed | ||
from deepspeed.launcher.runner import main | ||
import requests | ||
|
||
def get_wandb_api_key(): | ||
""" Get Weights and Biases API key from ENV or .netrc file. Otherwise return None """ | ||
if 'WANDB_API_KEY' in os.environ: | ||
return os.environ['WANDB_API_KEY'] | ||
|
||
wandb_token = requests.utils.get_netrc_auth('https://api.wandb.ai') | ||
|
||
if wandb_token is not None: | ||
return wandb_token[1] | ||
|
||
# Generate unique run group name | ||
wandb_group = shortuuid.uuid() | ||
sys.argv.extend(['--group_name', wandb_group]) | ||
|
||
# Extract wandb API key and inject into worker environments | ||
wandb_token = get_wandb_api_key() | ||
if wandb_token is not None: | ||
deepspeed.launcher.runner.EXPORT_ENVS.append('WANDB_API_KEY') | ||
os.environ['WANDB_API_KEY'] = wandb_token | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters