Python: captionbob.transcript
captionbob.transcript.nvidia_libraries
Loader of the NVIDIA libraries of the Python environment.
The Whisper model runs on ctranslate2. ctranslate2 opens cuBLAS and cuDNN by name when it first uses the GPU. The system then gives it the libraries of the system, when the system has them, and not the libraries that pip installed in the environment.
This module opens the libraries of the environment first. A later open by name gets a library that is already open in the process, so ctranslate2 then uses the libraries of the environment. Call load_nvidia_libraries before the Whisper model is made.
The loader works on Linux and on Windows. On Linux, the pip packages keep the libraries in their lib folders, and the loader opens cuBLAS and cuDNN. On Windows, the pip packages keep the DLL files in their bin folders, and the loader opens cuBLAS only. ctranslate2 for Windows carries its own cudnn64_9.dll and opens it when it is imported, which is before this loader runs, and the Whisper model on the GPU opened no cuDNN sub-library in the Windows run.
Source file: captionbob/transcript/nvidia_libraries.py
platform_libraries
def platform_libraries() -> tuple[NvidiaLibrary, ...]
Give the NVIDIA libraries that the loader opens on this platform.
Returns:
The entries of the libraries, in the order in which they are opened.
Raises:
OSError: When the platform is not Linux or Windows.
nvidia_library_paths
def nvidia_library_paths() -> tuple[Path, ...]
Give the full path of each NVIDIA library in the Python environment.
Returns:
The paths in the order in which the libraries must be opened.
Raises:
OSError: When the platform is not Linux or Windows.FileNotFoundError: When a library file is not in the environment.
load_nvidia_libraries
def load_nvidia_libraries() -> tuple[Path, ...]
Open the NVIDIA libraries of the Python environment in this process.
A second call opens nothing again and gives the same paths.
Returns:
The paths of the libraries that are open, in the order of opening.
Raises:
OSError: When the platform is not Linux or Windows, or when the system refuses to open a library.FileNotFoundError: When a library file is not in the environment.