environment
- sentence_transformers.util.environment.check_package_availability(package_name: str, owner: str) bool
Checks if a package is available from the correct owner.
- sentence_transformers.util.environment.get_device_name() str
Returns the name of the device where this module is running on.
This function only supports single device or basic distributed training setups. In distributed mode for cuda device, it uses the rank to assign a specific CUDA device.
- Returns:
Device name, like ‘cuda:2’, ‘mps’, ‘npu’, ‘xpu’, ‘hpu’, or ‘cpu’
- Return type:
str
- sentence_transformers.util.environment.is_accelerate_available() bool
Returns True if the Huggingface accelerate library is available.
- sentence_transformers.util.environment.is_datasets_available() bool
Returns True if the Huggingface datasets library is available.
- sentence_transformers.util.environment.is_dist_initialized() bool
Returns whether
torch.distributedis available and has been initialized.The availability check must come first: some PyTorch builds (e.g. ROCm or CPU-only) report
torch.distributed.is_available() == Falseand do not expose APIs likeis_initialized, so calling them directly raisesAttributeError.
- sentence_transformers.util.environment.is_training_available() bool
Returns True if we have the required dependencies for training Sentence Transformers models, i.e. Huggingface datasets and Huggingface accelerate.
- sentence_transformers.util.environment.suggest_extra_on_exception() Generator[None, None, None]
Re-raise ImportError/AttributeError with an install hint when a multimodal dependency is missing.