[Python] ONNXRuntime CUDA Error When Running rembg on RTX 4000 series graphic cards [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running into a persistent issue while trying to set up rembg on my system. Here are my current specs and setup details:

    OS: Windows 11

    GPU: RTX 4050 Laptop GPU 6GB (also tried with RTX 4060 Ti 16GB)

    CUDA: 12.6.3

    cuDNN: 9.8.0 for CUDA 12.x

    PyTorch: 2.6.0+cu126 (also tested with version 2.4.0 to see if that changes anything)

    onnxruntime-gpu: 1.19.0 (tried upgrading to 1.20.0 & 1.21.0, but still no luck)

    The error I keep getting is:

    Command: rembg i "C:\Users\admin\Downloads\Test\R.jpg" "C:\Users\admin\Downloads\Test\R1.png"

    Response: 2025-04-09 15:04:27.1359704 [E:eek:nnxruntime:Default, provider_bridge_ort.cc:1992 onnxruntime::TryGetProviderInfo_CUDA] D:\a_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1637 onnxruntime::providerLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

    I’m stuck on this error and have been wracking my brain trying to figure out if it’s a misconfiguration with CUDA/cuDNN, a path issue, or something within onnxruntime itself.

    What I’ve Tried Already:

    Verified that my CUDA and cuDNN versions match what’s expected by PyTorch and onnxruntime.

    Experimented with different versions of PyTorch (2.6.0 and 2.4.0) to no avail.

    Attempted to use different onnxruntime-gpu versions (1.19.0, 1.20.0, and 1.21.0).

    Questions & What I Need Help With:

    Library Loading Issue: Has anyone else encountered error 126 when loading onnxruntime_providers_cuda.dll? What usually causes this?

    Dependency Mismatches: Could this error be indicative of a mismatch between CUDA, cuDNN, and onnxruntime versions?

    Environment Variables & Paths: Are there specific environment variables or path issues I should check to ensure that the DLL is being found and loaded correctly?

    Potential Workarounds: Any recommended steps or workarounds for ensuring rembg functions properly with GPU acceleration on these configurations?

    Any insights or pointers to debugging steps would be hugely appreciated. I need this to work for my AI projects, and I’d really appreciate any help to figure out what’s going wrong.

    Continue reading...

Compartilhe esta Página