[GH-ISSUE #3] LoadLibrary failed with error 126 #1

Closed
opened 2026-10-30 21:08:11 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @lvjurenbaba on GitHub (Mar 14, 2023).
Original GitHub issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/3

Error completing request
Arguments: (0, <PIL.Image.Image image mode=RGB size=1024x1536 at 0x250236FB370>, None, '', '', True, 0, 1, 512, 512, True, 'None', 'None', 0, 0, 0, 0, 'u2net', False, False, 240, 10, 10) {}
Traceback (most recent call last):
File "E:\NEW_SD\stable-diffusion-webui\modules\call_queue.py", line 56, in f
res = list(func(*args, **kwargs))
File "E:\NEW_SD\stable-diffusion-webui\modules\call_queue.py", line 37, in f
res = func(*args, **kwargs)
File "E:\NEW_SD\stable-diffusion-webui\modules\postprocessing.py", line 56, in run_postprocessing
scripts.scripts_postproc.run(pp, args)
File "E:\NEW_SD\stable-diffusion-webui\modules\scripts_postprocessing.py", line 130, in run
script.process(pp, **process_args)
File "E:\NEW_SD\stable-diffusion-webui\extensions\stable-diffusion-webui-rembg\scripts\postprocessing_rembg.py", line 53, in process
session=rembg.new_session(model),
File "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\rembg\session_factory.py", line 66, in new_session
ort.InferenceSession(
File "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 360, in init
self._create_inference_session(providers, provider_options, disabled_optimizers)
File "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 408, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: D:\a_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1106 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_providers_tensorrt.dll"

After I downloaded the onnx i met this

Originally created by @lvjurenbaba on GitHub (Mar 14, 2023). Original GitHub issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/3 Error completing request Arguments: (0, <PIL.Image.Image image mode=RGB size=1024x1536 at 0x250236FB370>, None, '', '', True, 0, 1, 512, 512, True, 'None', 'None', 0, 0, 0, 0, 'u2net', False, False, 240, 10, 10) {} Traceback (most recent call last): File "E:\NEW_SD\stable-diffusion-webui\modules\call_queue.py", line 56, in f res = list(func(*args, **kwargs)) File "E:\NEW_SD\stable-diffusion-webui\modules\call_queue.py", line 37, in f res = func(*args, **kwargs) File "E:\NEW_SD\stable-diffusion-webui\modules\postprocessing.py", line 56, in run_postprocessing scripts.scripts_postproc.run(pp, args) File "E:\NEW_SD\stable-diffusion-webui\modules\scripts_postprocessing.py", line 130, in run script.process(pp, **process_args) File "E:\NEW_SD\stable-diffusion-webui\extensions\stable-diffusion-webui-rembg\scripts\postprocessing_rembg.py", line 53, in process session=rembg.new_session(model), File "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\rembg\session_factory.py", line 66, in new_session ort.InferenceSession( File "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 360, in __init__ self._create_inference_session(providers, provider_options, disabled_optimizers) File "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 408, in _create_inference_session sess.initialize_session(providers, provider_options, disabled_optimizers) RuntimeError: D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1106 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "E:\NEW_SD\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_providers_tensorrt.dll" After I downloaded the onnx i met this
Author
Owner

@judy commented on GitHub (Mar 15, 2023):

I got this too and was able to fix it by reading this comment on the rembg repo. In short:

  1. You'll want to make sure you have the right versions of CUDA, cuDNN, and Nvidia TensorRT. I ended up installing all three of those. (The link says to use CUDA 11, but I needed CUDA 12.)
  2. Once installed, make sure the paths to the folders containing those DLLs are on your PATH when running the interface. Instead of modifying my system environment variables, I changed my webui-user.bat file to change the PATH like this:
set PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin;C:\Program Files\Common Files\TensorRT-8.6.0.12\lib;%PATH%

Adjust that yourself based on what the folders are on your own system. TensorRT in particular came as a zip file and no installer, so I stuck it in C:\Program Files\Common Files. No idea if that's the ideal location for that sort of thing, so your mileage will vary!

<!-- gh-comment-id:1470024586 --> @judy commented on GitHub (Mar 15, 2023): I got this too and was able to fix it by reading [this comment](https://github.com/danielgatis/rembg/issues/312#issuecomment-1465316591) on the rembg repo. In short: 1. You'll want to make sure you have the right versions of CUDA, cuDNN, and Nvidia TensorRT. I ended up installing all three of those. (The link says to use CUDA 11, but I needed CUDA 12.) 2. Once installed, make sure the paths to the folders containing those DLLs are on your PATH when running the interface. Instead of modifying my system environment variables, I changed my `webui-user.bat` file to change the PATH like this: ``` set PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin;C:\Program Files\Common Files\TensorRT-8.6.0.12\lib;%PATH% ``` Adjust that yourself based on what the folders are on your own system. TensorRT in particular came as a zip file and no installer, so I stuck it in `C:\Program Files\Common Files`. No idea if that's the ideal location for that sort of thing, so your mileage will vary!
Author
Owner

@RafaRed commented on GitHub (Mar 15, 2023):

It works. Thank you @judy

<!-- gh-comment-id:1470413129 --> @RafaRed commented on GitHub (Mar 15, 2023): It works. Thank you @judy
Author
Owner

@CansecoDev commented on GitHub (Mar 16, 2023):

Awesome it's working now, on my setup I went for:

  • cuda 11.8
  • cudnn 8.8.1.3 (for cuda 11)
  • tensorrt 8.6.0.12 (for cuda11)

old2

<!-- gh-comment-id:1471192391 --> @CansecoDev commented on GitHub (Mar 16, 2023): Awesome it's working now, on my setup I went for: - cuda 11.8 - cudnn 8.8.1.3 (for cuda 11) - tensorrt 8.6.0.12 (for cuda11) ![old2](https://user-images.githubusercontent.com/5104584/225495766-c908a1c0-3402-4afe-8c1b-d41457cce7bd.png)
Author
Owner

@lvjurenbaba commented on GitHub (Mar 16, 2023):

@judy Appreciate,i download Tensort8.6 and set path as you, it finally works!

<!-- gh-comment-id:1471818655 --> @lvjurenbaba commented on GitHub (Mar 16, 2023): @judy Appreciate,i download Tensort8.6 and set path as you, it finally works!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AUTOMATIC1111/stable-diffusion-webui-rembg#1
No description provided.