lablab-ai / whisper-api-flask

89 stars 38 forks source link

ffmpeg: error while loading shared libraries: libblas.so.3 #2

Open sscotti opened 1 year ago

sscotti commented 1 year ago

Getting that error when trying to build this using a docker-compose.yml file. I think everything is mostly working though.

I am running docker on and INTEL Mac with Docker Desktop. The container builds, but when I enter the terminal and type:

ffmpeg --version

get that error:

ffmpeg: error while loading shared libraries: libblas.so.3: cannot open shared object file: No such file or directory

Same error when I execute from the CLI:

curl -F "file=@/Users/sscotti/Desktop/test.wav" http://localhost:5000/whisper

with port 5000 exposed in docker-compose.yml

whisper_service_1  | The above exception was the direct cause of the following exception:
whisper_service_1  | 
whisper_service_1  | Traceback (most recent call last):
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app
whisper_service_1  |     response = self.full_dispatch_request()
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
whisper_service_1  |     rv = self.handle_user_exception(e)
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
whisper_service_1  |     rv = self.dispatch_request()
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
whisper_service_1  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
whisper_service_1  |   File "/python-docker/app.py", line 43, in handler
whisper_service_1  |     result = model.transcribe(temp.name)
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/whisper/transcribe.py", line 121, in transcribe
whisper_service_1  |     mel = log_mel_spectrogram(audio, padding=N_SAMPLES)
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/whisper/audio.py", line 130, in log_mel_spectrogram
whisper_service_1  |     audio = load_audio(audio)
whisper_service_1  |   File "/usr/local/lib/python3.10/site-packages/whisper/audio.py", line 51, in load_audio
whisper_service_1  |     raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e
whisper_service_1  | RuntimeError: Failed to load audio: ffmpeg: error while loading shared libraries: libblas.so.3: cannot open shared object file: No such file or directory

Seems like so sort of issue with that library being loaded.

sscotti commented 1 year ago

Just a follow up to my previous post. I kept having problems with that ffmpeg library not being available: libblas.so.3

So, my solution was to actually compile my own ffmpeg library per the directions here:

ffmpeg compile using docker

and then map or copy that compiled ffmpeg to my Whisper container. Surprising that seems to have worked because when I test with : curl -F "file=@test.wav" http://localhost:5000/whisper

that works now. I just get a warning:

/usr/local/lib/python3.9/site-packages/whisper/transcribe.py:114: UserWarning: FP16 is not supported on CPU; using FP32 instead
whisper_service_1  |   warnings.warn("FP16 is not supported on CPU; using FP32 instead")

Is there something I should do with the whisper options in app.py to configure it correctly for my system ?

Another thing I am curious about. My dev machine and others do not have a GPU, but quite a few CPU's. Does Whisper automatically use all of the resources, or do I need to somehow configure it to use multiple processes or pools, if it can do that at all.

The performance on my dev iMac (Intel i7 machine) isn't bad. I haven't tried it yet on an M1 MBP. A production machine is a Dell R710 with 24 cores, but not GPU. Kind of wondering how it might work on that machine ?

ezzcodeezzlife commented 1 year ago

Hey, this example was really made for GPU usage, but there is this whisper implementation that is made for CPU: https://github.com/ggerganov/whisper.cpp

Thank you 🚀