Introduction

Weight and Bias (WandB) 是一個 AI 開發者平台,可以用來記錄模型訓練過程的日誌,幫助開發者微調模型的工具,是一個非常強大的工具,類似的工具有 Neptune、TensorBoard、MLFlow 等。WandB 可以使用官方提供的平台紀錄訓練資料,免費計畫有容量額度的限制,若使用自架伺服器則沒有這個限制。

Installation

不論是 Client 還是 Server,要使用 WandB 都可以使用 Python 安裝:

pip install wandb
conda install wandb --channel conda-forge

第一次安裝完成會提示輸入在 WandB 帳號的 API key,是用來給 Client 用的,之後跑訓練模型的時候會把相關過程記錄在這個帳號上,此時紀錄的位置還是官方提供的平台位置,並不是自架的伺服器。

wandb: W&B server started at <http://localhost:8080> 🚀
wandb: You can stop the server by running `wandb server stop`
wandb: You can find your API key in your browser here: <http://localhost:8080/authorize>
wandb: Paste an API key from your profile and hit enter, or press ctrl+c to quit:
wandb: Appending key for localhost to your netrc file: /home/yucheng/.netrc

若要修改紀錄的目標成自己的伺服器位置,需要設定地址成自己的位置。

wandb login --host=http://wandb.your-shared-local-host.com
wandb login --host=http://wandb.your-shared-local-host.com --relogin

如果要切換回官方提供的平台,則需要設定回去。

wandb login --cloud --relogin

Self Hosting

若要自架 WandB Server,官方說明是同樣用使用 Python 安裝 Wandb。不同的是還需要安裝 Docker,伺服器將架在 Docker 裡面。執行下面命令將自動建立伺服器。

wandb server start

若要手動建立伺服器,也可以單純使用 Docker 架設,因此應該可以不用 Python 安裝 WandB?但若要使用 wandb 指令可能就需要自己去找地方修改。

docker run --rm -d -v wandb:/vol -p 8080:8080 --name wandb-local wandb/local