Whisper OpenBLAS Warnings when running Whisper Inference on aarch64 cpu
Author: DrChrisLevy
Pull request: no

### System Info

- `transformers` version: 4.36.2
- Platform: Linux-5.10.76-linuxkit-aarch64-with-glibc2.31
- Python version: 3.9.18
- Huggingface_hub version: 0.20.1
- Safetensors version: 0.4.1
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): 2.1.2 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

@ArthurZucker

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [x] My own task or dataset (give details below)

### Reproduction

The issue I am seeing happens when I run the whisper model inference below on Apple M1 Pro within certain environments and versions of transformers, but not all the time. 

- The issue **is** present in docker container below on macm1 with transformers versions higher than 4.35.2. It does not happen in 4.35.2.  
- The issue is **not** present when running within python venv (not Docker) on mac m1, even for transformers versions higher than 4.35.2.
- The issue is **not** present when running on on linux machine `x86_64` , even for transformers versions higher than 4.35.2.

To reproduce the issue on Apple M1 Pro:

Create this Dockerfile
```
FROM public.ecr.aws/docker/library/python:3.9-slim-bullseye

WORKDIR /app

RUN apt-get update && apt-get install -y \
        vim


RUN pip install transformers==4.36.2
RUN pip  install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
RUN pip install ipython

COPY . /app
```

Build the docker image and then get into the docker container shell
```
docker build . -t  asr
docker run -it asr /bin/bash
```

Now in the container, open `ipython` shell
```
ipython
```
Then copy/paste this code which is almost identical to the example code [here](https://huggingface.co/openai/whisper-large-v3#usage).

```python
import torch
import numpy as np
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline


model_id = "openai/whisper-tiny"
device = "cpu"
model = AutoModelForSpeechSeq2Seq.from_pretrained(
    model_id, torch_dtype=torch.float32, use_safetensors=True
)
model.to(device)

processor = AutoProcessor.from_pretrained(model_id)

pipe = pipeline(
    "automatic-speech-recognition",
    model=model,
    tokenizer=processor.tokenizer,
    feature_extractor=processor.feature_extractor,
    max_new_tokens=128,
    chunk_length_s=30,
    batch_size=16,
    return_timestamps=True,
    torch_dtype=torch.float32,
    device=device,
)


sample_audio = np.array([-3.7841797e-03, -2.0751953e-03, -3.9978027e-03, -3.5095215e-03,
       -2.2888184e-03, -1.8920898e-03, -2.1057129e-03,  2.7465820e-04,
       -1.0986328e-03, -3.0517578e-03, -3.1433105e-03, -2.6245117e-03,
       -2.0446777e-03, -4.5776367e-04, -4.3334961e-03, -2.5024414e-03,
       -2.5634766e-03, -2.1667480e-03, -3.0517578e-05,  1.1291504e-03,
        2.2888184e-03,  1.1901855e-03, -1.0681152e-03, -1.0986328e-03,
       -1.2207031e-04, -2.2888184e-03, -9.1552734e-05, -1.1596680e-03,
       -9.4604492e-04,  1.5258789e-04,  3.0517578e-05, -6.4086914e-04,
        1.8310547e-04, -3.0517578e-05,  6.7138672e-04, -1.1291504e-03,
       -2.3193359e-03, -2.6855469e-03, -8.2397461e-04, -2.5634766e-03,
       -2.4414062e-03, -3.5095215e-03, -1.8310547e-04, -3.1738281e-03,
       -1.3122559e-03, -4.4250488e-03, -1.3732910e-03, -3.2348633e-03,
       -1.8005371e-03, -1.2207031e-03, -4.8828125e-04, -2.6245117e-03,
       -2.3193359e-03, -1.8920898e-03, -1.4953613e-03,  4.2724609e-04,
       -1.2207031e-03, -9.4604492e-04, -1.6479492e-03, -2.4719238e-03,
       -1.0986328e-03, -1.5258789e-03, -4.8828125e-04, -2.4719238e-03,
       -1.4648438e-03, -7.6293945e-04,  2.1057129e-03,  3.6621094e-04,
        1.5258789e-04,  3.9672852e-04,  1.3122559e-03,  3.7231445e-03,
        2.9907227e-03,  4.0893555e-03,  2.1362305e-03,  3.1127930e-03,
        3.4484863e-03,  5.8898926e-03,  5.7678223e-03,  5.3405762e-03,
        5.7678223e-03,  3.6621094e-03,  4.5166016e-03,  2.3498535e-03,
        4.7912598e-03,  4.8217773e-03,  7.1105957e-03,  5.7678223e-03,
        5.7678223e-03,  4.9438477e-03,  6.5612793e-03,  7.3547363e-03,
        7.4462891e-03,  7.2631836e-03,  6.6833496e-03,  4.4860840e-03,
        5.0964355e-03,  5.5847168e-03,  5.9204102e-03,  5.0659180e-03],
      dtype=np.float32)

result = pipe(sample_audio)
print(result["text"])
```

When running on aarch64 you will see the warning message printed to the screen hundreds of times

```
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
......
```



### Expected behavior

The output result which is the string `' you'` with **no** OpenBLAS Warnings. 

Comments:
It seems like OpenBlas is at fault here no? I ran your code and had no warning whatsoever (on a M3). https://github.com/OpenMathLib/OpenBLAS might need to be built with USE_OPENMP=1.


Okay let me run it in a python virtual env (not docker) on the same machine and see if the issue goes away. You ran it in the above docker container ? Or in a slightly different env? Thanks for the quick reply and checking. I just thought it was something to do with transformers since I only saw that warning when upgrading recently. I'll post back later today. 

**update** (I also updated some of the findings in the description at the top).
- The issue **is** present in the sample docker container on macm1 with transformers versions higher than 4.35.2. It does not happen in 4.35.2 though in the same Docker container.
- The issue is **not** present when running within python venv (not Docker) on mac m1, even for transformers versions higher than 4.35.2.

Im not sure if you have any other thoughts on that @ArthurZucker . I would be interested in knowing if you ran my reproducible example in the same docker container environment. 

If you think this is just some environment thing then feel free to close the issue.


Sorry for the confusion I simply ran it on pyenv locally as well 😉 
Glad that the findings show this might be more a docker issue than a transformers issue! 

It should be possible to disable multithreading in openblas without recompiling it, by `export OPENBLAS_NUM_THREADS=1` before running the python program in the terminal https://pythonspeed.com/articles/concurrency-control/

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.