AudioToText icon indicating copy to clipboard operation
AudioToText copied to clipboard

Colab version not working anymore

Open Zennco23 opened this issue 11 months ago • 2 comments

Dear Carlos,

The Colab version is not working anymore. It is giving the following error.

Would you mind checking it and resolving the error?

Thanks very much! Engin.

RuntimeError Traceback (most recent call last) in <cell line: 0>() 100 print(f"\nLoading {use_model} model... {os.path.expanduser(f'~/.cache/whisper/{use_model}.pt')}") 101 --> 102 model = whisper.load_model(use_model, device=DEVICE) 103 104 print(

1 frames /usr/local/lib/python3.11/dist-packages/whisper/model.py in set_alignment_heads(self, dump) 249 gzip.decompress(base64.b85decode(dump)), dtype=bool 250 ).copy() --> 251 mask = torch.from_numpy(array).reshape( 252 self.dims.n_text_layer, self.dims.n_text_head 253 )

RuntimeError: Numpy is not available

Zennco23 avatar Mar 19 '25 22:03 Zennco23

If you're encountering issues with this notebook in Google Colab due to package dependency conflicts (especially around torch, torchaudio, torchvision, typing-extensions, and potentially triton), I recently worked through some of these and found a set of installation commands for "[Step 1] ⚙️ Install the required libraries" that resolved the problems for me.

Replace the existing !pip install --root-user-action=ignore git+https://github.com/openai/whisper.git... line with the corrected lines provided below:

# Define the warning suppressor if you keep it, or remove {NO_ROOT_WARNING} from the line below
NO_ROOT_WARNING = '|& grep -v \\\"WARNING: Running pip as the \\'root\\' user\"'

# 1. Upgrade pip
!pip install --no-warn-script-location --user --upgrade pip {NO_ROOT_WARNING}

# 2. Install Whisper and main dependencies with corrected typing-extensions
!pip install --root-user-action=ignore \
    git+https://github.com/openai/whisper.git@v20231117 \
    openai==1.9.0 \
    numpy \
    scipy \
    deepl \
    pydub \
    cohere \
    ffmpeg-python \
    "typing-extensions>=4.12.0,<5.0.0" \
    tensorflow-probability==0.23.0

# 3. Install a compatible PyTorch stack for Colab
!pip install --root-user-action=ignore torch==2.6.0 torchaudio==2.6.0 torchvision==0.21.0 -f https://download.pytorch.org/whl/cu121/torch_stable.html

VERY IMPORTANT: After this cell finishes, YOU MUST RESTART THE COLAB RUNTIME (Runtime > Restart session)

Note on Triton: You will prob see a warning about openai-whisper requiring triton<3.0.0 while triton 3.2.0 (or similar) is installed by torch 2.6.0. After restarting the runtime, Whisper v20231117 worked fine for me with this newer Triton. If you face Triton-specific errors later, you might need to add !pip install --root-user-action=ignore --force-reinstall triton==2.1.0 at the end of the installations and restart again.

Hope this helps!

mikezio avatar May 06 '25 21:05 mikezio