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 availableView on GitHub (pinned to aecdd12c8a)
Solutions
- Check what your build supports: python -c "import onnxruntime; print(onnxruntime.get_available_providers())" and request only providers from that list
- For CUDA: pip uninstall onnxruntime && pip install onnxruntime-gpu, and verify CUDA/cuDNN versions match the ORT release requirements
- Pass preferred_providers=None (or omit) to let the EF use whatever providers are available on the machine
- 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
- Derive the provider list from onnxruntime.get_available_providers() at runtime instead of hardcoding
- Match the onnxruntime variant to hardware: onnxruntime (CPU), onnxruntime-gpu (CUDA), macOS builds (CoreML)
- Log get_available_providers() at startup in deployment diagnostics
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
- Preferred providers must be a list of strings
- Preferred providers must be unique
- Could not build embedding function {ef_config['name']} from
- Updating '{key}' is not supported for {NAME}
- The onnxruntime python package is not installed. Please inst
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/9b949ceb7ac3324a.
Report an issue: GitHub.