DVCLive
DVCLive is a Python library for logging machine learning metrics and other metadata. It is designed to be fully compatible with DVC (Data Version Control) and stores logged information in simple, human-readable file formats (like .tsv, .json, .yaml) that can be versioned by Git. It provides real-time experiment tracking and integrates with various ML frameworks, helping users maintain reproducible ML workflows. The current version is 3.49.0, and the library is actively developed with frequent releases.
Warnings
- breaking Scikit-learn `probas_pred` argument change (v3.48.3 and `sklearn>=1.7`). Older DVCLive versions with `sklearn` 1.7+ might encounter `TypeError: missing a required argument: 'y_score'` when using `live.log_sklearn_plot()`. DVCLive 3.48.3 fixed this internally, so ensure your `dvclive` is updated if you use newer `sklearn`.
- breaking Dropped Catalyst ML framework integration (v3.47.0). Support for the Catalyst ML framework was removed in DVCLive 3.47.0.
- gotcha Matplotlib `Figure` logging behavior change (v3.48.4). Previously, `live.log_image()` with a matplotlib figure might have implicitly logged the most recently active figure. Since 3.48.4, it strictly logs the `matplotlib.figure.Figure` instance explicitly provided as an argument. Make sure to pass the intended figure object.
- gotcha DVC `live` section deprecation in `dvc.yaml` (DVC 3.0 / DVCLive ~3.0). The `live` section for DVCLive configuration in `dvc.yaml` was deprecated and is no longer the primary way to configure DVCLive. Configuration should primarily be done through the Python `Live` API.
- gotcha `save_dvc_exp` ignored in `dvc repro`. When `dvclive` runs as part of a `dvc repro` command, the `save_dvc_exp=True` argument to `Live()` is ignored. DVC experiments will not be automatically saved by `dvclive` in this context.
Install
-
pip install dvclive -
pip install dvclive[sklearn,image,huggingface,lightning,tf,fastai,optuna,xgb,lgbm,mmcv]
Imports
- Live
from dvclive import Live
Quickstart
import time
import random
from dvclive import Live
params = {"learning_rate": 0.002, "optimizer": "Adam", "epochs": 20}
with Live() as live:
# Log parameters
for param in params:
live.log_param(param, params[param])
# Simulate training loop
offset = random.uniform(0.2, 0.1)
for epoch in range(1, params["epochs"]):
fuzz = random.uniform(0.01, 0.1)
accuracy = 1 - (2 ** -epoch) - fuzz - offset
loss = (2 ** -epoch) + fuzz + offset
# Log metrics for the current step
live.log_metric("accuracy", accuracy)
live.log_metric("loss", loss)
live.next_step()
time.sleep(0.05) # Simulate work, shorten for quick demo