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
git add 了数据文件,没有提交 .dvc 文件,其他人拉不到。dvc push 失败。dvc add,Git 里仍是指向旧内容的指针。dvc repro 的依赖声明不完整,缓存命中错误。git filter-repo 清理。dvc gc。