跳到正文

第 22 课 · Troubleshooting and Practices

Troubleshooting Common DVC Problems

Fix common DVC problems: failed pulls, missing cache objects, lock errors, too many open files, credentials, stale pipelines and Git-tracked data, step by step.

Most DVC problems fall into a few families: missing data, authentication, locks, file links and surprising reruns. A calm, ordered approach fixes them faster than guessing.

Start with facts

Terminal
# Read-only: gather information
dvc doctor
dvc status
dvc data status --granular
git status
dvc pull -v           # add -v to whichever command fails

Read the whole error message, not only the last line. Before you share logs, remove tokens, passwords and private paths.

Failed to pull

Check these causes in order:

  1. The author pushed Git commits but not the data. Ask them to run dvc push.
  2. You are on a different branch or commit than you think.
  3. Your remote is not configured or the default is wrong (dvc remote list, dvc remote default).
  4. You lack permission to read the storage.
  5. Someone deleted objects from storage, for example with cloud garbage collection or manual cleanup. Restore from a backup or storage versioning.

Authentication and connection errors

  • Unable to find credentials: configure the provider's standard credentials, or set options with dvc remote modify --local.
  • Unable to connect: check the network, VPN and, for S3-compatible storage, the endpointurl.
  • Bucket does not exist: confirm the name, region and endpoint.
  • Git authentication during dvc import: prefer SSH, or set up a Git credential helper at the global level.

Lock errors

DVC uses lock files so two processes do not change the same state. If it says it cannot acquire a lock:

  1. Check whether another DVC process is still running, including a queue worker or an editor extension.
  2. Wait for it, or stop it properly.
  3. Only when you are sure nothing is running, delete .dvc/tmp/lock.

On network file systems such as NFS or Lustre, the documentation suggests dvc config core.hardlink_lock true.

Too many open files

An error with Errno 24 means the limit on open files was reached. Reduce parallel transfers with --jobs (for example dvc pull --jobs 4), or raise the limit (ulimit -n on Unix-like systems).

  • No possible cache types: your cache.type does not work on this file system. Change the setting, then run dvc checkout --relink.
  • Permission denied when editing: the file may be a protected hardlink or symlink. Run dvc unprotect <file>.
  • Unable to detect cache type: create the cache folder, for example mkdir .dvc/cache, then retry.
  • Cannot add through a symlinked folder: dvc add accepts symlinked files, but not symlinked directories or paths through them.

Git already tracks the file

If DVC refuses because Git tracks a path:

Terminal
# Read-only: hand a file over from Git to DVC
git rm -r --cached data/reviews.csv
git commit -m "Stop tracking data in Git"
dvc add data/reviews.csv

The file remains in earlier Git history. For secrets or oversized files, plan a history cleanup with your team.

Why did my stage rerun? Why not?

Observation Check
Reruns every time always_changed, a stage with no dependencies or outputs, or an upstream output containing timestamps
Does not rerun after a code edit Is the module listed in deps?
Does not rerun after a parameter edit Is the key listed in params?
Runs but nothing changes The script ignores the parameter
Old output returns The run cache; use --no-run-cache or -f
Skipped although stale The stage may be frozen

Run dvc status and dvc repro --dry to see DVC's reasoning before you force anything. -f can hide the cause rather than fix it.

Try the idea

This stand-in is a tiny "triage" helper that maps symptoms to first checks. Real diagnosis needs the actual error message.

Python Stand-in: a symptom triage helper

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Asking for help

Include the output of dvc doctor, the exact command, the full error with -v, your storage type, and what you changed recently. Create a tiny repository that reproduces the problem with fake data. Never post private data or credentials in a public issue.

Safety first

Before running a command that deletes or overwrites (dvc gc, dvc destroy, dvc checkout -f, dvc init -f, dvc exp apply), make sure you can recover. Check whether the data exists in a remote or backup. dvc destroy removes DVC from the project, including DVC's own files and local cache data, so do not use it as a "reset".

Common mistake: deleting the cache or the .dvc folder as a first fix. You may erase the only copy of unpushed data.

A worked example

A teammate reports that dvc repro runs the training stage every time, even when nothing changed. Work through it calmly. First, dvc status shows that a dependency of train changed: data/clean.csv. The file is an output of prepare, which also ran. Looking at prepare, you find that it writes the current time into a comment line. Each run produces a new hash, so train always sees new input. The fix is to remove the timestamp from the data file and log it elsewhere. After one more run, both stages are skipped. Notice that forcing or editing the lock file would only have hidden the problem.

Write it down

After you solve a problem, add two lines to your team notes: the symptom and the real cause.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What is a very common cause of a failed dvc pull for a fresh commit?

    The pointer arrived through Git but the objects never reached storage.
  2. 2. DVC reports that it cannot acquire a lock. What should you do first?

    Remove the lock file only after you are sure nothing is using it.
  3. 3. A stage does not rerun after you edit a helper module. What is a likely cause?

    DVC only watches declared dependencies.
  4. 4. What helps with an Errno 24 error during transfer?

    The error means too many files are open at once.

Summary

  • Collect dvc doctor, status output and a verbose log first.
  • Failed pulls often mean unpushed data, a wrong remote or missing access.
  • Remove a lock file only when no DVC process is running.
  • Unexpected reruns usually come from declarations in dvc.yaml.
  • Never delete caches or DVC folders without a recovery path.

Next: Cleaning Storage and Best Practices

你的学习进度保存在此浏览器中,无需账号。