Version 5.10.0, error in total segmentator

processing started

Writing input file to /private/var/folders/0c/gpzkc1r575xdc6jdzv6v_s6h0000gn/T/Slicer-cy/__SlicerTemp__2025-11-24_06+19+55.287/total-segmentator-input.nii

Creating segmentations with TotalSegmentator AI…

Total Segmentator arguments: [‘-i’, ‘/private/var/folders/0c/gpzkc1r575xdc6jdzv6v_s6h0000gn/T/Slicer-cy/__SlicerTemp__2025-11-24_06+19+55.287/total-segmentator-input.nii’, ‘-o’, ‘/private/var/folders/0c/gpzkc1r575xdc6jdzv6v_s6h0000gn/T/Slicer-cy/__SlicerTemp__2025-11-24_06+19+55.287/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]

No GPU detected. Running on CPU. This can be very slow. The ‘–fast’ or the `–roi_subset` option can help to reduce runtime.

If you use this tool please cite: https://pubs.rsna.org/doi/10.1148/ryai.230024

Traceback (most recent call last):

File “/Applications/Slicer.app/Contents/lib/Python/bin/TotalSegmentator”, line 8, in

sys.exit(main())

         ^^^^^^

File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/totalsegmentator/bin/TotalSegmentator.py”, line 155, in main

totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,

File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/totalsegmentator/python_api.py”, line 142, in totalsegmentator

from totalsegmentator.nnunet import nnUNet_predict_image  # this has to be after setting new env vars

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/totalsegmentator/nnunet.py”, line 29, in

from totalsegmentator.custom_trainers import nnUNetTrainer_MOSAIC_1k_QuarterLR_NoMirroring

File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/totalsegmentator/custom_trainers.py”, line 2, in

from nnunetv2.training.nnUNetTrainer.variants.data_augmentation.nnUNetTrainerNoMirroring import nnUNetTrainerNoMirroring

File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/nnunetv2/training/nnUNetTrainer/variants/data_augmentation/nnUNetTrainerNoMirroring.py”, line 26, in

from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer

File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py”, line 43, in

from torch import GradScaler

ImportError: cannot import name ‘GradScaler’ from ‘torch’ (/Applications/Slicer.app/Contents/lib/Python/lib/python3.12/site-packages/torch/_init_.py)

Traceback (most recent call last):

File “/Applications/Slicer.app/Contents/bin/Python/slicer/util.py”, line 3392, in tryWithErrorDisplay

yield

File “/Applications/Slicer.app/Contents/Extensions-34045/TotalSegmentator/lib/Slicer-5.10/qt-scripted-modules/TotalSegmentator.py”, line 309, in onApplyButton

self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),

File “/Applications/Slicer.app/Contents/Extensions-34045/TotalSegmentator/lib/Slicer-5.10/qt-scripted-modules/TotalSegmentator.py”, line 1054, in process

self.processVolume(inputFile, inputVolume,

File “/Applications/Slicer.app/Contents/Extensions-34045/TotalSegmentator/lib/Slicer-5.10/qt-scripted-modules/TotalSegmentator.py”, line 1121, in processVolume

self.logProcessOutput(proc)

File “/Applications/Slicer.app/Contents/Extensions-34045/TotalSegmentator/lib/Slicer-5.10/qt-scripted-modules/TotalSegmentator.py”, line 900, in logProcessOutput

raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)

subprocess.CalledProcessError: Command ‘[’/Applications/Slicer.app/Contents/bin/../bin/PythonSlicer’, ‘/Applications/Slicer.app/Contents/lib/Python/bin/TotalSegmentator’, ‘-i’, ‘/private/var/folders/0c/gpzkc1r575xdc6jdzv6v_s6h0000gn/T/Slicer-cy/__SlicerTemp__2025-11-24_06+19+55.287/total-segmentator-input.nii’, ‘-o’, ‘/private/var/folders/0c/gpzkc1r575xdc6jdzv6v_s6h0000gn/T/Slicer-cy/__SlicerTemp__2025-11-24_06+19+55.287/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 1.

ImportError: cannot import name ‘GradScaler’ from ‘torch’

This appears to be an issue introduced by NNunetv2 developers. This package is a dependency of TotalSegmentator.

A possible workaround is to open the NNunet Slicer module which is used for installing versions of the package. Choose to install nnunetv2<2.6 as it seems like the nnunetv2 2.6.0 version introduced this error that requires torch 2.6.0 and later for the CPU version of GradScaler.

Unfortunately, on macOS Slicer factory builds are still x86_64 builds with no native arm64 build. The latest version of torch supported on x86_64 macOS is torch 2.2.x. Slicer developers have been actively working to update a whole list of dependencies to be able to support native arm64 builds. Things are still in progress, but hopefully these type of issues on macOS will be resolved soon for users of macOS on Apple Silicon M based Macs.

Thanks for your reply. I reinstall slicer of version 5.8.1 again and problems resolved.