Skip to content

Whether the .whl file works on your computer is NOT a matter of luck! #3

Description

@dan64

You wrote that the fact that the .whl file works on your computer is a matter of luck! This is not true, the problem is that the dlib initialization script requires the user to have the CUDA SDK and cuDNN installed of the same version expected by the downloaded dlib version, while only torch with same CUDA needs to be installed in the same environment.
Replace the init.py file in the dlib folder with the attached version.

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 the same CUDA version used by dlib 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.

init.zip

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions