I need to run my code on a cluster in offline mode. Even though I specify wandb offline in the batch file, I encounter an error when the code reaches wandb.sweep(). The error message is:
Hello, This a reply from our support bot designed to assist you with your Weights & Biases related queries. To reach a human please reply to this message.
Running wandb.sweep in offline mode presents a unique challenge because sweeps are designed to coordinate hyperparameter searches across multiple runs, typically requiring communication with the Weights & Biases server. However, based on the context provided, there’s no direct support for executing wandb.sweep entirely offline as it inherently relies on the W&B server to manage the sweep configuration and distribute tasks to agents.
The error you’re encountering (wandb: Network error (ConnectionError), entering retry loop.) occurs because wandb.sweep attempts to communicate with the W&B server to create the sweep and fails due to the offline mode setting.
Here’s a workaround approach for running experiments in a somewhat “offline” manner, but it’s important to note that this doesn’t utilize the wandb.sweep function directly because of its online nature:
Prepare Sweep Configuration Locally: Before moving to the cluster, define your sweep configuration as you normally would and use the W&B interface to create a sweep. This step requires internet access but can be done from your local machine. Note the sweep_id generated by W&B.
Manual Sweep Execution: Instead of using wandb.sweep and wandb.agent to automatically manage your sweep, manually iterate over your desired hyperparameter configurations in your code. For each configuration:
Initialize a W&B run with wandb.init(mode='offline', ...) to ensure it operates in offline mode.
Manually set the hyperparameters in wandb.config based on the current iteration’s configuration.
Execute your training script with these hyperparameters.
Save the run’s outputs and logs as usual with wandb.log.
Post-Processing: After completing all runs, you’ll have a collection of offline run directories. You can then upload these runs to the W&B server when internet access is available using wandb sync command. This step won’t recreate the sweep on the server but will upload the runs to the specified project.
This approach requires manual management of hyperparameter configurations and doesn’t leverage the full power of W&B sweeps, such as automatic hyperparameter optimization algorithms (e.g., Bayesian optimization). However, it allows you to conduct multiple runs in an offline environment and later sync them to W&B for analysis.
For your specific use case, consider revising the workflow to avoid calling wandb.sweep in an environment where network access is not available. Instead, focus on preparing your experiments beforehand and managing the hyperparameter iterations manually within your script.
Unfortunately, the provided context does not include direct instructions or support for running wandb.sweep in a completely offline mode, reflecting the inherent design of sweeps as an online feature. For more detailed guidance or updates on offline capabilities, I recommend reaching out to the Weights & Biases support or checking the W&B Community forums for any new developments or workarounds shared by the community.
We wanted to follow up with you regarding your support request as we have not heard back from you. Please let us know if we can be of further assistance or if your issue has been resolved.