{"record":{"id":"9b949ceb7ac3324a","repo":"chroma-core/chroma","slug":"preferred-providers-must-be-subset-of-available-pr","errorCode":null,"errorMessage":"Preferred providers must be subset of available providers: {self.ort.get_available_providers()}","messagePattern":"Preferred providers must be subset of available providers: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/onnx_mini_lm_l6_v2.py","lineNumber":235,"sourceCode":"    @cached_property\n    def model(self) -> Any:\n        \"\"\"\n        Get the model.\n\n        Returns:\n            The model.\n        \"\"\"\n        if self._preferred_providers is None or len(self._preferred_providers) == 0:\n            if len(self.ort.get_available_providers()) > 0:\n                logger.debug(\n                    f\"WARNING: No ONNX providers provided, defaulting to available providers: \"\n                    f\"{self.ort.get_available_providers()}\"\n                )\n            self._preferred_providers = self.ort.get_available_providers()\n        elif not set(self._preferred_providers).issubset(\n            set(self.ort.get_available_providers())\n        ):\n            raise ValueError(\n                f\"Preferred providers must be subset of available providers: {self.ort.get_available_providers()}\"\n            )\n\n        # Suppress onnxruntime warnings\n        so = self.ort.SessionOptions()\n        so.log_severity_level = 3\n        so.graph_optimization_level = self.ort.GraphOptimizationLevel.ORT_ENABLE_ALL\n\n        if (\n            self._preferred_providers\n            and \"CoreMLExecutionProvider\" in self._preferred_providers\n        ):\n            # remove CoreMLExecutionProvider from the list, it is not as well optimized as CPU.\n            self._preferred_providers.remove(\"CoreMLExecutionProvider\")\n\n        return self.ort.InferenceSession(\n            os.path.join(self.DOWNLOAD_PATH, self.EXTRACTED_FOLDER_NAME, \"model.onnx\"),\n            # Since 1.9 onnyx runtime requires providers to be specified when there are multiple available","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/onnx_mini_lm_l6_v2.py#L217-L253","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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())"],"exampleFix":"// before\nfn = ONNXMiniLM_L6_V2(preferred_providers=[\"CUDAExecutionProvider\"])  # CPU-only onnxruntime -> ValueError\n\n// after\nimport onnxruntime\navailable = onnxruntime.get_available_providers()\nfn = ONNXMiniLM_L6_V2(preferred_providers=[p for p in [\"CUDAExecutionProvider\", \"CPUExecutionProvider\"] if p in available] or None)","handlingStrategy":"validation","validationCode":"import onnxruntime\navailable = set(onnxruntime.get_available_providers())\nwanted = [p for p in [\"CUDAExecutionProvider\", \"CPUExecutionProvider\"] if p in available]\nfn = ONNXMiniLM_L6_V2(preferred_providers=wanted or None)","typeGuard":null,"tryCatchPattern":"try:\n    fn = ONNXMiniLM_L6_V2(preferred_providers=req)\nexcept ValueError as e:\n    if \"subset of available providers\" in str(e):\n        import onnxruntime\n        req = [p for p in req if p in onnxruntime.get_available_providers()]\n        fn = ONNXMiniLM_L6_V2(preferred_providers=req or None)\n    else:\n        raise","preventionTips":["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"],"tags":["onnx","embedding-function","execution-providers","cuda","config-validation","chroma"],"backgroundTag":"unsupported-execution-provider","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}