WZMIAOMIAO/deep-learning-for-image-processing · error · FileNotFoundError

VOCdevkit dose not in path:'{}'.

Error message

VOCdevkit dose not in path:'{}'.

What it means

Same guard as error 153 but in the LRASPP multi-GPU training script: before building VOCSegmentation datasets it verifies `<args.data_path>/VOCdevkit` exists and raises FileNotFoundError if not. It enforces the expected VOC dataset directory layout early with a clear message.

Source

Thrown at pytorch_segmentation/lraspp/train_multi_GPU.py:84

    return model


def main(args):
    init_distributed_mode(args)
    print(args)

    device = torch.device(args.device)
    # segmentation nun_classes + background
    num_classes = args.num_classes + 1

    # 用来保存coco_info的文件
    results_file = "results{}.txt".format(datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))

    VOC_root = args.data_path
    # check voc root
    if os.path.exists(os.path.join(VOC_root, "VOCdevkit")) is False:
        raise FileNotFoundError("VOCdevkit dose not in path:'{}'.".format(VOC_root))

    # load train data set
    # VOCdevkit -> VOC2012 -> ImageSets -> Segmentation -> train.txt
    train_dataset = VOCSegmentation(args.data_path,
                                    year="2012",
                                    transforms=get_transform(train=True),
                                    txt_name="train.txt")
    # load validation data set
    # VOCdevkit -> VOC2012 -> ImageSets -> Segmentation -> val.txt
    val_dataset = VOCSegmentation(args.data_path,
                                  year="2012",
                                  transforms=get_transform(train=False),
                                  txt_name="val.txt")

    print("Creating data loaders")
    if args.distributed:
        train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
        test_sampler = torch.utils.data.distributed.DistributedSampler(val_dataset)

View on GitHub (pinned to 1ec3fe6f37)

Solutions

  1. Point --data-path at the parent directory containing VOCdevkit/
  2. Create the correct layout: data_path/VOCdevkit/VOC2012/{ImageSets/Segmentation,JPEGImages,SegmentationClass}
  3. Use absolute paths or $DATA_ROOT env var; verify on every node before torchrun
  4. Re-extract the VOC2012 archive if VOCdevkit is genuinely missing

Example fix

// before
python -m torch.distributed.run --nproc_per_node=4 train_multi_GPU.py --data-path ./VOCdevkit
// after
python -m torch.distributed.run --nproc_per_node=4 train_multi_GPU.py --data-path /data/VOC2012_train_val  # dir contains VOCdevkit/
Defensive patterns

Strategy: validation

Validate before calling

import os
assert os.path.isdir(os.path.join(args.data_path, 'VOCdevkit', 'VOC2012')), \
    f"VOC root invalid: {args.data_path}"

Type guard

def voc_layout_ok(path):
    return os.path.isdir(os.path.join(path, 'VOCdevkit', 'VOC2012', 'SegmentationClass'))

Try / catch

try:
    train_dataset = VOCSegmentation(args.data_path, year="2012", ...)
except FileNotFoundError as e:
    raise SystemExit(f"VOC dataset missing under {args.data_path}: {e}")

Prevention

When it happens

Trigger: `--data-path` set to the VOCdevkit dir itself or a non-dataset directory; dataset not downloaded/extracted on the node running rank 0; relative path resolved from a different CWD under torchrun; symlink broken after moving data.

Common situations: Multi-node training where only some nodes have the dataset mounted; job schedulers resetting CWD; sharing a script where teammates keep data at different paths; forgetting to run the download/extract step before launching 4/8-GPU training.

Related errors


AI-assisted analysis of WZMIAOMIAO/deep-learning-for-image-processing@1ec3fe6f37 (2026-08-30). Data as JSON: /api/errors/4dcc394d7d47a7fc. Report an issue: GitHub.