Buckets:

hf-doc-build/doc-dev / trackio /pr_651 /en /self_hosted_server.md
qgallouedec's picture
|
download
raw
2.82 kB
# Self-host the Trackio server
You can run the Trackio dashboard and API on your own machine (or any host you control) and send metrics from training scripts to that server over HTTP. This is an alternative to logging to a Hugging Face Space via `space_id`.
## Run the server locally
Install Trackio, then start the dashboard. By default it listens on `127.0.0.1` and uses the port from `GRADIO_SERVER_PORT` if set, otherwise **7860** (see [Launch the Dashboard](launch)).
```sh
trackio show
```
```py
import trackio
trackio.show()
```
Leave that process running while you train. The terminal prints a base URL for the UI and a URL that includes a **write token**; anyone who can reach that URL with the token can perform write operations supported by the server (for example renaming runs), so treat it like a secret on untrusted networks.
## Listen on all interfaces
To access the dashboard from another machine on your network (or from containers), bind to all interfaces:
```sh
trackio show --host 0.0.0.0
```
```py
import trackio
trackio.show(host="0.0.0.0")
```
Ensure your firewall and security policies allow the traffic you intend.
## Point training code at your server
In your training script, pass a `server_url` and supply the **write token**: either embed `write_token` in the query string (the same URL the dashboard prints for write access, or the `full_url` return value from `trackio.show()`), or pass a base URL like `http://127.0.0.1:7860/` and set the `TRACKIO_WRITE_TOKEN` environment variable to that token. You can also set `TRACKIO_WRITE_TOKEN` on the Trackio server before launching `trackio.show()` to choose the server's write token instead of using the random token generated at startup. Metric ingestion and uploads require this token when the server is not on Hugging Face Spaces. You can also set `TRACKIO_SERVER_URL` instead of passing `server_url` in code.
```py
import trackio
trackio.init(
project="my-project",
server_url="http://127.0.0.1:7860?write_token=YOUR_TOKEN",
)
trackio.log({"loss": 0.25})
trackio.finish()
```
Precedence: **`space_id` / `TRACKIO_SPACE_ID` always wins** over `server_url` / `TRACKIO_SERVER_URL` when both are set (in code or in the environment). Trackio then behaves as if only the Space were configured.
Hugging Face–specific options such as `dataset_id` (deprecated; use `bucket_id` instead) and `bucket_id` apply only when logging to a Space. When only `server_url` is in effect, configure persistence on the machine where the server runs (for example via `TRACKIO_DIR` on that host). See [Environment Variables](environment_variables).
## Related
- [Launch the Dashboard](launch) — CLI options, port, and remote access
- [Environment Variables](environment_variables) — `TRACKIO_SERVER_URL`, `TRACKIO_DIR`, and others

Xet Storage Details

Size:
2.82 kB
·
Xet hash:
457e724050dde454b65e2d9e232206068ebe536cefbb2776bed8a4524a4840f4

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.