--- a/src/diffusers/utils/import_utils.py +++ b/src/diffusers/utils/import_utils.py @@ -97,6 +97,11 @@ if USE_TORCH in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TF not in ENV_VARS_TRUE_VALUES: _torch_available, _torch_version = _is_package_available("torch") + # Gentoo slotted pytorch: importlib.metadata may not find version + if _torch_available and _torch_version is None: + import torch + _torch_version = torch.__version__ + else: logger.info("Disabling PyTorch because USE_TORCH is set") _torch_available = False