# Issue with TorchCodec when fine-tuning Whisper ASR model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315%3E%5C
**Category:** Beginners\
**Created:** [October 21, 2025, 7:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315 "2025-10-21T07:37:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![junnyrong](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/junnyrong/32/54763_2.png) [@junnyrong](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjunnyrong)%5C
**Post date:** [October 21, 2025, 7:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315%2F1 "2025-10-21T07:37:41Z")

</div>

Hello,

In the past I have been fine tuning the Whisper-tiny ASR model using these guides:

> **[Fine Tuning Whisper on Custom Dataset](https://learnopencv.com/fine-tuning-whisper-on-custom-dataset/)**
>
> Fine tuning Whisper on a custom dataset involving Air Traffic Control audio and diving deep into the dataset & training code to understand the process.

> **[Fine-Tune Whisper For Multilingual ASR with 🤗 Transformers](https://huggingface.co/blog/fine-tune-whisper)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

It was all working fine, I was able do everything locally like loading a pre-trained Whisper-tiny model and also my own dataset until recently when I updated the modules. I have been getting errors like these:

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/3/e/3e0ff636781aeeb1fdff900eafe2f60051f3ea6c.png)

I have tried falling back and testing the samples provided by the guides and they also seem to have broke and started giving the same error. I also tried running them on Google Colab where it will crash when trying to run a cell like this:

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/c/2/c2cf5b03a21c3eacb8d525f29c49f087a917a64e.png)

I would like to know if anyone else is also facing the same issue and if there are any solutions for it. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [October 21, 2025, 8:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315%2F2 "2025-10-21T08:37:37Z")

</div>

This error appears to stem from changes to the audio backend in the datasets library. The quickest workaround may be to install using `pip install datasets==3.6.0`. Additionally, if using version `4.0.0` or later, **builder script-type datasets can no longer be used directly from the Hub**. [You will need to find and use datasets that have been converted to the standard type beforehand](https://huggingface.co/lhoestq/datasets). If the original datasets were standard datasets, the latter issue should not be a problem.

Additionally, since Transformers underwent significant changes around version `4.49.0`, if you encounter errors related to Whisper, **rolling `transformers` back to version `4.48.3` or earlier would be the simplest workaround**. Of course, rewriting for the new version is preferable… but for a temporary fix.

* * *

Your error started after upgrading to **🤗 Datasets 4.x**. 4.x **switched audio decoding to TorchCodec** , which **loads FFmpeg at runtime** and also **requires a matching torch↔torchcodec pair**. Accessing or printing an `Audio` column now triggers that decode path, so if FFmpeg is missing or versions don’t line up, you see the probe-and-fail chain (`core7 → core6 → core5 → core4 ... Could not load torchcodec`). On Windows this is more brittle, and early 4.0 notes even said Windows was not supported yet. ([Hugging Face](https://huggingface.co/docs/datasets/en/audio_load "Load audio data"))

# Why it broke now

- **Behavior change in Datasets 4.x** : audio is decoded on access via TorchCodec + FFmpeg. Older 3.x used a different backend. Printing an example decodes it. ([Hugging Face](https://huggingface.co/docs/datasets/en/audio_load "Load audio data"))
- **New runtime requirements** : TorchCodec expects FFmpeg on the system and a compatible `torch` version. The README documents FFmpeg support and the torch↔torchcodec matrix. ([GitHub](https://github.com/meta-pytorch/torchcodec "GitHub - meta-pytorch/torchcodec: PyTorch media decoding and encoding"))
- **Windows caveat** : initial 4.0 release notes warned “not available for Windows yet; use datasets\<4.0.” This explains why your previously working Windows setup started failing after upgrade. ([GitHub](https://github.com/huggingface/datasets/releases "Releases · huggingface/datasets"))

# Typical root causes

1. **FFmpeg missing or wrong major**. TorchCodec supports FFmpeg majors **4–7** on all platforms, with **8** only on macOS/Linux. Missing or mismatched DLLs yields your exact probe sequence. ([GitHub](https://github.com/meta-pytorch/torchcodec "GitHub - meta-pytorch/torchcodec: PyTorch media decoding and encoding"))
2. **Torch↔TorchCodec mismatch**. Use the official matrix. Example: `torchcodec 0.7 ↔ torch 2.8`; `0.8 ↔ 2.9`. ([GitHub](https://github.com/meta-pytorch/torchcodec "GitHub - meta-pytorch/torchcodec: PyTorch media decoding and encoding"))
3. **Fresh 4.0 regressions**. Multiple reports show 3.x works then 4.x fails until TorchCodec+FFmpeg are added and versions pinned. ([GitHub](https://github.com/huggingface/datasets/issues/7678 "To support decoding audio data, please install 'torchcodec'."))

# Fixes and workarounds

Pick one path. Keep it pinned.

## A) Fastest unblock on Windows

```bash
# Downgrade Datasets to pre-TorchCodec behavior
pip install "datasets<4.0.0" # release notes flagged Windows not ready
# https://github.com/huggingface/datasets/releases/tag/4.0.0

```

([GitHub](https://github.com/huggingface/datasets/releases "Releases · huggingface/datasets"))

## B) Stay on Datasets 4.x and make it work

```bash
# Windows CPU: install FFmpeg and match versions
conda install -c conda-forge "ffmpeg<8" # README recommends conda FFmpeg
pip install "torch==2.8.*" "torchcodec==0.7.*" # matrix: 0.7 <-> 2.8
# https://github.com/meta-pytorch/torchcodec#installing-torchcodec

```

If you need CUDA on Windows, use the experimental conda package:

```bash
conda install -c conda-forge "ffmpeg<8" "torchcodec=*=*cuda*"
# https://github.com/meta-pytorch/torchcodec#installing-cuda-enabled-torchcodec

```

([GitHub](https://github.com/meta-pytorch/torchcodec "GitHub - meta-pytorch/torchcodec: PyTorch media decoding and encoding"))

## C) Linux or Colab

```bash
# Colab VM or Linux
apt-get update && apt-get install -y ffmpeg
pip install -U "datasets[audio]" "torch==2.8.*" "torchcodec==0.7.*"
# HF docs: audio decoding uses TorchCodec + FFmpeg
# https://huggingface.co/docs/datasets/en/audio_load

```

([Hugging Face](https://huggingface.co/docs/datasets/en/audio_load "Load audio data"))

## D) Bypass decoding while you train

Avoid TorchCodec until your env is fixed.

```python
from datasets import Audio
# Option 1: disable globally
ds = ds.decode(False) # https://huggingface.co/docs/datasets/en/package_reference/main_classes#datasets.Dataset.decode
# Option 2: disable per column
ds = ds.cast_column("audio", Audio(decode=False)) # https://huggingface.co/docs/datasets/en/about_dataset_features

```

These return paths/bytes rather than decoded arrays, so printing items won’t invoke TorchCodec. ([Hugging Face](https://huggingface.co/docs/datasets/en/package_reference/main_classes "Main classes"))

# Sanity checks

```bash
python - <<'PY'
import subprocess, sys
import torch
print("python:", sys.version)
print("torch:", torch. __version__ )
try:
    import torchcodec
    print("torchcodec:", torchcodec. __version__ )
except Exception as e:
    print("torchcodec import failed:", e)
subprocess.run(["ffmpeg", "-hide_banner", "-version"])
PY
# Matrix and FFmpeg policy:
# https://github.com/meta-pytorch/torchcodec#installing-torchcodec

```

([GitHub](https://github.com/meta-pytorch/torchcodec "GitHub - meta-pytorch/torchcodec: PyTorch media decoding and encoding"))

# Context from your linked thread

Your screenshots show Datasets 4.x decoding an `Audio` column, TorchCodec probing FFmpeg 7→6→5→4, then failing. That matches the new 4.x behavior and the FFmpeg/compatibility requirements above. ([Hugging Face Forums](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315 "Issue with TorchCodec when fine-tuning Whisper ASR model - Beginners - Hugging Face Forums"))

# Extra references and pitfalls

- **Release notes roundup** : breaking changes, removal of scripts, and the Windows note. Useful if other 4.0 changes surfaced after your upgrade. ([NewReleases](https://newreleases.io/project/github/huggingface/datasets/release/4.0.0 "huggingface/datasets 4.0.0 on GitHub"))
- **Known mismatch/FFmpeg pitfalls** : reports of brew-FFmpeg conflicts and version-mismatch guidance from TorchCodec maintainers. ([GitHub](https://github.com/pytorch/torchcodec/issues/570 "torchcodec not compatible with brew-installed ffmpeg #570"))
- **PyTorch/Torchaudio migration** : decoding is consolidating on TorchCodec (`load_with_torchcodec` exists as a bridge). Aligns your stack with where the ecosystem is going. ([PyTorch Documentation](https://docs.pytorch.org/audio/main/torchaudio.html "Torchaudio 2.8.0 documentation"))

---

<div class="post-metadata">

**Author:** ![junnyrong](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/junnyrong/32/54763_2.png) [@junnyrong](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjunnyrong)%5C
**Post date:** [October 22, 2025, 1:45am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315%2F3 "2025-10-22T01:45:23Z")

</div>

I was pulling my hair thinking it has something to do with TorchCodec’s versioning, it never came to me that it might have been datasets! Thank you so much for the detailed explanation too, that solved my issue 😄

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [October 22, 2025, 1:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-torchcodec-when-fine-tuning-whisper-asr-model%2F169315%2F4 "2025-10-22T13:45:34Z")

</div>

Closed on October 22, 2025, 1:45pm UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
