microsoft / microsoft/foundry-dev-tools

Bug: CUDA provider DLLs copied to wrong directory, causing Error 126 on model load

Open
#469 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs attention
Dominant language
JavaScript
Stars
2.1k
Forks
260
Avg merge
42m
Merged PRs (30d)
29

Description

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.jsOnnxRuntimeHandler 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

  1. Install the extension on a machine with an NVIDIA GPU but without the CUDA toolkit in System32/PATH
  2. Select a *-cuda-gpu model variant in the playground
  3. Observe the on-demand download progress notification (DLLs download successfully)
  4. 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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in dist/extension.js at the OnnxRuntimeHandler methods ensureOnnxRuntimeTRTLib and ensureOnnxRuntimeCudaLib, then inspect module 72057 and getToolkitStaticFolder(). Check all six DLL path constructions and the inference-agent spawn call. Done means the provider DLLs are placed under ai-mlstudio/bin and the CUDA model loads without Error 126, including the reported Windows dependency-resolution case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.