Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoadLibrary failed with error 126 #140

Open
JacobCZ opened this issue May 9, 2024 · 1 comment
Open

LoadLibrary failed with error 126 #140

JacobCZ opened this issue May 9, 2024 · 1 comment

Comments

@JacobCZ
Copy link

JacobCZ commented May 9, 2024

Trying the minimal stable diffusion example from the readme, when I run the code (with executionProvider: ExecutionProvider.Cuda in the ctor to use CUDA) I get the following error:

Unhandled exception. Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:RuntimeException] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1209 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "...\bin\Debug\net8.0\onnxruntime_providers_cuda.dll"

   at Microsoft.ML.OnnxRuntime.SessionOptions.AppendExecutionProvider_CUDA(Int32 deviceId)
   at OnnxStack.Core.Extensions.GetSessionOptions(OnnxModelConfig configuration)
   at OnnxStack.Core.Model.OnnxModelSession..ctor(OnnxModelConfig configuration)
   at OnnxStack.StableDiffusion.Models.UNetConditionModel..ctor(UNetConditionModelConfig configuration)
   at OnnxStack.StableDiffusion.Pipelines.StableDiffusionPipeline.CreatePipeline(StableDiffusionModelSet modelSet, ILogger logger)
   at OnnxStack.StableDiffusion.Pipelines.StableDiffusionPipeline.CreatePipeline(String modelFolder, ModelType modelType, Int32 deviceId, ExecutionProvider executionProvider, MemoryModeType memoryMode, ILogger logger)
   at UnstableDiffusion.UnstableDiff..ctor(String model) in ...\StableDiff.cs:line 20
   at Program.<Main>$(String[] args) in ...\Program.cs:line 3
   at Program.<Main>(String[] args)

I'm not sure what to do about this. I tried manually installing the CUDA SDK and cuDNN to no avail. bin\Debug\net8.0\onnxruntime_providers_cuda.dll exists and seems to be a valid DLL

Environment:

  • Windows 10
  • .NET 8.0.200
  • OnnxStack.StableDiffusion 0.31.0
  • CUDA 12.2
  • cuDNN 8.9.2.26
@saddam213
Copy link
Member

Hey JacobCZ

The CUDA and TensorRT OnnxRuntime packages require their own dependencies to be installed, CUDA Toolkit and cuDNN

LoadLibrary failed with error 126 happens when it cant find one of those dependencies, unfortunately this happens to a few users and I have no idea what causes the issue.

We recommend DirectML if your card supports DirectX as its significantly faster than CUDA and does not require external dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants