chroma-core/chroma · error · ValueError

Preferred providers must be subset of available providers: {

Error message

Preferred providers must be subset of available providers: {self.ort.get_available_providers()}

What it means

When building the ONNX InferenceSession, ONNXMiniLM_L6_V2 checks that every entry of _preferred_providers is in self.ort.get_available_providers() and raises ValueError listing the available set otherwise. Availability depends on the onnxruntime build: plain `onnxruntime` only offers CPUExecutionProvider, while CUDA/TensorRT need onnxruntime-gpu and CoreML needs the macOS package. A mismatch usually means the wrong onnxruntime variant is installed for the requested provider.

Source

Thrown at chromadb/utils/embedding_functions/onnx_mini_lm_l6_v2.py:235

    @cached_property
    def model(self) -> Any:
        """
        Get the model.

        Returns:
            The model.
        """
        if self._preferred_providers is None or len(self._preferred_providers) == 0:
            if len(self.ort.get_available_providers()) > 0:
                logger.debug(
                    f"WARNING: No ONNX providers provided, defaulting to available providers: "
                    f"{self.ort.get_available_providers()}"
                )
            self._preferred_providers = self.ort.get_available_providers()
        elif not set(self._preferred_providers).issubset(
            set(self.ort.get_available_providers())
        ):
            raise ValueError(
                f"Preferred providers must be subset of available providers: {self.ort.get_available_providers()}"
            )

        # Suppress onnxruntime warnings
        so = self.ort.SessionOptions()
        so.log_severity_level = 3
        so.graph_optimization_level = self.ort.GraphOptimizationLevel.ORT_ENABLE_ALL

        if (
            self._preferred_providers
            and "CoreMLExecutionProvider" in self._preferred_providers
        ):
            # remove CoreMLExecutionProvider from the list, it is not as well optimized as CPU.
            self._preferred_providers.remove("CoreMLExecutionProvider")

        return self.ort.InferenceSession(
            os.path.join(self.DOWNLOAD_PATH, self.EXTRACTED_FOLDER_NAME, "model.onnx"),
            # Since 1.9 onnyx runtime requires providers to be specified when there are multiple available

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Check what your build supports: python -c "import onnxruntime; print(onnxruntime.get_available_providers())" and request only providers from that list
  2. For CUDA: pip uninstall onnxruntime && pip install onnxruntime-gpu, and verify CUDA/cuDNN versions match the ORT release requirements
  3. Pass preferred_providers=None (or omit) to let the EF use whatever providers are available on the machine
  4. Make the provider list environment-driven (e.g. only add CUDAExecutionProvider if it appears in get_available_providers())

Example fix

// before
fn = ONNXMiniLM_L6_V2(preferred_providers=["CUDAExecutionProvider"])  # CPU-only onnxruntime -> ValueError

// after
import onnxruntime
available = onnxruntime.get_available_providers()
fn = ONNXMiniLM_L6_V2(preferred_providers=[p for p in ["CUDAExecutionProvider", "CPUExecutionProvider"] if p in available] or None)
Defensive patterns

Strategy: validation

Validate before calling

import onnxruntime
available = set(onnxruntime.get_available_providers())
wanted = [p for p in ["CUDAExecutionProvider", "CPUExecutionProvider"] if p in available]
fn = ONNXMiniLM_L6_V2(preferred_providers=wanted or None)

Try / catch

try:
    fn = ONNXMiniLM_L6_V2(preferred_providers=req)
except ValueError as e:
    if "subset of available providers" in str(e):
        import onnxruntime
        req = [p for p in req if p in onnxruntime.get_available_providers()]
        fn = ONNXMiniLM_L6_V2(preferred_providers=req or None)
    else:
        raise

Prevention

When it happens

Trigger: ONNXMiniLM_L6_V2(preferred_providers=["CUDAExecutionProvider"]) with CPU-only onnxruntime installed (or onnxruntime-gpu installed but CUDA runtime/cuDNN missing, in which case the provider does not appear in get_available_providers()); requesting "TensorrtExecutionProvider" or "CoreMLExecutionProvider" on a machine/OS that cannot provide it; requesting "AzureExecutionProvider" without the azure package.

Common situations: Developing on macOS then deploying the same preferred_providers list to Linux; installing onnxruntime-gpu but the NVIDIA driver/CUDA toolkit version doesn't match, so ORT silently falls back to a CPU-only provider list; pinning provider lists in shared config across heterogeneous machines.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/9b949ceb7ac3324a. Report an issue: GitHub.