You can run Weights & Biases completely offline, logging all your experiments and syncing them later when you have a connection.

import wandb

# Configure wandb to run offline
wandb.init(mode="offline")

# Log some data as usual
for i in range(10):
    wandb.log({"metric": i, "loss": 10 - i})

# When you're done, you can optionally call wandb.finish()
# This isn't strictly necessary in offline mode, but good practice.
wandb.finish()

This script will create a wandb directory in your current working folder. Inside, you’ll find a latest.spec file and a files subdirectory. The latest.spec file is a small JSON containing metadata about your run, and the files directory holds all the actual data — logs, media, checkpoints, etc. — serialized into a format ready for upload.

The core problem Weights & Biases solves is making experiment tracking seamless, even when you’re not connected to the internet. Without offline mode, a flaky connection or a restricted network environment would immediately halt your experiment logging. Offline mode acts as a local buffer, ensuring your valuable experiment data is never lost due to connectivity issues. It decouples the act of running an experiment from the act of uploading its results, giving you flexibility.

Here’s how it works under the hood: When wandb.init(mode="offline") is called, the wandb client doesn’t attempt to contact the W&B cloud servers. Instead, it serializes all run metadata and logged data locally. This includes metrics, hyperparameters, system metrics (like GPU utilization), and any media artifacts you’ve logged (images, plots, audio). Everything is written to files within a designated local directory, typically wandb/. The client operates as if it were online, but all its output is redirected to disk.

When you’re ready to sync, you navigate to the directory containing the wandb folder and run:

wandb sync

This command looks for wandb directories that haven’t been synced. It then serializes the local data into a tarball and uploads it to your W&B account. If you want to sync a specific run, you can point wandb sync to the specific run directory within your wandb folder. The wandb sync command is intelligent enough to resume interrupted uploads, and it handles duplicate data gracefully.

The wandb sync command can also take a --clean flag. If you use wandb sync --clean, it will delete the local wandb directory after a successful upload. This is useful for managing disk space on your local machine, especially if you’re running many experiments offline.

The default behavior of wandb sync is to upload any pending runs. If you have multiple wandb directories in your current path, it will attempt to sync all of them. You can also specify a particular run directory to sync, for example: wandb sync /path/to/your/run/directory. This offers granular control over what gets uploaded and when.

A crucial detail often overlooked is that wandb sync respects the WANDB_API_KEY environment variable. If this variable is not set, wandb sync will prompt you to log in or provide an API key. For automated syncing in CI/CD or on servers, ensuring this key is set is paramount.

When you sync a run that was created in offline mode, wandb sync automatically associates it with your currently logged-in W&B account. If you’ve never logged into the CLI before, you’ll be prompted to do so. This ensures that your offline experiments are correctly attributed to you when they appear on the W&B dashboard.

The next step after syncing is often to analyze the aggregated results across multiple runs, which might involve setting up W&B sweeps to manage hyperparameter optimization.

Want structured learning?

Take the full Wandb course →