Summary
When loading a CUDA-GPU model variant (e.g. qwen2.5-coder-1.5b-instruct-cuda-gpu), the extension correctly detects an NVIDIA GPU and triggers an on-demand download of the ONNX Runtime CUDA provider DLLs. However, the DLLs are copied to the wrong directory and are never found by the inference agent, resulting in a hard failure.
Error Message
Failed loading model qwen2.5-coder-1.5b-instruct-cuda-gpu:4.
E:_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1844
onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL :
Error loading "...\ai-mlstudio\bin\onnxruntime_providers_cuda.dll" which is missing.
(Error 126: "The specified module could not be found.")
Root Cause
OnnxRuntimeHandler.ensureOnnxRuntimeCudaLib() constructs the copy destination using:
l.default.join(p.ext.context.extensionUri.fsPath, "bin", dllName)
This resolves to <extension root>\bin\ — but Inference.Service.Agent.exe lives in <extension root>\ai-mlstudio\bin\ and ONNX Runtime resolves provider DLL paths relative to that directory.
getToolkitStaticFolder() (defined in module 72057) correctly returns <extension root>\ai-mlstudio, but it is not imported in the OnnxRuntimeHandler module and is not used here. All 6 path constructions in ensureOnnxRuntimeTRTLib and ensureOnnxRuntimeCudaLib share the same wrong base path.
Affected Files
dist/extension.js — OnnxRuntimeHandler class (ensureOnnxRuntimeTRTLib, ensureOnnxRuntimeCudaLib)
Fix
Replace all occurrences of:
p.ext.context.extensionUri.fsPath, "bin"
with:
p.ext.context.extensionUri.fsPath, "ai-mlstudio", "bin"
within the OnnxRuntimeHandler class (both the existence check and the ensureDir/copyFile destination paths).
In source, this means using getToolkitStaticFolder() as the base instead of extensionUri.fsPath when constructing the bin/ path for CUDA provider DLLs.
Secondary Issue (PATH not set for child process)
The inference agent is launched via:
y.exec(`start /B "" "${exe}" ${args}`, { shell: cmdExe, windowsHide: true })
No env is passed, so the child process PATH does not include ai-mlstudio\bin\. Even after fixing the copy destination, Windows DLL loader may fail to resolve transitive dependencies of onnxruntime_providers_cuda.dll (e.g. cublas64_12.dll, cudnn64_9.dll) unless ai-mlstudio\bin\ is on PATH.
Fix: pass env: { ...process.env, PATH: \${binDir};${process.env.PATH}` }` when spawning the agent on Windows.
Steps to Reproduce
- Install the extension on a machine with an NVIDIA GPU but without the CUDA toolkit in
System32/PATH
- Select a
*-cuda-gpu model variant in the playground
- Observe the on-demand download progress notification (DLLs download successfully)
- Model load fails with Error 126
Environment
- Extension:
ms-windows-ai-studio 1.4.3
- OS: Windows 11
- GPU: NVIDIA RTX PRO 1000 Blackwell (driver installed, CUDA toolkit NOT separately installed system-wide)
Summary
When loading a CUDA-GPU model variant (e.g.
qwen2.5-coder-1.5b-instruct-cuda-gpu), the extension correctly detects an NVIDIA GPU and triggers an on-demand download of the ONNX Runtime CUDA provider DLLs. However, the DLLs are copied to the wrong directory and are never found by the inference agent, resulting in a hard failure.Error Message
Root Cause
OnnxRuntimeHandler.ensureOnnxRuntimeCudaLib()constructs the copy destination using:This resolves to
<extension root>\bin\— butInference.Service.Agent.exelives in<extension root>\ai-mlstudio\bin\and ONNX Runtime resolves provider DLL paths relative to that directory.getToolkitStaticFolder()(defined in module 72057) correctly returns<extension root>\ai-mlstudio, but it is not imported in theOnnxRuntimeHandlermodule and is not used here. All 6 path constructions inensureOnnxRuntimeTRTLibandensureOnnxRuntimeCudaLibshare the same wrong base path.Affected Files
dist/extension.js—OnnxRuntimeHandlerclass (ensureOnnxRuntimeTRTLib,ensureOnnxRuntimeCudaLib)Fix
Replace all occurrences of:
with:
within the
OnnxRuntimeHandlerclass (both the existence check and theensureDir/copyFiledestination paths).In source, this means using
getToolkitStaticFolder()as the base instead ofextensionUri.fsPathwhen constructing thebin/path for CUDA provider DLLs.Secondary Issue (PATH not set for child process)
The inference agent is launched via:
No
envis passed, so the child processPATHdoes not includeai-mlstudio\bin\. Even after fixing the copy destination, Windows DLL loader may fail to resolve transitive dependencies ofonnxruntime_providers_cuda.dll(e.g.cublas64_12.dll,cudnn64_9.dll) unlessai-mlstudio\bin\is onPATH.Fix: pass
env: { ...process.env, PATH: \${binDir};${process.env.PATH}` }` when spawning the agent on Windows.Steps to Reproduce
System32/PATH*-cuda-gpumodel variant in the playgroundEnvironment
ms-windows-ai-studio 1.4.3