{"id":24117,"library":"nnunetv2","title":"nnU-Net v2","description":"nnU-Net is a self-adapting framework for biomedical image segmentation that automatically configures itself for new datasets. Version 2.7.0 reworks the dataset conversion and introduces new training modes. Active development, monthly releases.","status":"active","version":"2.7.0","language":"python","source_language":"en","source_url":"https://github.com/MIC-DKFZ/nnUNet","tags":["medical-imaging","segmentation","deep-learning","image-segmentation"],"install":[{"cmd":"pip install nnunetv2","lang":"bash","label":"Standard install"},{"cmd":"pip install nnunetv2[all]","lang":"bash","label":"Install with all extras (e.g., zarr, tensorboard)"}],"dependencies":[],"imports":[{"note":"v1 package is nnunet; v2 requires nnunetv2 prefix","wrong":"from nnunet.experiment_planning import nnUNetPlanner","symbol":"nnUNetPlanner","correct":"from nnunetv2.experiment_planning.plan_and_configurator import nnUNetPlanner"},{"note":"Import path changed between major versions","wrong":"from nnunet.training import nnUNetTrainer","symbol":"nnUNetTrainer","correct":"from nnunetv2.training.nnUNetTrainer import nnUNetTrainer"},{"note":"Predictor class was added in v2","wrong":"from nnunet.inference import predict","symbol":"nnUNetPredictor","correct":"from nnunetv2.inference.predict import nnUNetPredictor"}],"quickstart":{"code":"import os\nos.environ['nnUNet_raw'] = '/path/to/nnUNet_raw'\nos.environ['nnUNet_preprocessed'] = '/path/to/nnUNet_preprocessed'\nos.environ['nnUNet_results'] = '/path/to/nnUNet_results'\n# Convert dataset (Task002_Heart example)\nfrom nnunetv2.dataset_conversion import convert_MSD_dataset\nconvert_MSD_dataset.convert_msd_dataset('/path/to/Task02_Heart')\n# Plan & preprocess\nfrom nnunetv2.experiment_planning.plan_and_configurator import nnUNetPlanner\nplanner = nnUNetPlanner(dataset_name_or_id='002', plans_identifier='nnUNetPlans')\nplanner.plan_and_preprocess()\n# Train 2D U-Net\nfrom nnunetv2.run.run_training import run_training\nrun_training('002', '2d', 0, plans_identifier='nnUNetPlans')\n","lang":"python","description":"Prepares environment variables, converts a Medical Segmentation Decathlon dataset, plans preprocessing, and runs a 2D training fold."},"warnings":[{"fix":"Set new env vars: nnUNet_raw, nnUNet_preprocessed, nnUNet_results. Update scripts that used the old names.","message":"From v2.0, the environment variables nnUNet_raw_data_base and nnUNet_preprocessed are replaced by nnUNet_raw, nnUNet_preprocessed, and nnUNet_results. Old scripts will break.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Update dataset.json to follow the new schema. See https://github.com/MIC-DKFZ/nnUNet/blob/master/documentation/dataset_format.md","message":"The dataset JSON format changed. The 'labels' field now uses a dictionary for old label names to new ones, and the 'modality' field must be a dict.","severity":"breaking","affected_versions":">=2.2"},{"fix":"Replace nnUNet_compile=True with torch.compile(model) in your training script.","message":"The use of 'nnUNet_compile' flag is deprecated. Use PyTorch's torch.compile directly.","severity":"deprecated","affected_versions":">=2.7"},{"fix":"Use Linux (Ubuntu) or WSL2. Ensure short paths (e.g., C:\\nnunet).","message":"Training on Windows may fail due to the default CUDA memory allocation policy or path length limits. Linux is the only officially supported OS.","severity":"gotcha","affected_versions":"all"},{"fix":"Run training with torchrun: torchrun --nnodes=1 --nproc_per_node=4 --master_port=xxxx nnunetv2/run/run_training.py ...","message":"nnU-Net v2 no longer supports multi-GPU training via nnUNet_train. Use PyTorch DDP manually.","severity":"gotcha","affected_versions":">=2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install nnunetv2` or `pip install nnunetv2[all]` in your environment.","cause":"Package not installed or environment not activated.","error":"ModuleNotFoundError: No module named 'nnunetv2'"},{"fix":"Set nnUNet_raw, nnUNet_preprocessed, and nnUNet_results before importing any nnU-Net modules.","cause":"Required environment variables are missing.","error":"RuntimeError: The environment variable nnUNet_raw is not set!"},{"fix":"Use convert_MSD_dataset or manually update dataset.json per the documentation.","cause":"Dataset JSON does not follow v2 format (labels must be a dict mapping old to new label names).","error":"AssertionError: The dataset.json does not contain a 'labels' key with proper structure."},{"fix":"Run plannner.plan_and_preprocess() before training. Verify the plans file exists in nnUNet_preprocessed/DatasetXXX.","cause":"Planning step either wasn't run or produced no output.","error":"ValueError: Plans identifier 'nnUNetPlans' not found."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}