Error while installing pytorch

Hii,
I am having trouble applying the module in slicer 5.2.1. When i press apply, it says pytorch will be installed using light-the-torch. After few seconds, i get the error: failed to compute results, no module named torch.
Detailed error:
Traceback (most recent call last):
File “E:\apps\Slicer 5.2.1\bin\Python\slicer\util.py”, line 2961, in tryWithErrorDisplay
yield
File “E:/apps/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 248, in onApplyButton
self.logic.setupPythonRequirements()
File “E:/apps/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 494, in setupPythonRequirements
torch = torchLogic.installTorch(askConfirmation=True)
File “E:/apps/Slicer 5.2.1/NA-MIC/Extensions-31317/PyTorch/lib/Slicer-5.2/qt-scripted-modules/PyTorchUtils.py”, line 188, in installTorch
import torch
ModuleNotFoundError: No module named ‘torch’

Please let me know what am i doing wrong.

1 Like

Could you please install the PyTorch extension

image

and restart Slicer ?

Thanks, but it is already installed and doesn’t make a difference :confused:

If you are on Windows, could you please try to install TotalSegmentator from the command line (cmd.exe):

"C:\Users\yourname\AppData\Local\NA-MIC\Slicer 5.2.1\bin/PythonSlicer.EXE" -m pip install git+https://github.com/wasserth/TotalSegmentator.git --no-deps

and post the results?

I’ve made improvements to the PyTorch extension. Please update it using the Extensions Manager. You can then open PyTorch Utils module and first click Uninstall pytorch to remove any incomplete installs and then click Install pytorch to properly install it.

3 Likes

Thank you, reinstalling pytorch worked :slight_smile:

1 Like

Very useful. Thank you

Can I use a computer with more than one GPU with total segmentator? I have de same problem with te pytorch, but nothing works for me, I try uninstall, and re insatall again, but does not work., Thank you!

It should be no problem at all. You should be able to install and use pytorch in Slicer’s Python environment the same way as any other Python requirements. If you work on a laptop with discrete NVIDIA GPU then make sure that in your NVIDIA settings Slicer executable (SlicerApp-real.exe) is assigned to use the high-performance GPU.

If you need further help please provide the full application log of a pytorch installation from scratch:

  • install latest Slicer Preview Release into a new folder
  • start this newly installed Slicer
  • install pytorch extension, restart Slicer
  • install torch using the PyTorch Utils module, go to menu: Help / Report a bug, save the full application log into a file, upload that file somewhere (dropbox, onedrive, etc.) and post the link here

Hi! I downloaded the last version, and installed Total Segmentator., but when I want to apply for segmentations, try to download pytorch and fails. Here the log Slicer_5.7.0-2024-04-12_32805_20240415_204438_406.log - Google Drive
Thank you in advance!

I could already install pytorch by adding time in the default timeout:

slicer.util.pip_install('--default-timeout=100 torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121')

I have pytorch installed but still cant use Totalsegmentator. It downloads model for task 294, and when its done the installation cant be done and errors appears:

Traceback (most recent call last):
  File "C:\ProgramData\slicer.org\Slicer 5.7.0-2024-04-12\bin\Python\slicer\util.py", line 3295, in tryWithErrorDisplay
    yield
  File "C:/ProgramData/slicer.org/Slicer 5.7.0-2024-04-12/slicer.org/Extensions-32805/TotalSegmentator/lib/Slicer-5.7/qt-scripted-modules/TotalSegmentator.py", line 292, in onApplyButton
    self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
  File "C:/ProgramData/slicer.org/Slicer 5.7.0-2024-04-12/slicer.org/Extensions-32805/TotalSegmentator/lib/Slicer-5.7/qt-scripted-modules/TotalSegmentator.py", line 975, in process
    self.logProcessOutput(proc)
  File "C:/ProgramData/slicer.org/Slicer 5.7.0-2024-04-12/slicer.org/Extensions-32805/TotalSegmentator/lib/Slicer-5.7/qt-scripted-modules/TotalSegmentator.py", line 795, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/ProgramData/slicer.org/Slicer 5.7.0-2024-04-12/bin/../bin\\PythonSlicer.EXE', 'C:\\ProgramData\\slicer.org\\Slicer 5.7.0-2024-04-12\\lib\\Python\\Scripts\\TotalSegmentator.exe', '-i', 'C:/Users/Familia Larragueta/AppData/Local/Temp/Slicer/__SlicerTemp__2024-04-17_16+11+21.925/total-segmentator-input.nii', '-o', 'C:/Users/Familia Larragueta/AppData/Local/Temp/Slicer/__SlicerTemp__2024-04-17_16+11+21.925/segmentation', '--ml', '--task', 'total']' returned non-zero exit status 1.

Thank you!!!

You may find more information in the process output. Check both the text window in the TotalSegmentator module and the Slicer application log.

Greetings,

I’m using the current latest stable version Slicer 5.6.2. I have quite the similar issue mentioned above. During the use of an extension MONAI Auto3DSeg when I press apply It says:
PyTorch will be downloaded and installed using light-the-torch (ltt install torch>=1.12 torchvision)

After some time an error occurs:
Failed to install required dependencies. No module named ‘torch’

Error details:
Traceback (most recent call last):
File “D:\Slicer 5.6.2\bin\Python\slicer\util.py”, line 3255, in tryWithErrorDisplay
yield
File “D:/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py”, line 505, in onApply
self.logic.setupPythonRequirements()
File “D:/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py”, line 1062, in setupPythonRequirements
torch = torchLogic.installTorch(askConfirmation=True, torchVersionRequirement = f">={minimumTorchVersion}")
File “D:/Slicer 5.6.2/slicer.org/Extensions-32448/PyTorch/lib/Slicer-5.6/qt-scripted-modules/PyTorchUtils.py”, line 225, in installTorch
import torch
ModuleNotFoundError: No module named ‘torch’

I’ve already tried to reinstall slicer from the scratch, reinstall extensions PyTorch and MONAI Auto3DSeg from the extenions manager, change computation backened to CPU and I also have more than 20gb of free space on the disk. None of these possibilities solved the problem.

I’ll be very grateful for your help.

You can try to install the PyTorch extension and run it yourself to get more diagnostic information about why Torch is not being installed).

Just choose auto the method…

If it work, go ahead and reinstall the auto3Dseg one more time.

I tried to install PyTorch directly in the module and it shows error:
Failed to install PyTorch. Some PyTorch files may be in use or corrupted. Please restart the application, uninstall PyTorch, and try installing again.
No module named ‘torch’

Error details:
Traceback (most recent call last):
File “D:\Slicer 5.6.2\bin\Python\slicer\util.py”, line 3255, in tryWithErrorDisplay
yield
File “D:/Slicer 5.6.2/slicer.org/Extensions-32448/PyTorch/lib/Slicer-5.6/qt-scripted-modules/PyTorchUtils.py”, line 78, in onInstallTorch
torch = self.logic.installTorch(askConfirmation, None if automaticBackend else backend, torchVersionRequirement, torchvisionVersionRequirement)
File “D:/Slicer 5.6.2/slicer.org/Extensions-32448/PyTorch/lib/Slicer-5.6/qt-scripted-modules/PyTorchUtils.py”, line 225, in installTorch
import torch
ModuleNotFoundError: No module named ‘torch’

Please restart the application, uninstall PyTorch, and try installing again. If you still experience any problems then copy here the application log of the session in that you tried to install pytorch.

Restarting the application and reinstalling PyTorch didnt help. There’s the full application log of the error session you asked:

[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Session start time …: 20240915_225204
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Slicer version …: 5.6.2 (revision 32448 / f10cd8c) win-amd64 - installed release
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Operating system …: Windows / Professional / (Build 19045, Code Page 65001) - 64-bit
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Memory …: 16343 MB physical, 16343 MB virtual
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - CPU …: GenuineIntel , 4 cores, 4 logical processors
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - VTK configuration …: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Qt configuration …: version 5.15.2, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Internationalization …: disabled, language=
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Developer mode …: disabled
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Application path …: C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/bin
[DEBUG][Qt] 15.09.2024 22:52:04 (unknown:0) - Additional module paths …: slicer.org/Extensions-32448/PyTorch/lib/Slicer-5.6/qt-scripted-modules, slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules
[DEBUG][Python] 15.09.2024 22:52:08 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Slicer-5.6\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:39) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 15.09.2024 22:52:08 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Slicer-5.6\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:39) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 15.09.2024 22:52:08 (unknown:0) - Switch to module: “Welcome”
[DEBUG][Qt] 15.09.2024 22:52:14 (unknown:0) - Switch to module: “SampleData”
[DEBUG][Python] 15.09.2024 22:52:18 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/bin/…/lib/Slicer-5.6/qt-scripted-modules/SampleData.py:384) - Verifying checksum
[DEBUG][Python] 15.09.2024 22:52:18 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/bin/…/lib/Slicer-5.6/qt-scripted-modules/SampleData.py:384) - File already exists and checksum is OK - reusing it.
[DEBUG][Python] 15.09.2024 22:52:18 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/bin/…/lib/Slicer-5.6/qt-scripted-modules/SampleData.py:384) - Requesting load CTChest from C:/Users/12345/AppData/Local/slicer.org/Slicer/cache/SlicerIO/CT-chest.nrrd …
[DEBUG][Qt] 15.09.2024 22:52:19 (unknown:0) - “Volume” Reader has successfully read the file “C:/Users/12345/AppData/Local/slicer.org/Slicer/cache/SlicerIO/CT-chest.nrrd” “[0.72s]”
[DEBUG][Python] 15.09.2024 22:52:19 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/bin/…/lib/Slicer-5.6/qt-scripted-modules/SampleData.py:384) - Load finished
[DEBUG][Qt] 15.09.2024 22:52:26 (unknown:0) - Switch to module: “MONAIAuto3DSeg”
[INFO][Python] 15.09.2024 22:52:34 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py:1036) - Initializing PyTorch…
[INFO][Python] 15.09.2024 22:52:34 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py:1036) - PyTorch Python package is required. Installing… (it may take several minutes)
[INFO][Python] 15.09.2024 22:52:34 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\bin\Python\slicer\util.py:3009) - PyTorch will be downloaded and installed using light-the-torch (ltt install torch>=1.12 torchvision). The process might take some minutes.
[INFO][Python] 15.09.2024 22:52:36 [Python] (C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/PyTorch/lib/Slicer-5.6/qt-scripted-modules/PyTorchUtils.py:216) - Install PyTorch using light-the-torch with arguments: [‘install’, ‘torch>=1.12’, ‘torchvision’]
[INFO][Stream] 15.09.2024 22:52:40 (unknown:0) - Collecting light-the-torch>=0.5
[INFO][Stream] 15.09.2024 22:52:40 (unknown:0) - Using cached light_the_torch-0.7.5-py3-none-any.whl.metadata (9.5 kB)
[INFO][Stream] 15.09.2024 22:52:40 (unknown:0) - Collecting pip<23.3,>=22.3 (from light-the-torch>=0.5)
[INFO][Stream] 15.09.2024 22:52:40 (unknown:0) - Using cached pip-23.2.1-py3-none-any.whl.metadata (4.2 kB)
[INFO][Stream] 15.09.2024 22:52:40 (unknown:0) - Using cached light_the_torch-0.7.5-py3-none-any.whl (14 kB)
[INFO][Stream] 15.09.2024 22:52:40 (unknown:0) - Using cached pip-23.2.1-py3-none-any.whl (2.1 MB)
[INFO][Stream] 15.09.2024 22:52:41 (unknown:0) - Installing collected packages: pip, light-the-torch
[INFO][Stream] 15.09.2024 22:52:41 (unknown:0) - Attempting uninstall: pip
[INFO][Stream] 15.09.2024 22:52:41 (unknown:0) - Found existing installation: pip 23.3
[INFO][Stream] 15.09.2024 22:52:41 (unknown:0) - Uninstalling pip-23.3:
[INFO][Stream] 15.09.2024 22:52:41 (unknown:0) - Successfully uninstalled pip-23.3
[INFO][Stream] 15.09.2024 22:52:47 (unknown:0) - WARNING: The scripts pip.exe, pip3.9.exe and pip3.exe are installed in ‘C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Scripts’ which is not on PATH.
[INFO][Stream] 15.09.2024 22:52:47 (unknown:0) - Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
[INFO][Stream] 15.09.2024 22:52:47 (unknown:0) - WARNING: The script ltt.exe is installed in ‘C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Scripts’ which is not on PATH.
[INFO][Stream] 15.09.2024 22:52:47 (unknown:0) - Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
[INFO][Stream] 15.09.2024 22:52:47 (unknown:0) - Successfully installed light-the-torch-0.7.5 pip-23.2.1
[DEBUG][Python] 15.09.2024 22:52:48 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\vcs\versioncontrol.py:225) - Registered VCS backend: bzr
[DEBUG][Python] 15.09.2024 22:52:48 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\vcs\versioncontrol.py:225) - Registered VCS backend: git
[DEBUG][Python] 15.09.2024 22:52:48 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\vcs\versioncontrol.py:225) - Registered VCS backend: hg
[DEBUG][Python] 15.09.2024 22:52:48 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\vcs\versioncontrol.py:225) - Registered VCS backend: svn
[INFO][Stream] 15.09.2024 22:53:00 (unknown:0) - Collecting torch>=1.12
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - ERROR: Exception:
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - Traceback (most recent call last):
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\cli\base_command.py”, line 180, in exc_logging_wrapper
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - status = run_func(*args)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\cli\req_command.py”, line 248, in wrapper
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return func(self, options, args)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\commands\install.py”, line 377, in run
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - requirement_set = resolver.resolve(
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\light_the_torch_utils.py”, line 103, in new
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - output = fn(*args, **kwargs)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\resolver.py”, line 92, in resolve
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - result = self._result = resolver.resolve(
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 546, in resolve
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - state = resolution.resolve(requirements, max_rounds=max_rounds)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 397, in resolve
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - self._add_to_criteria(self.state.criteria, r, parent=None)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 173, in _add_to_criteria
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - if not criterion.candidates:
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\resolvelib\structs.py”, line 156, in bool
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return bool(self._sequence)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py”, line 155, in bool
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return any(self)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py”, line 143, in
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return (c for c in iterator if id(c) not in self._incompatible_ids)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py”, line 47, in _iter_built
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - candidate = func()
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\factory.py”, line 206, in _make_candidate_from_link
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - self._link_candidate_cache[link] = LinkCandidate(
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 293, in init
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - super().init(
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 156, in init
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - self.dist = self._prepare()
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 225, in _prepare
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - dist = self._prepare_distribution()
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 304, in _prepare_distribution
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\operations\prepare.py”, line 538, in prepare_linked_requirement
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return self._prepare_linked_requirement(req, parallel_builds)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\operations\prepare.py”, line 609, in _prepare_linked_requirement
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - local_file = unpack_url(
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\operations\prepare.py”, line 166, in unpack_url
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - file = get_http_url(
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\operations\prepare.py”, line 107, in get_http_url
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - from_path, content_type = download(link, temp_dir.path)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\network\download.py”, line 134, in call
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - resp = _http_get_download(self._session, link)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\network\download.py”, line 117, in _http_get_download
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - resp = session.get(target_url, headers=HEADERS, stream=True)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\requests\sessions.py”, line 602, in get
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return self.request(“GET”, url, **kwargs)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_internal\network\session.py”, line 519, in request
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return super().request(method, url, *args, **kwargs)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\requests\sessions.py”, line 589, in request
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - resp = self.send(prep, **send_kwargs)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\requests\sessions.py”, line 703, in send
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - r = adapter.send(request, **kwargs)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\cachecontrol\adapter.py”, line 48, in send
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - cached_response = self.controller.cached_request(request)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\cachecontrol\controller.py”, line 155, in cached_request
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - resp = self.serializer.loads(request, cache_data, body_file)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\cachecontrol\serialize.py”, line 95, in loads
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - return getattr(self, “_loads_v{}”.format(ver))(request, data, body_file)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\cachecontrol\serialize.py”, line 186, in _loads_v4
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - cached = msgpack.loads(data, raw=False)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\msgpack\fallback.py”, line 125, in unpackb
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - ret = unpacker._unpack()
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\msgpack\fallback.py”, line 590, in _unpack
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - ret[key] = self._unpack(EX_CONSTRUCT)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\msgpack\fallback.py”, line 590, in _unpack
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - ret[key] = self._unpack(EX_CONSTRUCT)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\msgpack\fallback.py”, line 544, in _unpack
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - typ, n, obj = self._read_header()
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\msgpack\fallback.py”, line 486, in _read_header
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - obj = self._read(n)
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - File “C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\pip_vendor\msgpack\fallback.py”, line 403, in _read
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - ret = self._buffer[i : i + n]
[INFO][Stream] 15.09.2024 22:53:02 (unknown:0) - MemoryError
[ERROR][Python] 15.09.2024 22:53:03 [Python] (C:\Users\12345\AppData\Local\slicer.org\Slicer 5.6.2\bin\Python\slicer\util.py:3009) - Failed to install required dependencies.

No module named ‘torch’
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - Traceback (most recent call last):
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - File “C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py”, line 494, in onApplyButton
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - self.onApply()
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - File “C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py”, line 505, in onApply
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - self.logic.setupPythonRequirements()
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - File “C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAIAuto3DSeg/lib/Slicer-5.6/qt-scripted-modules/MONAIAuto3DSeg.py”, line 1062, in setupPythonRequirements
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - torch = torchLogic.installTorch(askConfirmation=True, torchVersionRequirement = f">={minimumTorchVersion}")
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - File “C:/Users/12345/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/PyTorch/lib/Slicer-5.6/qt-scripted-modules/PyTorchUtils.py”, line 225, in installTorch
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - import torch
[CRITICAL][Stream] 15.09.2024 22:53:10 (unknown:0) - ModuleNotFoundError: No module named ‘torch’

Thanks, thia was very useful. This shows the exact cause of the error:

So, you have ran out of memory RAM while unpacking pytorch. It means that your computer has very low amount of available memory, because it has small physical RAM (such as 8GB or less) and there is not enough free disk space either (and so the operating system does not want to allocate more virtual memory). You need to fix this not just for the installation but becaues you will need to have at least about 16GB memory space (physical+virtual memory) for the automatic segmentation, too.

Solution: If you are running some applications that use lots of memory (e.g., you have a web browser with 50 tabs open) then close them and try again. If you still get MemoryError then increase the virtual memory size. You can achieve that by freeing up lots of disk space (then Windows will allocate some of the free disk space as virtual memory) or manually allocate more virtual memory in your Windows system settings (I would recommend at least 30GB).

1 Like

You were absolutely right with that solution sir. Freeing up more disk space and simultaneously allocating more virtual memory than were the original preset values in Windows system settings finally allowed to install PyTorch Utils (Torch and TorchVision) successfully. Extension MONAI Auto3DSeg is now working flawlessly.

Thank you very much for your help, time and patience

2 Likes