Skip to main content

Description

DVC cache commands help you configure and manage the local cache directory where DVC stores all tracked data and model files. The cache enables efficient storage and sharing of large files across your project.

Subcommands

cache dir

Configure cache directory location.

Arguments

string
Path to cache directory. If no path is provided, it returns the current cache directory.
  • Relative paths are resolved relative to the current directory
  • Path is saved to config relative to the config file location
  • Default location: .dvc/cache within your project

Options

flag
Unset the custom cache directory and revert to default location (.dvc/cache).
flag
Use global config (~/.config/dvc/config).
flag
Use system config.
flag
Use project config (.dvc/config).
flag
Use local config (.dvc/config.local).

cache migrate

Migrate cached files to the DVC 3.0 cache location.

Options

flag
Migrate entries in all existing DVC files in the repository to the DVC 3.0 format.
flag
Only print actions which would be taken without actually migrating any data.

Examples

View Current Cache Location

Move Cache to External Drive

Using an external drive or network storage for cache is useful when working with large datasets that exceed your local disk capacity.

Share Cache Across Multiple Projects

This allows multiple DVC projects to share the same cache, saving disk space.

Reset to Default Location

Preview Cache Migration

Use --dry to safely preview migration before committing to changes.

Migrate to DVC 3.0 Format

Cache migration is a one-way operation. Make sure to backup important data before migrating, especially when using --dvc-files.

Cache Structure

DVC uses content-addressable storage where files are stored by their hash:
  • Files are stored using their MD5 hash
  • First 2 characters of hash become directory name
  • Rest of hash is the filename
  • Same file content = same cache entry (deduplication)

Cache Configuration Options

You can configure additional cache behaviors via dvc config:
Full file copies. Slowest but most compatible. Use when links aren’t available.

Protected Mode

Shared Cache

Use Cases

External Storage

Move cache to external drive when local disk space is limited.

Shared Team Cache

Configure a network location for cache to enable team collaboration without redundant downloads.

CI/CD Optimization

Use persistent cache directories in CI to speed up pipeline runs.

Version Upgrade

Migrate from DVC 2.x to 3.0 cache format for improved performance.

Cache vs Remote Storage

Cache is local storage on your machine for fast access.Remote is cloud or network storage for backup and sharing.Both work together: cache for speed, remote for collaboration.

Troubleshooting

Check Cache Size

Clear Cache

This will delete all cached files. Only do this if you have a remote backup.
Run dvc pull to restore files from remote.

Verify Cache Integrity

Shows which tracked files are missing from cache.
  • dvc config - Configure DVC settings including cache options
  • dvc gc - Garbage collect unused cache files
  • dvc pull - Download files from remote to cache
  • dvc push - Upload files from cache to remote
  • dvc status - Check status of tracked files and cache