Error during segmentation in TotalSegmentator

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.

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

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

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 word by word.

@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.

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.

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

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

Currently, PyTorch is not compatible with CUDA 12.0 (only with 11.6 and 11.7). See compatible versions here.

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")

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.

The code snippet I provided is from the PyTorch website - 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.

Agreed. On Linux, PyTorch includes CUDA libraries.

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. It seems that new NVIDIA drivers always work with older CUDA toolkit, 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.

2023-03-04 09-59-35屏幕截图
I had installed the pytorch extension

And you still get the error?

:stuck_out_tongue_closed_eyes:it can work now,thank you!

2 Likes