dvc

DVC 数据与模型版本管理

补充说明

DVC 用 Git 管理代码、用远程存储管理大文件,适合数据集、模型和训练流水线的版本化。它把大文件指针提交到 Git,把实际内容放到 S3、MinIO、NFS 等远程存储。

常用示例

初始化:

git init
dvc init
git commit -m "init dvc"

添加数据:

dvc add data/train.csv
git add data/train.csv.dvc data/.gitignore
git commit -m "add training data"

配置远程存储:

dvc remote add -d storage s3://my-dvc-bucket
dvc remote modify storage endpointurl http://minio:9000
dvc push

拉取数据:

dvc pull

定义流水线:

dvc stage add -n train \
  -d data/train.csv -d train.py \
  -o model.pkl \
  python train.py
dvc repro

查看指标和实验:

dvc metrics show
dvc exp run
dvc exp show

易错点与排错