Data Version Control
๐ฆ ML Experiments and Data Management with Git
DVC ์์ฒด๋ง์ผ๋ก ๋ฐ์ดํฐ์ ๋ฒ์ ๊ด๋ฆฌ๋ฅผ ํ ์ ์๋ ๊ฒ์ ์๋๋๋ค. DVC๋ ๋ฐ์ดํฐ๋ฅผ ์ถ์ ํ๋ ๋ฐ์ ์ฌ์ฉํ ๋ฉํ ๋ฐ์ดํฐ์ ์ค์ ํ์ผ์ ์์ฑํ๊ณ , DVC์ ์ํด ์์ฑ๋ ํ์ผ์ git์ด ์ถ์ ํ์ฌ ๋ฒ์ ๊ด๋ฆฌ๋ฅผ ์งํํฉ๋๋ค.
Install
pip ๋ฐฉ๋ฒ:
Depending on the type of the remote storage you plan to use, you might need to install optional dependencies: [s3], [gdrive], [gs], [azure], [ssh], [hdfs], [webdav], [oss]. Use [all] to include them all.
snap ๋ฐฉ๋ฒ:
์ ์ฅ์ ์ด๊ธฐํ
.git
์ด ์๋ ํด๋๋ก ์ด๋ํ ํ
ํ๋ฉด ๋ค์ ํ์ผ๋ค์ด ์ถ๊ฐ๋๋ค.
-
.dvc/.gitignore
-
.dvc/config
-
.dvcignore
์๊ฒฉ์ง ์ถ๊ฐ
-d
๋ --default
์ต์
๊ณผ ๋์ผ.
## SSH/SFTP
dvc remote add -d yournas ssh://yournas/volume5/20TB_DATA/DVC/ddrm
## WebDAV Over TLS
dvc remote add -d yournas webdavs://yournas:5006/20TB_DATA/DVC/ddrm
์๊ฒฉ์ง ์ค์
modify ๋ฅผ ์ฌ์ฉํ๋ฉด .dvc/config
ํ์ผ์ ์ ์ฅ๋๋ค.
--local
์ต์
์ ์ฌ์ฉํ๋ฉด Git Ignored ์ฒ๋ฆฌ๋ ๋ก์ปฌ ์ค์ ํ์ผ (located in .dvc/config.local
) ์ ์ฌ์ฉํ๋ค.
์ ์ ์ ๋ณด ์ถ๊ฐ (์ ์ฅ์๊ฐ ์๋ ์ฌ์ฉ์ ์ค์ )
-
dvc remote modify --local {๋ฆฌ๋ชจํธ์ด๋ฆ} user {์ฌ์ฉ์๋ช }
- ์ฌ์ฉ์๋ช ์ง์ -
dvc remote modify --local {๋ฆฌ๋ชจํธ์ด๋ฆ} password {๋น๋ฐ๋ฒํธ}
- ๋น๋ฐ๋ฒํธ ์ง์ -
dvc remote modify --local {๋ฆฌ๋ชจํธ์ด๋ฆ} port {ํฌํธ๋ฒํธ}
- ํฌํธ๋ฒํธ ๋ณ๊ฒฝ -
dvc remote modify {๋ฆฌ๋ชจํธ์ด๋ฆ} ask_password true
- ํต์ ์ ๋น๋ฐ๋ฒํธ ์ง์ ์ฌ๋ถ, true ๋๋ false
SSH KEY ๋ก ์ ์ํ ๊ฒฝ์ฐ:
-
dvc remote modify --local {๋ฆฌ๋ชจํธ์ด๋ฆ} keyfile {/path/to/keyfile}
-
dvc remote modify {๋ฆฌ๋ชจํธ์ด๋ฆ} ask_passphrase true
-
dvc remote modify --local {๋ฆฌ๋ชจํธ์ด๋ฆ} passphrase mypassphrase
SSL ๊ฒ์ฆ:
-
dvc remote modify {๋ฆฌ๋ชจํธ์ด๋ฆ} ssl_verify false
- ๊ฒ์ฆ SKIP
๋น ๋ฅธ ์์
์๋ชจ๋ฅด๊ฒ์ dvc init
์ดํ ์๋์ ๊ฐ์ด ์งํ.
INFORMATION |
์๋ ์ ์ ์๊ฒฉ ์ ์ฅ์ URL์ ์ ๋ก๋ํ ๊ฒฝ๋ก์ ๋๋ ํ ๋ฆฌ๊ฐ ์กด์ฌํด์ผ ํ๋ค. |
.dvc/config
file:
[core]
remote = yournas
autostage = true
['remote "yournas"']
url = webdavs://yournas:5006/20TB_DATA/DVC/์
๋ก๋ํ ๊ฒฝ๋ก
ask_password = true
ssl_verify = false
hosts ํ์ผ ์ ๋ฐ์ดํธ ๋ฐ ์ฌ์ฉ์ ์ ๋ณด ์ถ๊ฐ:
.dvc/config.local
file:
.dvc/.gitignore
file:
๊ทธ๋ฆฌ๊ณ ์ถ๊ฐํ๊ณ ์ถ์ ํ์ผ ์ถ๊ฐ. ์์ปจ๋ฐ cvp/assets/*.sqlite
ํ์ผ๋ค ์ด๋ผ๋ฉด:
git ์ผ๋ก ๊ด๋ จ ํ์ผ๋ค ์ถ๊ฐ ํ๋ ๋ง๋ ์์์ ํ์ ํ
ํ๋ฉด ๋๋ค.
์ถ์ ์ถ๊ฐ
์ํ๋ ํ์ผ ๋๋ ๋๋ ํ ๋ฆฌ ์ถ๊ฐ.
๋ค์๊ณผ ๊ฐ์ด ์ถ๋ ฅ๋๋ค:
100% Adding...|โโโโโโ|1/1 [00:04, 4.35s/file]
To track the changes with git, run:
git add ddrm/assets/checkpoints.dvc
To enable auto staging, run:
dvc config core.autostage true
DVC ์์ฒด๋ ์ด๋ ฅ ๊ด๋ฆฌ๊ฐ ์์ผ๋ฏ๋ก git ์ผ๋ก ์ถ๊ฐํ๋ค:
์ถ์ ์ ๊ฑฐ
์๊ฒฉ ์ ์ฅ์์ ํ์ผ ์ ๊ฑฐ
WARNING |
ํ์ธ ํ์ |
์๊ฒฉ์ ์ฅ์์์ dvc workspace์์ ์ถ์ ํ์ง ์๋ ํ์ผ ์ญ์
์ํ ํ์ธ
*.dvc
ํ์ผ ๊ธฐ์ค์ผ๋ก ์ถ๋ ฅ๋๋ค.
๊ทผ๋ฐ ์ด๋ ๊ฒ ๋ณด๋ฉด ๋ญ๋ง์ธ์ ์ ๋ชจ๋ฆ.
"data" ๊ฐ ์ถ๊ฐ๋๋ฉด ์ฝ๊ฐ git status
์ค๋ฌ์ด ์ถ๋ ฅ์ ํ ์ ์๋ค.
์๋ฅผ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ์ถ๋ ฅ๋๋ค:
Not in cache:
(use "dvc fetch <file>..." to download files)
ddrm/assets/checkpoints/mobile_sam.pt
ddrm/assets/checkpoints/rtmdet-ins_x_8xb16-300e_coco-cam1-epoch_300.pth
ddrm/assets/checkpoints/rtmdet-ins_x_8xb16-300e_coco_2nd-epoch_300.pth
DVC uncommitted changes:
(use "dvc commit <file>..." to track changes)
(use "dvc checkout <file>..." to discard changes)
deleted: ddrm/assets/checkpoints/mobile_sam.pt
deleted: ddrm/assets/checkpoints/rtmdet-ins_x_8xb16-300e_coco-cam1-epoch_300.pth
deleted: ddrm/assets/checkpoints/rtmdet-ins_x_8xb16-300e_coco_2nd-epoch_300.pth
(there are other changes not tracked by dvc, use "git status" to see)
์ถ์ ์ค์ธ ํ์ผ ๊ฐฑ์ (commit)
dvc add
๋ ์ถ์ ์ค์ด์ง ์๋ ํ์ผ์ ์ถ์ ํ๋๋ก ์ถ๊ฐํ๋ ๊ฒ. dvc commit
์ ์ด๋ฏธ ์ถ์ ์ค์ธ ํ์ผ์ด ์์ ๋์์ ๋ ์์ ์ฌํญ์ "ํ์ "ํ๊ณ ์บ์๋ฅผ ์
๋ฐ์ดํธํ๋ค. (์ฆ ์๋ฒ์ ์
๋ก๋ํ์ง ์๋๋ค)
git add
-> git commit
์์๋ก ์ดํ๋์ง๋ง ์ด๊ฒ๊ณผ ๋ณ๊ฐ๋ก ์๊ฐํด์ผ ํ๋ค.
์์
๋ฐ์ดํฐ๊ฐ ์์ ๋ ์งํ ๋ค์ ๋ฐ์ดํฐ ์ํ๋ฅผ ํ์ธํด ๋ณด์:
$ opy-dvc data status
DVC uncommitted changes:
(use "dvc commit <file>..." to track changes)
(use "dvc checkout <file>..." to discard changes)
modified: demos/
(there are other changes not tracked by dvc, use "git status" to see)
์ ๊ธฐ "modified:" ๋ถ๋ถ์ด <span style="color: yellow;">๋ ธ๋์์ผ๋ก ์ถ๋ ฅ๋๋ค. ์ฃผ์๋๋ก ํ๋ฉด ๋๋ค.
- ๋ณ๊ฒฝ ์ฌํญ์ ์ ์ฉ ํ๊ณ ์ถ๋ค๋ฉด "dvc commit <file>..."
- ๋ณ๊ฒฝ ์ฌํญ์ ์ทจ์ ํ๊ณ ์ถ๋ค๋ฉด "dvc checkout <file>..."
์ฌ๊ธฐ์ commit ํ๋ค.
$ opy-dvc commit
outputs ['demos'] of stage: 'demos.dvc' changed. Are you sure you want to commit it? [y/n] y
๋ณ๊ฒฝ๋ ๋ด์ฉ์ด ์๋ค๋ฉด ์ปค๋ฐํ ๊ฑด์ง ๋ฌผ์ด๋ณธ๋ค. y ๋ฅผ ์ ๋ ฅํ๋ฉด ๋๋ค.
$ opy-dvc data status
DVC committed changes:
(git commit the corresponding dvc files to update the repo)
modified: demos/
(there are other changes not tracked by dvc, use "git status" to see)
"modified:" ๋ถ๋ถ์ด <span style="color: green;">๋ น์์ผ๋ก ์ถ๋ ฅ๋๋ค. ์๋ฒ์ ์ ๋ก๋ํ๊ณ ์ถ๋ค๋ฉด push ํ์.
์๊ฒฉ์ง ๋๊ธฐํ
DVC ์๊ฒฉ์ง์์ ๋ค์ด๋ก๋:
DVC ์๊ฒฉ์ง์ ์ ๋ก๋:
์ด์ ๋ฒ์ ๋ณต๊ท
dvc๋ ๋ฐ์ดํฐ/๋ชจ๋ธ์ ๋ฒ์ ์ ๋ณ๊ฒฝํ๊ธฐ ์ํด ์ฌ์ฉํฉ๋๋ค. ๋ฒ์ ์ ๋ณ๊ฒฝํ๋ ๋ฐฉ๋ฒ์ ์์๋ด ์๋ค!
train.py ์์ ์ผ๋ถ ํ์ดํผํ๋ผ๋ฏธํฐ๋ฅผ ๋ณ๊ฒฝํ๊ณ ์ ๋ชจ๋ธ์ ํ๋ จํ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
ํ๋ จ ํ model_output์๋ ์ ๋ชจ๋ธ ํ์ผ์ด ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
dvc add model_output
git commit model_output.dvc -m "dvc: Model Updata vx.x"
dvc push
git push origin master
์์ ๊ฐ์ด ์ ๋ฒ์ ์ ๋ฐ์ดํฐ/๋ชจ๋ธ์ dvc์ pushํฉ๋๋ค.
์ด์ ๋ฐ์ดํฐ์ ๋ฒ์ ์ผ๋ก ์ ํํ ๋๋ ์์ ๊ฐ์ด ์ฌ์ฉํ๊ณ ์ ํ๋ ํด๋น ์ปค๋ฐ์ผ๋ก ๋์์ ๋น์์ dvc ๋ด์ฉ์ผ๋ก ๋์๊ฐ๋ฉด ๋ฉ๋๋ค!
์บ์
Is A TTY
Data Management
Remote Storage
DVC ๋ฆฌ๋ชจ์ปจ์ ์ธ๋ถ ์ ์ฅ์ ์์น์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ์ฌ ๋ฐ์ดํฐ ๋ฐ ML ๋ชจ๋ธ์ ์ถ์ ํ๊ณ ๊ณต์ ํฉ๋๋ค.
์ผ๋ฐ์ ์ผ๋ก ์ด๋ฌํ ์ ๋ณด๋ ํ๋ก์ ํธ ์์ ์ ์ํํ๋ ์ฅ์น๋ ํ ๊ตฌ์ฑ์ ๊ฐ์ ๊ณต์ ๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด ๋๋ฃ๊ฐ ์์ฑํ ๋ฐ์ดํฐ ์ํฐํฉํธ๋ฅผ ๋ก์ปฌ์์ ์ฌ์์ฑํ๋ ๋ฐ ์๊ฐ๊ณผ ๋ฆฌ์์ค๋ฅผ ์๋นํ์ง ์๊ณ ๋ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค.
- Amazon S3
- Azure Blob Storage
- Google Cloud Storage
- Google Drive
- Aliyun OSS
- SSH & SFTP
- HDFS & WebHDFS
- HTTP
- WebDAV
ddrm ์ ์ฅ์ ์ด๊ธฐํ ์์
Synology DiskStation (NAS) ์์ sftp๋ฅผ ์ฌ์ฉํ๋ฉด mkdirs ์ค ์๋ฌ๊ฐ ๊ณ์ ๋ฐ์๋์ WebDAV ํจํค์ง ์ค์น ํ TLS ์ ์ ํฌํธ(5006) ๋ก ์ ์ฉํ๋ค.
dvc init
dvc remote add -d yournas webdavs://yournas:5006/20TB_DATA/DVC/ddrm
dvc config core.autostage true
dvc add ./ddrm/assets/checkpoints/
git rm -r --cached ddrm/assets/checkpoints
git add ddrm/assets/checkpoints.dvc
Troubleshooting
Client error '401 Unauthorized' for url '..'
Collecting
Fetching
ERROR: unexpected error - received 401 (Unauthorized): Client error '401 Unauthorized' for url 'https://yournas:5006/20TB_DATA/DVC/ddrm/files/md5/00'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
์ต์ํ ์ฌ์ฉ์ ID๋ ์ถ๊ฐํด์ผ ํ๋ค.
ํ์ํ๋ค๋ฉด ๋น๋ฐ๋ฒํธ๋ ๋ฌผ์ด๋ณด๊ฒ ํ์.
unknown module name (_ssl.c:2633)
webdavs ํ๋กํ ์ฝ ์ฌ์ฉ, dvc push
ํ ๊ฒฝ์ฐ:
ERROR: unexpected error - [CONF: UNKNOWN_MODULE_NAME] unknown module name (_ssl.c:2633): [CONF: UNKNOWN_MODULE_NAME] unknown module name (_ssl.c:2633)
Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
ํ.. -_-; ๊ทธ๋ฅ pip๋ก ์ค์นํ ํ ์ฌ์ฉํ์.
output '...' is already tracked by SCM (e.g. Git)
dvc add ddrm/assets/checkpoints/
๋ช
๋ น์ ๋ ๋ฆฌ๋:
Computing md5 for a large file '/home/yourid/Project/ddrm/ddrm/assets/checkpoints/rtmdet-ins_x_8xb16-300e_coco-cam1-epoch_300.pth'. This is only done once.
Computing md5 for a large file '/home/yourid/Project/ddrm/ddrm/assets/checkpoints/rtmdet-ins_x_8xb16-300e_coco_2nd-epoch_300.pth'. This is only done once.
Adding...
ERROR: output 'ddrm/assets/checkpoints' is already tracked by SCM (e.g. Git).
You can remove it from Git, then add to DVC.
To stop tracking from Git:
git rm -r --cached 'ddrm/assets/checkpoints'
git commit -m "stop tracking ddrm/assets/checkpoints"
๋ช ์๋ ํ์ผ/ํด๋๋ฅผ SCM ๋ฒ์ ๊ด๋ฆฌ์์ ์ ๊ฑฐํด์ผ ํ๋ค.