speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

faster-whisper: Could not locate cudnn_ops64_9.dll. Please make sure it is in your library path! Invalid handle. Cannot load symbol cudnnCreateTensorDescriptor

Open ViSzKe opened this issue 11 months ago • 1 comments

Steps to reproduce

import speech_recognition as sr
recognizer = sr.Recognizer()
mic = sr.Microphone()

with mic as source:
        audio = recognizer.listen(source)

whisper_model = "turbo"
command = recognizer.recognize_faster_whisper(audio, model=whisper_model)

Expected behaviour

I expect command == [transcribed speech] It does work with command = recognizer.recognize_google(audio) and even command = recognizer.recognize_whisper(audio, model=whisper_model)

Actual behaviour

INFO:faster_whisper:Processing audio with duration 00:02.368
Could not locate cudnn_ops64_9.dll. Please make sure it is in your library path!
Invalid handle. Cannot load symbol cudnnCreateTensorDescriptor

System information

My system is Windows 11.

My Python version is 3.12.9.

My Pip version is 24.3.1.

My SpeechRecognition library version is 3.14.2. (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)

My PyAudio library version is 0.2.14 .

My microphone is: Logitech G733 headset.

My working microphone is: Logitech G733 headset.

I have not installed PocketSphinx.

ViSzKe avatar Mar 29 '25 05:03 ViSzKe

See the GPU execution requirements for faster-whisper:

GPU execution requires the following NVIDIA libraries to be installed:

Note: The latest versions of ctranslate2 only support CUDA 12 and cuDNN 9. For CUDA 11 and cuDNN 8, the current workaround is downgrading to the 3.24.0 version of ctranslate2, for CUDA 12 and cuDNN 8, downgrade to the 4.4.0 version of ctranslate2, (This can be done with pip install --force-reinstall ctranslate2==4.4.0 or specifying the version in a requirements.txt).

There are multiple ways to install the NVIDIA libraries mentioned above. The recommended way is described in the official NVIDIA documentation, but we also suggest other installation methods below.

Other installation methods (click to expand)

Note: For all these methods below, keep in mind the above note regarding CUDA versions. Depending on your setup, you may need to install the CUDA 11 versions of libraries that correspond to the CUDA 12 libraries listed in the instructions below.

Use Docker

The libraries (cuBLAS, cuDNN) are installed in this official NVIDIA CUDA Docker images: nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04.

Install with pip (Linux only)

On Linux these libraries can be installed with pip. Note that LD_LIBRARY_PATH must be set before launching Python.

pip install nvidia-cublas-cu12 nvidia-cudnn-cu12==9.*

export LD_LIBRARY_PATH=`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + ":" + os.path.dirname(nvidia.cudnn.lib.__file__))'`

Download the libraries from Purfview's repository (Windows & Linux)

Purfview's whisper-standalone-win provides the required NVIDIA libraries for Windows & Linux in a single archive. Decompress the archive and place the libraries in a directory included in the PATH.

Alternatively, you can use your CPU, e.g.:

command = recognizer.recognize_faster_whisper(
    audio, model=whisper_model,
    init_options={"device": "cpu", "compute_type": "int8"}
)

Harmon758 avatar Oct 26 '25 17:10 Harmon758