16.02.2026, 19:32
You're right, the dlib initialization script requires the user to have the CUDA SDK and cuDNN installed, while torch only needs to be installed in the same environment.
Replace the __init__.py file in the dlib folder with the attached version and clear the cache.
Key Changes applied in the attached script:
Installation Requirement:
Ensure that the torch package with CUDA 13.0 is installed in the same Python environment as dlib, so that the script can locate torch\lib correctly.
This modification allows dlib to dynamically use the CUDA DLLs bundled with torch, improving portability and reducing dependency on system-wide CUDA installations.
Dan
P.S.
Tested and working on my side.
Replace the __init__.py file in the dlib folder with the attached version and clear the cache.
Key Changes applied in the attached script:
- Removed Static CUDA Paths: Eliminated hardcoded references to the NVIDIA CUDA Toolkit.
- Dynamic Torch Path Detection: Used torch.__file__ to locate the torch package and constructed the path to its lib folder.
- Windows-Specific Logic: Wrapped the DLL path modification in a check for os.name == 'nt' to ensure it only runs on Windows.
- Robust Error Handling: Maintained try-except blocks to prevent failures if torch is not installed or paths are inaccessible.
Installation Requirement:
Ensure that the torch package with CUDA 13.0 is installed in the same Python environment as dlib, so that the script can locate torch\lib correctly.
This modification allows dlib to dynamically use the CUDA DLLs bundled with torch, improving portability and reducing dependency on system-wide CUDA installations.
Dan
P.S.
Tested and working on my side.

