Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix torch not installed through PyTorchUtils #65

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions TotalSegmentator/TotalSegmentator.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,21 +739,6 @@ def setupPythonRequirements(self, upgrade=False):
'rt_utils', # Only needed for RTSTRUCT export, which is not needed in Slicer; rt_utils depends on opencv-python which is hard to build
]

# acvl_utils workaround - start
# Recent versions of acvl_utils are broken (https://github.com/MIC-DKFZ/acvl_utils/issues/2).
# As a workaround, we install an older version manually. This workaround can be removed after acvl_utils is fixed.
packagesToSkip.append("acvl_utils")
needToInstallAcvlUtils = True
try:
if packaging.version.parse(importlib.metadata.version("acvl_utils")) == packaging.version.parse("0.2"):
# A suitable version is already installed
needToInstallAcvlUtils = False
except Exception as e:
pass
if needToInstallAcvlUtils:
slicer.util.pip_install("acvl_utils==0.2")
# acvl_utils workaround - end

# Install PyTorch
try:
import PyTorchUtils
Expand All @@ -775,6 +760,23 @@ def setupPythonRequirements(self, upgrade=False):
+ f' Minimum required version is {minimumTorchVersion}. You can use "PyTorch Util" module to install PyTorch'
+ f' with version requirement set to: >={minimumTorchVersion}')

# acvl_utils workaround - start
# Recent versions of acvl_utils are broken (https://github.com/MIC-DKFZ/acvl_utils/issues/2).
# As a workaround, we install an older version manually. This workaround can be removed after acvl_utils is fixed.
# acvl_utils==0.2 has a dependency on torch so install acvl_utils should happen after installing torch using PyTorchutils
# https://github.com/MIC-DKFZ/acvl_utils/blob/fe9c8abe8b3c6a63c24f636f8815b6f45ce77dfb/setup.py#L11-L18
packagesToSkip.append("acvl_utils")
needToInstallAcvlUtils = True
try:
if packaging.version.parse(importlib.metadata.version("acvl_utils")) == packaging.version.parse("0.2"):
# A suitable version is already installed
needToInstallAcvlUtils = False
except Exception as e:
pass
if needToInstallAcvlUtils:
slicer.util.pip_install("acvl_utils==0.2")
# acvl_utils workaround - end

# Install TotalSegmentator with selected dependencies only
# (it would replace Slicer's "requests")
needToInstallSegmenter = False
Expand Down