environment

sentence_transformers.util.environment.check_package_availability(package_name: str, owner: str) bool[source]

Checks if a package is available from the correct owner.

sentence_transformers.util.environment.get_device_name() str[source]

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[source]

Returns True if the Huggingface accelerate library is available.

sentence_transformers.util.environment.is_datasets_available() bool[source]

Returns True if the Huggingface datasets library is available.

sentence_transformers.util.environment.is_training_available() bool[source]

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][source]

Re-raise ImportError/AttributeError with an install hint when a multimodal dependency is missing.