{ "cells": [ { "cell_type": "raw", "id": "dee626a4-0dc1-4bd2-ab45-808fc640f1ea", "metadata": {}, "source": [ "---\n", "title: Launch Experiments with wandb.init\n", "description: Call wandb.init() at the top of your script to start a new run\n", "---" ] }, { "cell_type": "markdown", "id": "9de3eb4c-66e8-490b-910b-cf717cd45ffb", "metadata": {}, "source": [ "> Call wandb.init() at the top of your script to start a new run" ] }, { "cell_type": "markdown", "id": "ce76cad4-9805-4361-afb0-53475e5d4623", "metadata": {}, "source": [ "Call wandb.init() once at the beginning of your script to initialize a new job. This creates a new run in W&B and launches a background process to sync data.\n", "\n", "- On-Prem: If you need a private cloud or local instance of W&B, see our Self Hosted offerings.\n", "- Automated Environments: Most of these settings can also be controlled via Environment Variables. This is often useful when you're running jobs on a cluster.\n", "\n", "## Reference Documentation\n", "\n", "View the reference docs for this function, generated from the wandb Python library." ] }, { "cell_type": "code", "execution_count": null, "id": "3d2dfb25-b4f9-4c15-9e7d-6eb8eb196769", "metadata": {}, "outputs": [], "source": [ "#|hide\n", "import wandb" ] }, { "cell_type": "markdown", "id": "c48501d6-9de2-4888-98b0-768e096da124", "metadata": {}, "source": [ "## Common Questions\n", "\n", "### How do I launch multiple runs from one script?\n", "\n", "If you're trying to start multiple runs from one script, add two things to your code:\n", "\n", "1. run = wandb.init(reinit=True): Use this setting to allow reinitializing runs\n", "2. run.finish(): Use this at the end of your run to finish logging for that run" ] }, { "cell_type": "code", "execution_count": null, "id": "504232a8-c455-438c-9b57-d7dcb051535d", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mhamelsmu\u001b[0m (\u001b[33mgithub-wandb\u001b[0m). Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n" ] }, { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_091814-34hsdgyi" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run wobbly-paper-38 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.000 MB of 0.000 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "

Run history:


metric▁▁▂▂▂▂▃▃▃▄▄▄▅▅▅▅▆▆▆▇▇▇▇██

Run summary:


metric24

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced wobbly-paper-38: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/34hsdgyi
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_091814-34hsdgyi/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_091840-hiugxi6j" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run rural-dragon-39 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.000 MB of 0.000 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "

Run history:


metric▁▁▂▂▂▂▃▃▃▄▄▄▅▅▅▅▆▆▆▇▇▇▇██

Run summary:


metric25

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced rural-dragon-39: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/hiugxi6j
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_091840-hiugxi6j/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#|output: false\n", "#|eval: false\n", "import wandb\n", "for x in range(2):\n", " run = wandb.init(reinit=True)\n", " for y in range (25):\n", " wandb.log({\"metric\": x+y})\n", " run.finish()" ] }, { "cell_type": "markdown", "id": "1c0c16c8-0a2d-4231-b1d1-1c0cd8e703f3", "metadata": {}, "source": [ "Alternatively you can use a python context manager which will automatically finish logging:" ] }, { "cell_type": "code", "execution_count": null, "id": "918d34bf-3fca-4eb9-b9e5-c14c80448689", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_091906-1pwi8bd5" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run autumn-dew-40 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.000 MB of 0.000 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "

Run history:


metric▁▁▂▂▂▂▃▃▃▄▄▄▅▅▅▅▆▆▆▇▇▇▇██

Run summary:


metric24

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced autumn-dew-40: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/1pwi8bd5
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_091906-1pwi8bd5/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_091931-2wterg8o" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run valiant-cherry-41 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.000 MB of 0.000 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "

Run history:


metric▁▁▂▂▂▂▃▃▃▄▄▄▅▅▅▅▆▆▆▇▇▇▇██

Run summary:


metric25

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced valiant-cherry-41: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/2wterg8o
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_091931-2wterg8o/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#|output: false\n", "#|eval: false\n", "import wandb\n", "for x in range(2):\n", " run = wandb.init(reinit=True)\n", " with run:\n", " for y in range(25):\n", " run.log({\"metric\": x+y})" ] }, { "cell_type": "markdown", "id": "14073b0d-8cb4-4d03-a03a-8c57e6679b25", "metadata": {}, "source": [ "# InitStartError: Error communicating with wandb process\n", "\n", "This error indicates that the library is having difficulty launching the process which synchronizes data to the server.\n", "The following workarounds can help resolve the issue in certain environments:" ] }, { "cell_type": "markdown", "id": "859ce7c5-f338-45b1-b47c-6b7ad0fa7d01", "metadata": {}, "source": [ "::: {.panel-tabset}\n", "\n", "### Linux / OS X" ] }, { "cell_type": "code", "execution_count": null, "id": "7ef685a9-2e65-4f72-a3be-ceea167d6a87", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_091958-yvnab4te" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run exalted-field-42 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#|eval: false\n", "#|output: false\n", "\n", "wandb.init(settings=wandb.Settings(start_method=\"fork\"))" ] }, { "cell_type": "markdown", "id": "56147d21-b098-48bf-a38b-c4981d162890", "metadata": {}, "source": [ "### Google Colab\n", "\n", "For versions prior to 0.13.0 we suggest using:" ] }, { "cell_type": "code", "execution_count": null, "id": "1d0ba894-2152-4731-8e6b-461c39168131", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Finishing last run (ID:yvnab4te) before initializing another..." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.000 MB of 0.000 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced exalted-field-42: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/yvnab4te
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_091958-yvnab4te/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Successfully finished last run (ID:yvnab4te). Initializing new run:
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_092005-wfzidwwi" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run dutiful-dew-43 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#|eval: false\n", "#|output: false\n", "wandb.init(settings=wandb.Settings(start_method=\"thread\"))" ] }, { "cell_type": "markdown", "id": "67ffe916-7d5e-4e4f-90d6-934c163ad3d2", "metadata": {}, "source": [ ":::\n", "\n", "## How do I programmatically access the human-readable run name?\n", "\n", "It's available as the .name attribute of a [wandb.Run](https://docs.wandb.ai/ref/python/run)." ] }, { "cell_type": "code", "execution_count": null, "id": "f8735522-a71a-445f-b0dc-bab131990e62", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Finishing last run (ID:ir6w5g66) before initializing another..." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.001 MB of 0.001 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced smart-cloud-45: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/ir6w5g66
Synced 6 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_092102-ir6w5g66/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Successfully finished last run (ID:ir6w5g66). Initializing new run:
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_092935-3udt6k6p" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run sweet-sun-46 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#|output: false\n", "import wandb\n", "wandb.init();\n", "run_name = wandb.run.name" ] }, { "cell_type": "code", "execution_count": null, "id": "076fc658-cc99-45e9-aba0-2d6be8705598", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "sweet-sun-46\n" ] } ], "source": [ "print(run_name)" ] }, { "cell_type": "markdown", "id": "a83781d7-b80f-4dc0-8e15-3641f40b374b", "metadata": {}, "source": [ "## Can I just set the run name to the run ID?\n", "\n", "If you'd like to overwrite the run name (like snowy-owl-10) with the run ID (like qvlp96vk) you can use this snippet:" ] }, { "cell_type": "code", "execution_count": null, "id": "0f922c46-3d6f-43aa-bd53-db5bdffb49f4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Finishing last run (ID:1bbzqokp) before initializing another..." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Waiting for W&B process to finish... (success)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(Label(value='0.000 MB of 0.000 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=1.0, max…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Synced mild-tree-47: https://wandb.ai/github-wandb/wandb-nbdev-docs/runs/1bbzqokp
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20220819_092952-1bbzqokp/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Successfully finished last run (ID:1bbzqokp). Initializing new run:
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.13.1" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /Users/hamel/wandb-nbdev/docs/wandb/run-20220819_093015-16ej8478" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run usual-star-48 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "True" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#| output: false\n", "import wandb\n", "wandb.init();\n", "wandb.run.name = wandb.run.id\n", "wandb.run.save()" ] }, { "cell_type": "code", "execution_count": null, "id": "b0d9a1a6-b8e3-40ca-bd0c-db563794e571", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "16ej8478\n" ] } ], "source": [ "print(wandb.run.name)" ] }, { "cell_type": "markdown", "id": "2296f054-a948-41e8-94e7-b42c4ad9170e", "metadata": {}, "source": [ "## Is it possible to save metrics offline and sync them to W&B later?\n", "\n", "By default, wandb.init starts a process that syncs metrics in real time to our cloud hosted app. If your machine is offline, you don't have internet access, or you just want to hold off on the upload, here's how to run wandb in offline mode and sync later.\n", "You'll need to set two environment variables.\n", "\n", "1. `WANDB_API_KEY=$KEY`, where $KEY is the API Key from your settings page\n", "2. `WANDB_MODE=\"offline\"`\n", "\n", "And here's a sample of what this would look like in your script:" ] }, { "cell_type": "code", "execution_count": null, "id": "89801527-1184-4a3a-861f-92d272c74d52", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[0;32mimport\u001b[0m \u001b[0mwandb\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0menviron\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"WANDB_MODE\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"offline\"\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0mconfig\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0;34m\"dataset\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m\"CIFAR10\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0;34m\"machine\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m\"offline cluster\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0;34m\"model\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m\"CNN\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0;34m\"learning_rate\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m0.01\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0;34m\"batch_size\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m128\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0mwandb\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mproject\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"offline-demo\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m100\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mwandb\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m\"accuracy\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#|echo: false\n", "%pycat offline.py" ] }, { "cell_type": "code", "execution_count": null, "id": "0af4f0c7-a159-4159-bfb1-e45e88d3921a", "metadata": {}, "outputs": [], "source": [ "#|hide\n", "!rm -rf wandb" ] }, { "cell_type": "markdown", "id": "3bfaabc5-7546-439b-aa2d-51e563eb342e", "metadata": {}, "source": [ "Here's a sample terminal output:\n" ] }, { "cell_type": "code", "execution_count": null, "id": "df5a9e55-48d0-4c75-96b7-db40e218ddf3", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "wandb: Tracking run with wandb version 0.13.1\n", "wandb: W&B syncing is set to `offline` in this directory. \n", "wandb: Run `wandb online` or set WANDB_MODE=online to enable cloud syncing.\n", "wandb: Waiting for W&B process to finish... (success).\n", "wandb: \n", "wandb: \n", "wandb: Run history:\n", "wandb: accuracy ▁▁▁▁▂▂▂▂▂▃▃▃▃▃▃▄▄▄▄▄▅▅▅▅▅▅▆▆▆▆▆▇▇▇▇▇▇███\n", "wandb: \n", "wandb: Run summary:\n", "wandb: accuracy 99\n", "wandb: \n", "wandb: You can sync this run to the cloud by running:\n", "wandb: wandb sync /Users/hamel/wandb-nbdev/docs/wandb/offline-run-20220819_111619-1kj5i84c\n", "wandb: Find logs at: ./wandb/offline-run-20220819_111619-1kj5i84c/logs\n" ] } ], "source": [ "%%bash\n", "\n", "python offline.py" ] }, { "cell_type": "markdown", "id": "7c51f3f1-bf9e-4701-9155-3fc8feb3179a", "metadata": {}, "source": [ "And once you're ready, just run a sync command to send that folder to the cloud with the following command:\n", "\n", "`wandb sync wandb/dryrun-folder-name`" ] }, { "cell_type": "code", "execution_count": null, "id": "3b66b544-9bdc-4577-9c7d-3a786d53aef0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Find logs at: /Users/hamel/wandb-nbdev/docs/wandb/debug-cli.hamel.log\n", "Syncing: https://wandb.ai/github-wandb/offline-demo/runs/1kj5i84c ... done.\n" ] } ], "source": [ "#|eval: false\n", "!wandb sync wandb/latest-run" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }