Experiment Tracking with Weights & Biases

Introduction

In this tutorial, we show how to set up experiment tracking via Weights & Biases on Neuro Platform using Neuro Project Template.

Creating a Neuro Project

First, make sure that you have the Neu.ro CLI client and cookiecutter installed and configured:
1
$ pip install pipx
2
$ pipx install neuro-all cookiecutter
3
$ neuro login
Copied!
Then, initialize an empty project:
1
$ cookiecutter gh:neuro-inc/cookiecutter-neuro-project --checkout release
Copied!

Connecting Weights & Biases

Now, connect your project with Weights & Biases:
  1. 2.
    Find your API key (it is also called a token) on W&B’s settings page(section “API keys”). It should be a sequence like cf23df2207d99a74fbe169e3eba035e633b65d94.
  2. 3.
    Save your API key (token) to a file in your local home directory ~ and protect it by setting appropriate permissions to make W&B available on Neu.ro platform:
1
export WANDB_SECRET_FILE=wandb-token.txt
2
echo "cf23df2207d99a74fbe169e3eba035e633b65d94" > ~/$WANDB_SECRET_FILE
3
chmod 600 ~/$WANDB_SECRET_FILE
Copied!
After that, create a Neu.ro secret:
1
$ neuro secret add wandb-token @~/$WANDB_SECRET_FILE
Copied!
Open .neuro/live.yaml, find remote_debug section within jobs in it and add the following lines at the end of remote_debug:
1
jobs:
2
remote_debug:
3
...
4
args:
5
...
6
additional_env_vars: '{"WANDB_API_KEY": "secret:wandb-token"}'
Copied!
Now, you can start using W&B API in your code.

Testing

Change default preset to cpu-small in .neuro/live.yamlto avoid consuming GPU for this test:
1
defaults:
2
preset: cpu-small
Copied!
Run a development job and connect to the job's shell:
1
$ neuro-flow run remote_debug
Copied!
In your job's shell, try to use wandb:
1
wandb status
Copied!
You should see something like the following:
1
Logged in? True
2
Current Settings
3
{
4
"anonymous": "false",
5
"base_url": "https://api.wandb.ai",
6
"entity": null,
7
"git_remote": "origin",
8
"ignore_globs": [],
9
"project": null,
10
"run": "latest",
11
"section": "default"
12
}
Copied!
You can also find more examples on how to use experiment tracking and other features of W&B in the official W&B's examples repo.
To close the remote terminal session, press ^D or type exit.
Please don't forget to terminate your job when you don't need it anymore:
1
$ neuro-flow kill remote_debug
Copied!