# Error during segmentation in TotalSegmentator

**URL:** https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812
**Category:** Support
**Tags:** segmentation, ai
**Created:** [February 15, 2023, 1:08am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812 "2023-02-15T01:08:55Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Luo\_Dr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luo_dr/32/11999_2.png) [@Luo\_Dr](https://discourse.slicer.org/u/Luo_Dr)
#### Post date: [February 15, 2023, 1:08am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/1 "2023-02-15T01:08:55Z")

</div>

raceback (most recent call last):  
File “/home/ubuntu/Slicer-5.3.0-2023-02-08-linux-amd64/bin/Python/slicer/util.py”, line 2973, in tryWithErrorDisplay  
yield  
File “/home/ubuntu/Slicer-5.3.0-2023-02-08-linux-amd64/NA-MIC/Extensions-31564/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 264, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “/home/ubuntu/Slicer-5.3.0-2023-02-08-linux-amd64/NA-MIC/Extensions-31564/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 749, in process  
self.logProcessOutput(proc)  
File “/home/ubuntu/Slicer-5.3.0-2023-02-08-linux-amd64/NA-MIC/Extensions-31564/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 656, in logProcessOutput  
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)  
subprocess.CalledProcessError: Command ‘[’/home/ubuntu/Slicer-5.3.0-2023-02-08-linux-amd64/bin/…/bin/PythonSlicer’, ‘/home/ubuntu/Slicer-5.3.0-2023-02-08-linux-amd64/lib/Python/bin/TotalSegmentator’, ‘-i’, ‘/tmp/Slicer-ubuntu/\_\_SlicerTemp\_\_2023-02-15\_08+53+07.525/total-segmentator-input.nii’, ‘-o’, ‘/tmp/Slicer-ubuntu/\_\_SlicerTemp\_\_2023-02-15\_08+53+07.525/segmentation’, ‘–ml’, ‘–task’, ‘total’]’ returned non-zero exit status 120.

---

<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:24am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/2 "2023-02-15T05:24:15Z")

</div>

This usually means that CUDA version is incorrect. See more details here:

> [@TotalSegmentator fails with error 120](https://discourse.slicer.org/t/totalsegmentator-fails-with-error-120/27130):
>
> 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: ![Luo\_Dr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luo_dr/32/11999_2.png) [@Luo\_Dr](https://discourse.slicer.org/u/Luo_Dr)
#### Post date: [February 15, 2023, 7:05am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/3 "2023-02-15T07:05:18Z")

</div>

I used CUDA 11.6,it could not work.But,when i changed the version to 11.7, the results were the same.

---

<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, 7:11am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/4 "2023-02-15T07:11:24Z")

</div>

Both CUDA 11.6 and 11.7 work on Windows an Linux. Remove your Slicer installation and reinstall Slicer from scratch, then install the TotalSegmentator extension, following the [TotalSegmentaor setup instructions](https://github.com/lassoan/SlicerTotalSegmentator#setup) word by word.

---

<div class="post-metadata">

### Author: ![Luo\_Dr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luo_dr/32/11999_2.png) [@Luo\_Dr](https://discourse.slicer.org/u/Luo_Dr)
#### Post date: [February 15, 2023, 8:21am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/5 "2023-02-15T08:21:07Z")

</div>

@lassoan sorry,there was some trouble with me. I could not unintall 3dslicer in my computer which operation system was ubantu.I had try to remove it by using some progames,such as ‘sudo apt-get remove ’，sudo apt-get purge .But all of these i have done ended in failure.

---

<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, 8:55pm UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/6 "2023-02-15T20:55:20Z")

</div>

On Linux, Slicer is installed by simply unpacking the installation package into a folder. You can uninstall Slicer by deleting all the files in that folder.

---

<div class="post-metadata">

### Author: ![Luo\_Dr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luo_dr/32/11999_2.png) [@Luo\_Dr](https://discourse.slicer.org/u/Luo_Dr)
#### Post date: [March 2, 2023, 1:48am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/7 "2023-03-02T01:48:30Z")

</div>

It still could not work, 🥵  
Can you remotely control my computer to solve this problem? I found out that this extension doesn’t work in China

 ![2023-03-02 08-41-16屏幕截图](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/6/961b6b8f75bb67cfc585850cd56f0d713fcf3dfc.png)

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [March 2, 2023, 3:16am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/8 "2023-03-02T03:16:03Z")

</div>

Please make sure you install the pytorch extension first and run the module prior to trying the totalsegmentator.

---

<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: [March 3, 2023, 6:20am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/9 "2023-03-03T06:20:26Z")

</div>

Currently, PyTorch is not compatible with CUDA 12.0 (only with 11.6 and 11.7). See compatible versions [here](https://pytorch.org/get-started/locally/).

Delete the entire Slicer installation folder, unpack the Slicer install package, install a compatible CUDA version, then install pytorch manually as @muratmaga suggested, for example, like this:

```
pip_install("torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117")

```

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [March 3, 2023, 6:09pm UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/10 "2023-03-03T18:09:01Z")

</div>

> [@lassoan](#):
>
> Delete the entire Slicer installation folder, unpack the Slicer install package, install a compatible CUDA version, then install pytorch manually as @muratmaga suggested, for example, like this:

Actually in my experience, with new Nvidia drivers on Ubuntu you do NOT need to install CUDA. Just run the pytorch module, and choose automatic install and see that it bring the CUDA enabled torch. In fact if the CUDA 10.2 installed in the LD\_LIBRARY\_PATH, that might be interfering with the correct install.

---

<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: [March 3, 2023, 6:40pm UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/11 "2023-03-03T18:40:35Z")

</div>

The code snippet I provided is from the PyTorch website - [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)  
I still recommend to follow those instructions if anyone runs into trouble with Slicer’s automatic PyTorch installation. How you get CUDA is another matter, it depends on your operating system and drivers, so it is hard to give exact instructions.

> [@muratmaga](#):
>
> Actually in my experience, with new Nvidia drivers on Ubuntu you do NOT need to install CUDA

Agreed. On Linux, [PyTorch includes CUDA libraries](https://stackoverflow.com/a/62361395).

Even if system CUDA is installed, system CUDA is not used. System CUDA should not interfere with PyTorch’s CUDA libraries, but in some edge cases (e.g., incomplete PyTorch installation) having a system CUDA may make things more complicated. Therefore, I agree that it is better not to install system CUDA (if you don’t need it for other purposes).

* * *

@Luo_Dr What is important to use NVIDIA driver on your system that supports the CUDA version compatible with PyTorch. On Linux it is [currently CUDA 11.6 or 11.7](https://pytorch.org/get-started/locally/). It seems that [new NVIDIA drivers always work with older CUDA toolkit](https://docs.nvidia.com/datacenter/tesla/drivers/index.html#:~:text=The%20CUDA%20driver%20provides%20an%20API%20that%20is,toolkit.%20This%20behavior%20of%20CUDA%20is%20documented%20here.), so it may be enough to install “new enough” driver. Since NVIDIA-SMI listed compatibility with CUDA 12.0 for you, it should be compatible with the 11.6 or 11.7 CUDA binaries that are bundled with PyTorch, so I don’t know why you are getting problems. However, this problem is most likely not related to Slicer, so you can search the web on tips for installing PyTorch on Linux.

---

<div class="post-metadata">

### Author: ![Luo\_Dr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luo_dr/32/11999_2.png) [@Luo\_Dr](https://discourse.slicer.org/u/Luo_Dr)
#### Post date: [March 4, 2023, 2:00am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/12 "2023-03-04T02:00:24Z")

</div>

![2023-03-04 09-59-35屏幕截图](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/4/04e542f84c18e40d3fec09941d0f628b84579ea1.png)  
I had installed the pytorch extension

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [March 4, 2023, 2:43am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/13 "2023-03-04T02:43:40Z")

</div>

And you still get the error?

---

<div class="post-metadata">

### Author: ![Luo\_Dr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luo_dr/32/11999_2.png) [@Luo\_Dr](https://discourse.slicer.org/u/Luo_Dr)
#### Post date: [March 4, 2023, 3:25am UTC](https://discourse.slicer.org/t/error-during-segmentation-in-totalsegmentator/27812/14 "2023-03-04T03:25:31Z")

</div>

😝it can work now,thank you!
