wasserth / TotalSegmentator

Tool for robust segmentation of >100 important anatomical structures in CT and MR images
Apache License 2.0
1.42k stars 239 forks source link

PyTorch module not found #345

Open gleesoi opened 1 month ago

gleesoi commented 1 month ago

Hi I tried to install and run but it's giving me errors below. Am using windows 10 and cpu and I pip installed it with and without PyTorch. Wondering if this is known issue and any solution? ChatGPT mentions that PyTorch on Windows often requires the Microsoft Visual C++ Redistributable package?? I will try again with different torch version maybe but it appears once I install total segmentation torch 2.4 comes in.

The error message you're encountering, OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\glees\Desktop\TotalSegmentator\totalseg\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies., indicates that a required DLL file or one of its dependencies for PyTorch could not be loaded.

This can often be due to missing dependencies or incompatible versions

wasserth commented 1 month ago

Unfortunately I am not familiar with windows details. My test installation on windows is working.

gleesoi commented 1 month ago

ok got this working. i think its a torch 2.4 issue and some forums recently talking about same thing! this torch version comes in naturally when pip installing TotalSegmentator for me. so below worked for me:

python -m venv venv venv\Scripts\activate python -m pip install --upgrade pip pip install TotalSegmentator this brings in torch 2.4 anyways pip uninstall torch and say yes to its other things pip install torch==2.1.0 i tried this version first..... i get errors about nnunet needs torch >=2.1.2 and I have 2.1.0 so….. pip uninstall torch 2.1.0 pip install torch==2.1.2

run my script(dicom ct) using fastest option 6mm resolution – took ~37minutes for 6 rois subset !!

seems far too long to be used practically . when i run within 3dslicer ,total task fast completes within 3mins....?

wasserth commented 1 month ago

Great that it works now! Maybe 3d Slicer is using your GPU (if you have one) or it is using the --fast option or the --roi_subset option ?

gleesoi commented 3 weeks ago

I don't have a gpu and slicer seems much quicker even when doing lots more rois.used fast options for both. not sure why big difference

clead6 commented 2 weeks ago

Hi, I ran into the same issue described above with the torch version, 2.4 is not compatible. I uninstalled and resintalled torch version 2.1.2 which worked. It would be useful if you modified the torch requirement so it gets installed properly

wasserth commented 2 weeks ago

Thanks for the report. On Linux and Mac this error does not occur therefore I do not really want to not allow pytorch 2.4 for those users. But it will add a note somewhere such that users are aware.

simzhangbest commented 1 week ago

【使用TotalSegment 模块 在3D Slicer中分割人体所有器官和骨骼】 https://www.bilibili.com/video/BV1m1421m7f2/?share_source=copy_web&vd_source=0e576be21554bb1ea5d13280e520d904

watch my video, you can fix your issues yourself