Skip to content

Training error: super().__init__(optimizer, current_step if current_step is not None else -1, False) TypeError: __init__() takes from 2 to 3 positional arguments but 4 were given Exception in thread Thread-4: #2983

@drZyj98

Description

@drZyj98

**Dear All,
I ran into an issue where trying to train nnUnetV2 on my windows system (3080,10G). **

(nnUnetV2) PS I:\nnUnetV2\nnUNet> nnUNetv2_plan_and_preprocess -d 99 -pl ResEncUNetPlanner --verify_dataset_integrity
Fingerprint extraction...
Dataset099_Meningioma-t1ce
Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> as reader/writer

####################
verify_dataset_integrity Done.
If you didn't see any error messages then your dataset is most likely OK!
####################

Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> as reader/writer
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [02:06<00:00, 7.89it/s]
Experiment planning...
Dropping 3d_lowres config because the image size difference to 3d_fullres is too small. 3d_fullres: [138. 167. 133.], 3d_lowres: [138, 167, 133]
2D U-Net configuration:
{'data_identifier': 'nnUNetPlans_2d', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 108, 'patch_size': (192, 160), 'median_image_size_in_voxels': array([167., 133.]), 'spacing': array([1., 1.]), 'normalization_schemes': ['ZScoreNormalization'], 'use_mask_for_norm': [True], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.ResidualEncoderUNet', 'arch_kwargs': {'n_stages': 6, 'features_per_stage': (32, 64, 128, 256, 512, 512), 'conv_op': 'torch.nn.modules.conv.Conv2d', 'kernel_sizes': ((3, 3), (3, 3), (3, 3), (3, 3), (3, 3), (3, 3)), 'strides': ((1, 1), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)), 'n_blocks_per_stage': (1, 3, 4, 6, 6, 6), 'n_conv_per_stage_decoder': (1, 1, 1, 1, 1), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm2d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': True}

Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> as reader/writer
3D fullres U-Net configuration:
{'data_identifier': 'nnUNetPlans_3d_fullres', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 2, 'patch_size': (128, 160, 112), 'median_image_size_in_voxels': array([138., 167., 133.]), 'spacing': array([1., 1., 1.]), 'normalization_schemes': ['ZScoreNormalization'], 'use_mask_for_norm': [True], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.ResidualEncoderUNet', 'arch_kwargs': {'n_stages': 6, 'features_per_stage': (32, 64, 128, 256, 320, 320), 'conv_op': 'torch.nn.modules.conv.Conv3d', 'kernel_sizes': ((3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3)), 'strides': ((1, 1, 1), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 1)), 'n_blocks_per_stage': (1, 3, 4, 6, 6, 6), 'n_conv_per_stage_decoder': (1, 1, 1, 1, 1), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm3d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': False}

Plans were saved to I:\nnUnetV2\nnUNet\DATASET\nnUNet_preprocessed\Dataset099_Meningioma-t1ce\nnUNetResEncUNetPlans.json
Preprocessing...
Preprocessing dataset Dataset099_Meningioma-t1ce
Configuration: 2d...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [01:51<00:00, 8.95it/s]
Configuration: 3d_fullres...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [02:33<00:00, 6.51it/s]
Configuration: 3d_lowres...
INFO: Configuration 3d_lowres not found in plans file nnUNetResEncUNetPlans.json of dataset Dataset099_Meningioma-t1ce. Skipping.

nnUNetResEncUNetPlans.json was created in the preprocessed file. Since 3080 only have 10G of RAM, i tried to create a trainning plan with nnUNetResEncUNetM.

(nnUnetV2) PS I:\nnUnetV2\nnUNet> nnUNetv2_plan_experiment -d 99 -pl nnUNetPlannerResEncM
Dropping 3d_lowres config because the image size difference to 3d_fullres is too small. 3d_fullres: [138. 167. 133.], 3d_lowres: [138, 167, 133]
2D U-Net configuration:
{'data_identifier': 'nnUNetPlans_2d', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 108, 'patch_size': (192, 160), 'median_image_size_in_voxels': array([167., 133.]), 'spacing': array([1., 1.]), 'normalization_schemes': ['ZScoreNormalization'], 'use_mask_for_norm': [True], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.ResidualEncoderUNet', 'arch_kwargs': {'n_stages': 6, 'features_per_stage': (32, 64, 128, 256, 512, 512), 'conv_op': 'torch.nn.modules.conv.Conv2d', 'kernel_sizes': ((3, 3), (3, 3), (3, 3), (3, 3), (3, 3), (3, 3)), 'strides': ((1, 1), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)), 'n_blocks_per_stage': (1, 3, 4, 6, 6, 6), 'n_conv_per_stage_decoder': (1, 1, 1, 1, 1), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm2d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': True}

Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> as reader/writer
3D fullres U-Net configuration:
{'data_identifier': 'nnUNetPlans_3d_fullres', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 2, 'patch_size': (128, 160, 112), 'median_image_size_in_voxels': array([138., 167., 133.]), 'spacing': array([1., 1., 1.]), 'normalization_schemes': ['ZScoreNormalization'], 'use_mask_for_norm': [True], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.ResidualEncoderUNet', 'arch_kwargs': {'n_stages': 6, 'features_per_stage': (32, 64, 128, 256, 320, 320), 'conv_op': 'torch.nn.modules.conv.Conv3d', 'kernel_sizes': ((3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3)), 'strides': ((1, 1, 1), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 1)), 'n_blocks_per_stage': (1, 3, 4, 6, 6, 6), 'n_conv_per_stage_decoder': (1, 1, 1, 1, 1), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm3d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': False}

Plans were saved to I:\nnUnetV2\nnUNet\DATASET\nnUNet_preprocessed\Dataset099_Meningioma-t1ce\nnUNetResEncUNetMPlans.json

Then i tried to train the model but errors occured

(nnUnetV2) PS I:\nnUnetV2\nnUNet> nnUNetv2_train 99 3d_fullres 0 -p nnUNetResEncUNetMPlans
Using device: cuda:0
G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\training\nnUNetTrainer\nnUNetTrainer.py:164: FutureWarning: torch.cuda.amp.GradScaler(args...) is deprecated. Please use torch.amp.GradScaler('cuda', args...) instead.
self.grad_scaler = GradScaler() if self.device.type == 'cuda' else None

#######################################################################
Please cite the following paper when using nnU-Net:
Isensee, F., Jaeger, P. F., Kohl, S. A., Petersen, J., & Maier-Hein, K. H. (2021). nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation. Nature methods, 18(2), 203-211.
#######################################################################

2026-02-01 23:55:39.253726: do_dummy_2d_data_aug: False
2026-02-01 23:55:39.257730: Using splits from existing split file: I:\nnUnetV2\nnUNet\DATASET\nnUNet_preprocessed\Dataset099_Meningioma-t1ce\splits_final.json
2026-02-01 23:55:39.266729: The split file contains 5 splits.
2026-02-01 23:55:39.280225: Desired fold for training: 0
2026-02-01 23:55:39.286231: This split has 800 training and 200 validation cases.
using pin_memory on device 0
using pin_memory on device 0
Traceback (most recent call last):
File "G:\anaconda\envs\nnUnetV2\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "G:\anaconda\envs\nnUnetV2\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "G:\anaconda\envs\nnUnetV2\Scripts\nnUNetv2_train.exe_main
.py", line 6, in
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\run\run_training.py", line 275, in run_training_entry
run_training(args.dataset_name_or_id, args.configuration, args.fold, args.tr, args.p, args.pretrained_weights,
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\run\run_training.py", line 211, in run_training
nnunet_trainer.run_training()
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\training\nnUNetTrainer\nnUNetTrainer.py", line 1362, in run_training
self.on_train_start()
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\training\nnUNetTrainer\nnUNetTrainer.py", line 906, in on_train_start
self.initialize()
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\training\nnUNetTrainer\nnUNetTrainer.py", line 223, in initialize
self.optimizer, self.lr_scheduler = self.configure_optimizers()
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\training\nnUNetTrainer\nnUNetTrainer.py", line 508, in configure_optimizers
lr_scheduler = PolyLRScheduler(optimizer, self.initial_lr, self.num_epochs)
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\nnunetv2\training\lr_scheduler\polylr.py", line 11, in init
super().init(optimizer, current_step if current_step is not None else -1, False)
TypeError: init() takes from 2 to 3 positional arguments but 4 were given
Exception in thread Thread-4:
Traceback (most recent call last):
File "G:\anaconda\envs\nnUnetV2\lib\threading.py", line 980, in _bootstrap_inner
self.run()
File "G:\anaconda\envs\nnUnetV2\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\batchgenerators\dataloading\nondet_multi_threaded_augmenter.py", line 125, in results_loop
raise e
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\batchgenerators\dataloading\nondet_multi_threaded_augmenter.py", line 103, in results_loop
raise RuntimeError("One or more background workers are no longer alive. Exiting. Please check the "
RuntimeError: One or more background workers are no longer alive. Exiting. Please check the print statements above for the actual error message
Exception in thread Thread-3:
Traceback (most recent call last):
File "G:\anaconda\envs\nnUnetV2\lib\threading.py", line 980, in _bootstrap_inner
self.run()
File "G:\anaconda\envs\nnUnetV2\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\batchgenerators\dataloading\nondet_multi_threaded_augmenter.py", line 125, in results_loop
raise e
File "G:\anaconda\envs\nnUnetV2\lib\site-packages\batchgenerators\dataloading\nondet_multi_threaded_augmenter.py", line 103, in results_loop
raise RuntimeError("One or more background workers are no longer alive. Exiting. Please check the "
RuntimeError: One or more background workers are no longer alive. Exiting. Please check the print statements above for the actual error message

The same error occured with "nnUNetv2_train 99 3d_fullres 0 -p nnUNetResEncUNetPlans ". Below are my package lists.

(nnUnetV2) PS I:\nnUnetV2\nnUNet> pip list
Package Version Build


acvl_utils 0.2.1
batchgenerators 0.25.1
batchgeneratorsv2 0.3.0
blosc2 2.5.1
certifi 2026.1.4
charset-normalizer 3.4.4
colorama 0.4.6
connected-components-3d 3.26.1
contourpy 1.3.0
cycler 0.12.1
dicom2nifti 2.6.0
dynamic_network_architectures 0.3.1
einops 0.8.2
fft-conv-pytorch 1.2.0
filelock 3.19.1
fonttools 4.60.2
fsspec 2025.10.0
future 1.0.0
graphviz 0.21
idna 3.11
imagecodecs 2024.12.30 1
ImageIO 2.37.2
importlib_resources 6.5.2
itk 5.4rc1
itk-core 5.4rc1
itk-elastix 0.18.0
itk-filtering 5.4rc1
itk-io 5.4rc1
itk-numerics 5.4rc1
itk-registration 5.4rc1
itk-segmentation 5.4rc1
Jinja2 3.1.6
joblib 1.5.3
kiwisolver 1.4.7
lazy_loader 0.4
linecache2 1.0.0
MarkupSafe 3.0.3
matplotlib 3.9.4
mpmath 1.3.0
msgpack 1.1.2
ndindex 1.10.1
networkx 3.2.1
nibabel 5.3.3
nnunetv2 2.5.2
numpy 1.24.0
packaging 26.0
pandas 2.3.3
pillow 11.3.0
pip 25.3
py-cpuinfo 9.0.0
pydicom 2.4.4
pyparsing 3.3.2
python-dateutil 2.9.0.post0
python-gdcm 3.2.2
pytz 2025.2
PyYAML 6.0.3
requests 2.32.5
scikit-image 0.24.0
scikit-learn 1.6.1
scipy 1.13.1
seaborn 0.13.2
setuptools 80.9.0
simpleitk 2.5.3
six 1.17.0
sympy 1.14.0
threadpoolctl 3.6.0
tifffile 2024.8.30
torch 2.7.0+cu118
torchaudio 2.7.0+cu118
torchvision 0.22.0+cu118
tqdm 4.67.2
traceback2 1.4.0
typing_extensions 4.15.0
tzdata 2025.3
unittest2 1.1.0
urllib3 2.6.3
wheel 0.45.1
yacs 0.1.8
zipp 3.23.0

(nnUnetV2) PS I:\nnUnetV2\nnUNet> nvidia-smi
Mon Feb 2 01:02:21 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 576.80 Driver Version: 576.80 CUDA Version: 12.9 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 3080 WDDM | 00000000:01:00.0 On | N/A |
| 30% 39C P0 80W / 320W | 1681MiB / 10240MiB | 6% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 3908 C+G ...xyewy\ShellExperienceHost.exe N/A |
| 0 N/A N/A 4116 C+G ...acted\runtime\WeChatAppEx.exe N/A |
| 0 N/A N/A 8312 C+G ....0.3719.93\msedgewebview2.exe N/A |
| 0 N/A N/A 9104 C+G ...IA app\CEF\NVIDIA Overlay.exe N/A |
| 0 N/A N/A 10668 C+G C:\Windows\explorer.exe N/A |
| 0 N/A N/A 10948 C+G ...t\Edge\Application\msedge.exe N/A |
| 0 N/A N/A 11024 C+G ...y\StartMenuExperienceHost.exe N/A |
| 0 N/A N/A 11560 C+G ...crosoft OneDrive\OneDrive.exe N/A |
| 0 N/A N/A 12272 C+G ..._cw5n1h2txyewy\SearchHost.exe N/A |
| 0 N/A N/A 14500 C+G ...IA app\CEF\NVIDIA Overlay.exe N/A |
| 0 N/A N/A 15456 C+G ...App_cw5n1h2txyewy\LockApp.exe N/A |
| 0 N/A N/A 16540 C+G ...8bbwe\PhoneExperienceHost.exe N/A |
| 0 N/A N/A 18252 C+G ...5n1h2txyewy\TextInputHost.exe N/A |
| 0 N/A N/A 19316 C+G ...lpaper_engine\wallpaper64.exe N/A |
| 0 N/A N/A 22712 C+G ...kyb3d8bbwe\EdgeGameAssist.exe N/A |
| 0 N/A N/A 23172 C+G ...t\Edge\Application\msedge.exe N/A |
| 0 N/A N/A 24428 C+G ....0.3719.93\msedgewebview2.exe N/A |
| 0 N/A N/A 29632 C+G D:\cursor\Cursor.exe N/A |
| 0 N/A N/A 31288 C+G ...ntrolPanel\SystemSettings.exe N/A |
+-----------------------------------------------------------------------------------------+

cpu
Name
12th Gen Intel(R) Core(TM) i7-12700K
NumberOfCores
12
NumberOfLogicalProcessors
20

Thanks for your support!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions