-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve GPU auto detection in transcription code #2398
Comments
Fallbacking to CPU may not be desired by the user and he may prefer an explicit abortion. |
@lfcnassif , I was testing here on version 4.2.0 and I have a suggestion. GPUtil informs you if you have cuda installed on your PC. Torch already tells you whether the python being run is prepared to run cuda, so it is more reliable information. See the code below. With it I can run whisper without errors if my iped installation has pytorch cuda via gpu or cpu. If it's in the standard version, I'm getting errors.
|
Thanks @gfd2020. Unfortunately I just realized Is there a different GPUtil command to check for CUDA availability other than Anyway, I think the best approach here is to externalize the device option (CPU x GPU) and to abort processing if it fails. |
I agree, but if you only use CPU (pip install numpy faster-whisper) the import torch check will throw an exception, so it's ok, go for the CPU. If you are going to use GPU ( pip install torch torchvision torchaudio faster-whisper) the torch import will run and the two variables will be tested to see if everything is available. In short, you only need torch if you are going to use GPU. This check will only be done in the case of GPU installation.
From what I've tested, GPUtil tells you the cudaCount if cuda is installed on the PC. As for torch, it references the python.exe that is executing the script. For example, if IPED's python has torch installed correctly, it will return 1; if it doesn't have torch, it will return 0.
I agree, there could be an option to force the cpu if the user wants. |
But where in the official faster-whisper site they say pytorch is needed? I can run faster-whisper on GPU without pytorch, installing the needed CUDA libs (cuDNN and cuBLAS). Pytorch was required by the previous wav2vec2, but seems it is not by faster-whisper. |
I see. You're right then. |
@lfcnassif , I found another lib to detect cuda count. It's called numba. It's 100 MB. It worked here, tell me if it works.
PS: I didn't know that faster-whisper doesn't need pytorch. That way, I'll have to update the wiki. Just to confirm:
I had to do additional checks to see if cuudn and cublas are installed correctly, otherwise the transcription throws an exception. |
Information:
pip install faster-whisper On that same page there is a link to download the DLLs necessary to run on Windows. I downloaded So, just place 4 DLLs in the python folder and the transcription was done successfully on GPU. It wasn't even necessary to install NVIDIA's own cuDNN and cuBLAS (which, by the way, comes with a bunch of other software) . These 4 DLLs are only 440 MB compressed. The Python folder with faster-whisper plus the GPU DLLs was approximately 515 MB compressed. I thought it was reasonable. Remembering that updating the CUDA SDK driver to version 12.x must be done through the NVIDIA installer normally. I'm going to update the wiki to help anyone who wants to install faster-whisper with GPU drivers.
|
Thank you very much @gfd2020 for all your work here!
WhisperX uses Faster-whisper internally, so it doesn't need pytorch.
Yes, I got the same errors with GPUtil and numba with your previous code.
Thank you very much! |
It seems that after installing numba and faster-whisper (
|
Currently we use gputil python library to query GPU presence, it uses nvidia-smi cmd line tool internally. Unfortunately it can cause issues if a GPU exists but is badly configured (missing libraries, etc). Maybe it is better to use
torch.cuda.device_count()
to check for GPU availability. Or even make the choice between CPU x GPU an explicit parameter in AudioTranscriptConfig.txt and abort if it doesn't work with the selected device instead of trying to fallback to CPU, thoughts?The text was updated successfully, but these errors were encountered: