ultralytics/yolov5 · error · RuntimeError
Dataset not found ❌
Error message
Dataset not found ❌
What it means
check_dataset in utils/general.py raises RuntimeError('Dataset not found') when the yaml's val path(s) do not exist on disk AND there is no 'download:' entry (or autodownload=False) to fetch them. The preceding log line lists exactly which paths are missing. This is the top-level dataset gate for train.py/val.py; it only autodownloads when download: is an http..zip URL, a 'bash ...' script, or inline python.
Source
Thrown at utils/general.py:393
data["path"] = path # download scripts
for k in "train", "val", "test":
if data.get(k): # prepend path
if isinstance(data[k], str):
x = (path / data[k]).resolve()
if not x.exists() and data[k].startswith("../"):
x = (path / data[k][3:]).resolve()
data[k] = str(x)
else:
data[k] = [str((path / x).resolve()) for x in data[k]]
# Parse yaml
_train, val, _test, s = (data.get(x) for x in ("train", "val", "test", "download"))
if val:
val = [Path(x).resolve() for x in (val if isinstance(val, list) else [val])] # val path
if not all(x.exists() for x in val):
LOGGER.info("\nDataset not found ⚠️, missing paths %s" % [str(x) for x in val if not x.exists()])
if not s or not autodownload:
raise RuntimeError("Dataset not found ❌")
t = time.time()
if s.startswith("http") and s.endswith(".zip"): # URL
download(s, dir=DATASETS_DIR, curl=True)
r = None # success
elif s.startswith("bash "): # bash script
LOGGER.info(f"Running {s} ...")
r = subprocess.run(s, shell=True, check=False).returncode
else: # python script
r = exec(s, {"yaml": data}) # noqa: S102 # return None
dt = f"({round(time.time() - t, 1)}s)"
s = f"success ✅ {dt}, saved to {colorstr('bold', DATASETS_DIR)}" if r in (0, None) else f"failure {dt} ❌"
LOGGER.info(f"Dataset download {s}")
check_font("Arial.ttf" if is_ascii(data["names"]) else "Arial.Unicode.ttf", progress=True) # download fonts
return data # dictionary
def check_amp(model):
"""Checks PyTorch AMP functionality for a model, returns True if AMP operates correctly, otherwise False."""View on GitHub (pinned to 20d1d78a08)
Solutions
- Add a download: URL to the yaml so check_dataset can fetch it (see coco.yaml for the pattern).
- Or download/extract the dataset manually and correct the train/val/test paths to the extracted locations.
- Rerun with the same command; the missing paths are logged just above the exception.
Example fix
# before (mydata.yaml) path: ../datasets/mydata train: images/train val: images/val # after (mydata.yaml) path: ../datasets/mydata download: https://example.com/mydata.zip train: images/train val: images/val
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
import yaml
def dataset_ready(data_yaml: str) -> bool:
p = Path(data_yaml).resolve()
d = yaml.safe_load(p.read_text())
base = Path(d.get('path') or p.parent)
val = d.get('val')
if not val:
return False
vals = val if isinstance(val, list) else [val]
return all((Path(x) if str(x).startswith('/') else base / x).exists() for x in vals) or bool(d.get('download')) Try / catch
try:
data = check_dataset(data_yaml)
except RuntimeError as e:
if 'Dataset not found' in str(e):
raise SystemExit('download the dataset or add a download: URL to the yaml') from e Prevention
- Ship a download: URL in every distributed data yaml.
- Preflight check_dataset() in CI so missing datasets fail before training starts.
When it happens
Trigger: data yaml with val: ../coco/val2017.txt that is absent and no download: key; passing autodownload=False programmatically while the dataset is missing; a download: field that is an empty string (falsy) so the guard still trips.
Common situations: First-time training runs; yamls for custom datasets created without a download step; CI caches that exclude the datasets dir; users moving DATASETS_DIR without updating yamls.
Related errors
- {prefix}{p} does not exist
- {prefix}Error loading data from {path}: {e}\n{HELP_URL}
- More than one yaml file was found in the dataset root, canno
- No yaml definition found in dataset root path, check that th
- Could not resolve hostname '{hostname}': {e}
AI-assisted analysis of ultralytics/yolov5@20d1d78a08 (2026-08-15).
Data as JSON: /api/errors/c96d8b1d6fa4cb38.
Report an issue: GitHub.