設定 DVC 遠端儲存

使用 DVC 進行資料版本控管入門

Ravi Bhadauria

Machine Learning Engineer

重點回顧

  • 初始化 DVC 儲存庫
    • 執行 dvc init
    • 儲存庫位於工作區(/path/to/my-project
  • 設定 DVC 快取
    • .dvc 目錄中的暫存區
      • /path/to/my-project/.dvc/cache
    • dvc add 分階段暫存檔案
  • 現在:DVC 遠端
    • 外部儲存
    • 追蹤與分享資產
使用 DVC 進行資料版本控管入門

為什麼需要 DVC 遠端

  • DVC 遠端:資料儲存位置
  • 類似 Git 遠端,但用於「快取」資料
  • 使用遠端的好處
    • 同步大型檔案與目錄
    • 集中或分散資料儲存
    • 節省本機空間

從 DVC 工作區到快取與遠端的資料流示意圖

使用 DVC 進行資料版本控管入門

支援的儲存型態

DVC 支援的儲存型態圖示

使用 DVC 進行資料版本控管入門

設定遠端

  • 設定遠端

    • dvc remote add <name> <location>
  • S3 bucket

$ dvc remote add s3_remote \
   s3://mys3bucket
  • DVC 設定變更
 ['remote "s3_remote"']
     url = s3://mys3bucket
  • GCP bucket
$ dvc remote add gcp_remote \
   gs://myGCPbucket
  • Azure
$ dvc remote add azure_remote \
   azure://mycontainer/path
使用 DVC 進行資料版本控管入門

本機遠端

  • 本機遠端用於快速原型開發
  • 使用系統目錄或網路附加儲存(NAS)
$ dvc remote add mylocalremote /tmp/dvc
  • -d 旗標設定預設遠端
$ dvc remote add -d mylocalremote /tmp/dvc
  • 預設遠端會在 .dvc/configcore 區段指定
[core]
remote = mylocalremote
使用 DVC 進行資料版本控管入門

列出遠端

  • 列出遠端
$ dvc remote list
s3_remote    s3://mys3bucket
local_remote /tmp/dvcremote
  • .dvc/config 讀取
 ['remote "s3_remote"']
     url = s3://mys3bucket
 ['remote "local_remote"']
     url = /tmp/dvcremote
使用 DVC 進行資料版本控管入門

修改遠端設定

  • 可用 dvc remote modify 自訂設定
$ dvc remote modify s3_remote connect_timeout 300
  • DVC 設定檔變更
 ['remote "s3_remote"']
     url = s3://mys3bucket
     connect_timeout = 300
使用 DVC 進行資料版本控管入門

總結

  • DVC 遠端用於分享資料與 ML 模型
  • 支援多種本機與雲端儲存位置
  • 新增遠端:dvc remote add
    • -d 指定預設
  • 列出遠端:dvc remote list
  • 修改遠端:dvc remote modify
使用 DVC 進行資料版本控管入門

一起來練習吧!

使用 DVC 進行資料版本控管入門

Preparing Video For Download...