TotalSegmentator fails with error 120

Hi Lassoan

I have tried the cpu without fast option selected. It exited with status 120 after predicting part 1/5. Is there a workaround?

Thank you.

Regards
Lip Teck

Most likely your installation is corrupted. We have improved robustness of TotalSegmentator installation recently, so reinstallation from scratch may fix the problem. Please remove your Slicer installation completely, then install Slicer and TotalSegmentator again.

If it did not fix the issue then copy here the content of the window that is displayed below the “Apply” button.

Hi Lassoan,

After uninstallaing and re-installing, the fast option went well but without fast it failed with exit 120.

Here’s the slicer’s error:

Traceback (most recent call last):

File “/home/lipteck/Slicer-5.2.1-linux-amd64/bin/Python/slicer/util.py”, line 2961, in tryWithErrorDisplay

yield

File “/home/lipteck/Slicer-5.2.1-linux-amd64/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 258, in onApplyButton

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

File “/home/lipteck/Slicer-5.2.1-linux-amd64/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 647, in process

self.logProcessOutput(proc)

File “/home/lipteck/Slicer-5.2.1-linux-amd64/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 556, in logProcessOutput

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

subprocess.CalledProcessError: Command ‘[’/home/lipteck/Slicer-5.2.1-linux-amd64/bin/…/bin/PythonSlicer’, ‘/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/bin/TotalSegmentator’, ‘-i’, ‘/tmp/Slicer-lipteck/__SlicerTemp__2023-01-11_08+36+20.388/total-segmentator-input.nii’, ‘-o’, ‘/tmp/Slicer-lipteck/__SlicerTemp__2023-01-11_08+36+20.388/segmentation’, ‘–ml’, ‘–task’, ‘total’]’ returned non-zero exit status 120.

Here’s the display below apply:

Processing started

Writing input file to /tmp/Slicer-lipteck/__SlicerTemp__2023-01-11_08+36+20.388/total-segmentator-input.nii

Creating segmentations with TotalSegmentator AI…

Total Segmentator arguments: [‘-i’, ‘/tmp/Slicer-lipteck/__SlicerTemp__2023-01-11_08+36+20.388/total-segmentator-input.nii’, ‘-o’, ‘/tmp/Slicer-lipteck/__SlicerTemp__2023-01-11_08+36+20.388/segmentation’, ‘–ml’, ‘–task’, ‘total’]

/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/torch/cuda/amp/grad_scaler.py:115: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling.

warnings.warn(“torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling.”)

/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/torch/cuda/amp/autocast_mode.py:120: UserWarning: torch.cuda.amp.autocast only affects CUDA ops, but CUDA is not available. Disabling.

warnings.warn(“torch.cuda.amp.autocast only affects CUDA ops, but CUDA is not available. Disabling.”)

If you use this tool please cite: https://doi.org/10.48550/arXiv.2208.05868

No GPU detected. Running on CPU. This can be very slow. The ‘–fast’ option can help to some extend.

Resampling…

Resampled in 15.49s

Predicting part 0 of 5 …

Traceback (most recent call last):

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/bin/TotalSegmentator”, line 242, in

main()

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/bin/TotalSegmentator”, line 219, in main

seg = nnUNet_predict_image(args.input, args.output, task_id, model=model, folds=folds,

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/totalsegmentator/nnunet.py”, line 217, in nnUNet_predict_image

nnUNet_predict(tmp_dir, tmp_dir, tid, model, folds, trainer, tta)

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/totalsegmentator/nnunet.py”, line 106, in nnUNet_predict

predict_from_folder(model_folder_name, dir_in, dir_out, folds, save_npz, num_threads_preprocessing,

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/nnunet/inference/predict.py”, line 668, in predict_from_folder

return predict_cases_fastest(model, list_of_lists[part_id::num_parts], output_files[part_id::num_parts], folds,

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/nnunet/inference/predict.py”, line 468, in predict_cases_fastest

trainer, params = load_model_and_checkpoint_files(model, folds, mixed_precision=mixed_precision, checkpoint_name=checkpoint_name)

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/nnunet/training/model_restore.py”, line 140, in load_model_and_checkpoint_files

trainer = restore_model(join(folds[0], “%s.model.pkl” % checkpoint_name), fp16=mixed_precision)

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/nnunet/training/model_restore.py”, line 56, in restore_model

info = load_pickle(pkl_file)

File “/home/lipteck/Slicer-5.2.1-linux-amd64/lib/Python/lib/python3.9/site-packages/batchgenerators/utilities/file_and_folder_operations.py”, line 49, in load_pickle

with open(file, mode) as f:

FileNotFoundError: [Errno 2] No such file or directory: ‘/home/lipteck/.totalsegmentator/nnunet/results/nnUNet/3d_fullres/Task252_TotalSegmentator_part2_vertebrae_1139subj/nnUNetTrainerV2_ep4000_nomirror__nnUNetPlansv2.1/fold_0/model_final_checkpoint.model.pkl’

Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x7f4d03bec400>

AttributeError: ‘DummyFile’ object has no attribute ‘flush’

If you use this tool please cite: https://doi.org/10.48550/arXiv.2208.05868

No GPU detected. Running on CPU. This can be very slow. The ‘–fast’ option can help to some extend.

Resampling…

Resampled in 15.49s

Predicting part 0 of 5 …

Predicting part 1 of 5 …

Thank you and regards,

LipTeck

It seems that your model files download was incomplete, either due to some transient network issues or the download was interrupted.

You need to erase the /home/lipteck/.totalsegmentator/ folder and start again.

This indicates that there is an issue with your CUDA installation. Currently, pytorch supports CUDA 11.6 and 11.7 on Linux, for best compatibility install one of these CUDA versions. Then check if CUDA version shown in PyTorchUtils module in Slicer matches the installed CUDA version.

Hi Lassoan

I removed the .totalsegmentator in my home directory with rm -rf command and it is now working.

Thank you!

By the way, is there any plan to segment structures - the organs at risk frequently used in radiation treatment planning by body section?

Regards
Lip Teck

1 Like

We are planning a session at the upcoming Project Week to discuss TotalSegmentator and related machine learning segmentation tools, so you may want to join that discussion to see where things are headed and add your wishlist for future segmentation features.

1 Like

A post was split to a new topic: Create derived segments with AAPM nomenclature form TotalSegmentator output