Skip to content

LoadLibrary failed with error 127 #1794

@furkanbl2

Description

@furkanbl2

CPU works fine, but since I have an RTX 3070, I installed the required components to use the GPU and tried to run it with GPU. However, even though I installed CUDA Toolkit 12.8.0 and cuDNN v8.9.7, I’m getting error 127. When I asked ChatGPT and Gemini, they said either I didn’t install it properly or there is a PATH issue, but even after reinstalling 2–3 times, I still get the same error. ChatGPT also said that cuDNN 8.9.7 might be outdated and possibly no longer supported. Then I installed version 9.1.0.70, but the issue is still the same.
The error code is here:

[DLC.FACE-SWAPPER] Loading face swapper model from: E:\Deep-Live-Cam\models\inswapper_128.onnx
2026-04-28 01:00:02.0407804 [W:onnxruntime:, graph.cc:4401 onnxruntime::Graph::CleanUnusedInitializersAndNodeArgs] Removing initializer 'buff2fs'. It is not used by any node and should be removed from the model.
2026-04-28 01:00:02.0580695 [E:onnxruntime:Default, provider_bridge_ort.cc:2036 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1695 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 127 "" when trying to load "E:\Deep-Live-Cam\venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

2026-04-28 01:00:02.0671200 [W:onnxruntime:Default, onnxruntime_pybind_state.cc:994 onnxruntime::python::CreateExecutionProviderInstance] Failed to create CUDAExecutionProvider. Require cuDNN 9.* and CUDA 12.*, and the latest MSVC runtime. Please install all dependencies as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
inswapper-shape: [1, 3, 128, 128]
[DLC.FACE-SWAPPER] Face swapper model loaded successfully.
[DLC.CORE] Processing...
[DLC.CORE] Processing video in-memory at 30.0 fps...
2026-04-28 01:00:03.2182721 [E:onnxruntime:Default, provider_bridge_ort.cc:2036 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1695 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 127 "" when trying to load "E:\Deep-Live-Cam\venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
model ignore: C:\Users\mfurk/.insightface\models\buffalo_l\1k3d68.onnx landmark_3d_68
2026-04-28 01:00:03.6926563 [E:onnxruntime:Default, provider_bridge_ort.cc:2036 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1695 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 127 "" when trying to load "E:\Deep-Live-Cam\venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\Users\mfurk/.insightface\models\buffalo_l\2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
2026-04-28 01:00:03.7742579 [E:onnxruntime:Default, provider_bridge_ort.cc:2036 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1695 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 127 "" when trying to load "E:\Deep-Live-Cam\venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\Users\mfurk/.insightface\models\buffalo_l\det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
2026-04-28 01:00:03.8525470 [E:onnxruntime:Default, provider_bridge_ort.cc:2036 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1695 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 127 "" when trying to load "E:\Deep-Live-Cam\venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
model ignore: C:\Users\mfurk/.insightface\models\buffalo_l\genderage.onnx genderage
2026-04-28 01:00:03.9715757 [E:onnxruntime:Default, provider_bridge_ort.cc:2036 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1695 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 127 "" when trying to load "E:\Deep-Live-Cam\venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll" `

AND the code in the run.py file printed by Gemini is this: 
``` # Primary path for CUDA 12.8 on your system
cuda_bin_path = r"E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\bin"

# The onnxruntime folder where cuDNN DLLs were manually copied
onnx_capi_path = os.path.join(project_root, "venv", "Lib", "site-packages", "onnxruntime", "capi")

# 1. Explicitly point the system to the CUDA bin directory
if os.path.exists(cuda_bin_path):
    if hasattr(os, 'add_dll_directory'):
        os.add_dll_directory(cuda_bin_path)
    os.environ["PATH"] = cuda_bin_path + os.pathsep + os.environ.get("PATH", "")

# 2. Prioritize the CAPI folder containing the manually copied cuDNN files
if os.path.exists(onnx_capi_path):
    if hasattr(os, 'add_dll_directory'):
        # The most reliable method for Windows 10/11
        os.add_dll_directory(onnx_capi_path)
    # Append to PATH for legacy support
    os.environ["PATH"] = onnx_capi_path + os.pathsep + os.environ.get("PATH", "")

# 3. Enable the execution flag
os.environ["ORT_CUDA_FLAGS"] = "1"
# --- END OF CUDA DLL INJECTION ---

import tkinter_fix
from modules import core

if __name__ == '__main__':
    core.run() ``` 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions