# TotalSegmentator fails with error 120

**URL:** <https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130>\
**Category:** Support\
**Tags:** segmentation, ai\
**Created:** [January 9, 2023, 5:49am UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130 "2023-01-09T05:49:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LipTeck\_Chew](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lipteck_chew/32/13519_2.png) [@LipTeck\_Chew](https://discourse.slicer.org/u/LipTeck_Chew)\
**Post date:** [January 9, 2023, 5:49am UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/1 "2023-01-09T05:49:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 9, 2023, 2:17pm UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/2 "2023-01-09T14:17:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![LipTeck\_Chew](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lipteck_chew/32/13519_2.png) [@LipTeck\_Chew](https://discourse.slicer.org/u/LipTeck_Chew)\
**Post date:** [January 11, 2023, 12:51am UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/3 "2023-01-11T00:51:13Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 11, 2023, 3:11am UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/4 "2023-01-11T03:11:19Z")

</div>

> [@LipTeck\_Chew](#):
>
> 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’

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.

> [@LipTeck\_Chew](#):
>
> No GPU detected. Running on CPU. This can be very slow.

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.

---

<div class="post-metadata">

**Author:** ![LipTeck\_Chew](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lipteck_chew/32/13519_2.png) [@LipTeck\_Chew](https://discourse.slicer.org/u/LipTeck_Chew)\
**Post date:** [January 12, 2023, 9:13am UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/5 "2023-01-12T09:13:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 12, 2023, 1:42pm UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/6 "2023-01-12T13:42:10Z")

</div>

We are planning a session at the upcoming [Project Week](https://projectweek.na-mic.org/PW38_2023_GranCanaria/) 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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 15, 2023, 5:12am UTC](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130/7 "2023-02-15T05:12:30Z")

</div>

A post was split to a new topic: [Create derived segments with AAPM nomenclature form TotalSegmentator output](https://discourse.slicer.org/t/create-derived-segments-with-aapm-nomenclature-form-totalsegmentator-output/27817)
