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 Neuro Project

To create a new Neuro project, run:

> neuro project init
> cd <project-slug>
> neuro-flow build myimage

Connecting Weights & Biases

Now, connect your project with Weights & Biases:

  1. 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. 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:

export WANDB_SECRET_FILE=wandb-token.txt
echo "cf23df2207d99a74fbe169e3eba035e633b65d94" > ~/$WANDB_SECRET_FILE
chmod 600 ~/$WANDB_SECRET_FILE

After that, create a Neu.ro secret:

neuro secret add wandb-token @~/$WANDB_SECRET_FILE

Open .neuro/live.yaml, find remote_debug section within jobs in it and add the following lines at the end of remote_debug:

jobs:
remote_debug:
...
args:
...
additional_env_vars: '{"WANDB_API_KEY": "secret:wandb-token"}'

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:

defaults:
preset: cpu-small

Run a development job and connect to the job's shell:

neuro-flow run remote_debug

In your job's shell, try to use wandb:

wandb status

You should see something like the following:

Logged in? True
Current Settings
{
"anonymous": "false",
"base_url": "https://api.wandb.ai",
"entity": null,
"git_remote": "origin",
"ignore_globs": [],
"project": null,
"run": "latest",
"section": "default"
}

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:

neuro-flow kill remote_debug