0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WhisperX ROCm7.2.0 インストール・動作確認ガイド

0
Last updated at Posted at 2026-03-29

WhisperX ROCm インストール・動作確認ガイド

対象環境

  • マシン:GMKtec NucBox EVO X2
  • CPU/APU:AMD Ryzen AI MAX+ 395(gfx1151 / Strix Halo)
  • OS:Ubuntu 24.04.4 LTS
  • ROCm:7.2.0(インストール済み前提)
  • Python:3.10

概要

本ドキュメントは、AMDのROCm環境でWhisperX(話者区別・タイムスタンプ付き音声文字起こし)を動作させるまでの全手順を記録したものです。gfx1151はAMDの公式ROCmサポートマトリクスに記載されていない非公式サポートですが、実用的に動作することを確認しています。

最終的に動作したコマンド

# 基本の文字起こし
whisperx audio.wav --model small --language en --device cuda --compute_type float16

# 話者区別あり(large-v2モデル)
whisperx audio.wav --model large-v2 --language en --compute_type float32 \
  --diarize --hf_token ${HF_TOKEN}

出力ファイル

audio.json / audio.srt / audio.tsv / audio.txt / audio.vtt が生成されます。


Step 1:Python 3.10 仮想環境の構築

Ubuntu 24.04 のデフォルトリポジトリには Python 3.10 が含まれていないため、deadsnakes PPA から追加します。

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-dev

# 仮想環境の作成と有効化
python3.10 -m venv ~/venv/whisperx-rocm
source ~/venv/whisperx-rocm/bin/activate
pip install --upgrade pip

注意: whisperX-rocm fork の .python-version3.10 を指定しているため、3.12ではなく 3.10 を使用します。


Step 2:ROCm 7.2.0 対応 PyTorch のインストール

pip install torch ではCUDA版が入ってしまいます。必ずAMD公式の manylinux wheel を直接指定してインストールします。

pip install \
  https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1+rocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl \
  https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0+rocm7.2.0.gitb919bd0c-cp310-cp310-linux_x86_64.whl \
  https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchaudio-2.9.0+rocm7.2.0.gite3c6ee2b-cp310-cp310-linux_x86_64.whl \
  https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1+rocm7.2.0.gita272dfa8-cp310-cp310-linux_x86_64.whl

ファイル名について: torchvision は 0.24.00.25.0 ではない)です。最新のURLは AMD公式ドキュメント で確認してください。

動作確認

python3 -c "
import torch
print('Torch version:', torch.__version__)
print('CUDA(HIP) available:', torch.cuda.is_available())
if torch.cuda.is_available():
    print('Device:', torch.cuda.get_device_name(0))
"

CUDA(HIP) available: TrueAMD Radeon Graphics が表示されればOKです。


Step 3:WhisperX ROCm fork のインストール

mkdir -p ~/whisperx && cd ~/whisperx
git clone -b rocm https://github.com/paralin/whisperX-rocm.git
cd whisperX-rocm

# --no-deps でROCm版torchが上書きされるのを防ぐ
pip install -e . --no-deps

重要: --no-deps を省略すると pip install -e . がCUDA版 torch 2.8 を引っ張ってきてROCm版を上書きします。whisperx 3.7.4 requires torch~=2.8.0 という依存関係の警告は無視して問題ありません。


Step 4:ctranslate2 ROCm版のビルド(ソースビルド)

faster-whisper のバックエンドである ctranslate2 はROCm版を自前でビルドする必要があります。

4-1. 依存パッケージのインストール

sudo apt install -y cmake libopenblas-dev

4-2. ソースの取得

cd ~/whisperx
git clone --recurse-submodules https://github.com/paralin/ctranslate2-rocm.git
cd ctranslate2-rocm
git checkout rocm
mkdir -p build && cd build

4-3. CMake設定

cmake .. \
  -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
  -DWITH_HIP=ON \
  -DWITH_MKL=OFF \
  -DWITH_OPENBLAS=ON \
  -DCMAKE_HIP_ARCHITECTURES=gfx1151 \
  -DCMAKE_BUILD_TYPE=Release \
  -DOPENMP_RUNTIME=COMP \
  -DCMAKE_HIP_COMPILER=/opt/rocm/lib/llvm/bin/clang++ \
  -DCMAKE_CXX_COMPILER=/opt/rocm/lib/llvm/bin/clang++ \
  -DCMAKE_C_COMPILER=/opt/rocm/lib/llvm/bin/clang \
  -DCMAKE_PREFIX_PATH=/opt/rocm \
  -DBUILD_CLI=OFF \
  -DCMAKE_CXX_FLAGS="-Wno-deprecated-literal-operator" \
  -DCMAKE_C_FLAGS="-Wno-deprecated-literal-operator"

4-4. ビルド前のソースパッチ(Clang 22 対応)

CMake 4.x + Clang 22(ROCm 7.2付属)で expected expression エラーが発生するため、2ファイルの末尾カンマを削除します。

sed -i 's/model\.use_flash_attention(),$/model.use_flash_attention()/' \
  ~/whisperx/ctranslate2-rocm/src/layers/whisper.cc

sed -i 's/_use_flash_attention,$/_use_flash_attention/' \
  ~/whisperx/ctranslate2-rocm/src/layers/transformer.cc

4-5. ビルド・インストール

make -j$(nproc)
sudo make install
sudo ldconfig

4-6. Python バインディングのインストール

cd ~/whisperx/ctranslate2-rocm/python
pip install pybind11
pip install -r install_requirements.txt

export CTRANSLATE2_ROOT=/usr/local
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

pip install . --no-build-isolation

4-7. libomp シンボリックリンクの作成

sudo apt install -y libomp-dev
sudo ln -s /lib/x86_64-linux-gnu/libomp.so.5 /lib/x86_64-linux-gnu/libomp.so
sudo ldconfig

4-8. 動作確認(ホームディレクトリから実行)

cd ~
python3 -c "
import ctranslate2
print(ctranslate2.__version__)
print('CUDA devices:', ctranslate2.get_cuda_device_count())
"

CUDA devices: 1 が表示されればOKです。

注意: ctranslate2-rocm/python/ ディレクトリ内で実行するとソースディレクトリが優先されて正しく動作しません。必ずホームディレクトリ等から実行してください。


Step 5:互換性パッチの適用

torchaudio 2.9 で削除されたAPIを使っている依存ライブラリにパッチを当てます。

5-1. pyannote: AudioMetaData(io.py)

# Any のインポートを追加
sed -i '1s/^/from typing import Any\n/' \
  ~/venv/whisperx-rocm/lib/python3.10/site-packages/pyannote/audio/core/io.py

# AudioMetaData を Any に置換
sed -i 's/) -> torchaudio\.AudioMetaData:/) -> Any:/' \
  ~/venv/whisperx-rocm/lib/python3.10/site-packages/pyannote/audio/core/io.py
sed -i 's/info : torchaudio\.AudioMetaData/info : Any/' \
  ~/venv/whisperx-rocm/lib/python3.10/site-packages/pyannote/audio/core/io.py

5-2. pyannote: list_audio_backends(io.py)

python3 << 'EOF'
import re
filepath = "/home/$USER/venv/whisperx-rocm/lib/python3.10/site-packages/pyannote/audio/core/io.py"
with open(filepath, 'r') as f:
    content = f.read()
# 8スペースインデントのパターン
old = "        backends = (\n            torchaudio.list_audio_backends()\n        )  # e.g ['ffmpeg', 'soundfile', 'sox']\n        backend = \"soundfile\" if \"soundfile\" in backends else backends[0]"
new = '        backend = "soundfile"'
content = content.replace(old, new)
# 12スペースインデントのパターン
old2 = "            backends = (\n                torchaudio.list_audio_backends()\n            )  # e.g ['ffmpeg', 'soundfile', 'sox']\n            backend = \"soundfile\" if \"soundfile\" in backends else backends[0]"
new2 = '            backend = "soundfile"'
content = content.replace(old2, new2)
with open(filepath, 'w') as f:
    f.write(content)
print("Done")
EOF

5-3. speechbrain: list_audio_backends

sed -i 's/torchaudio\.list_audio_backends()/["soundfile"]/g' \
  ~/venv/whisperx-rocm/lib/python3.10/site-packages/speechbrain/utils/torch_audio_backend.py

5-4. pyannote: AudioMetaData(mixins.py)

python3 << 'EOF'
filepath = "/home/$USER/venv/whisperx-rocm/lib/python3.10/site-packages/pyannote/audio/tasks/segmentation/mixins.py"
with open(filepath, 'r') as f:
    content = f.read()
content = content.replace(
    'from torchaudio import AudioMetaData',
    'from types import SimpleNamespace\ndef AudioMetaData(**kwargs): return SimpleNamespace(**kwargs)'
)
with open(filepath, 'w') as f:
    f.write(content)
print("Done")
EOF

5-5. lightning_fabric: weights_only エラー

PyTorch 2.6以降で weights_only のデフォルトが True に変わり、omegaconf.listconfig.ListConfig を含む pyannote の VAD チェックポイントがロードできなくなった問題への対処です。

対象ファイル:
~/venv/whisperx-rocm/lib/python3.10/site-packages/lightning_fabric/utilities/cloud_io.py

     fs = get_filesystem(path_or_url)
     with fs.open(path_or_url, "rb") as f:
+        if weights_only is None:
+            weights_only = False
         return torch.load(
             f,
             map_location=map_location,
             weights_only=weights_only,
         )
# sedで適用する場合
CLOUD_IO=~/venv/whisperx-rocm/lib/python3.10/site-packages/lightning_fabric/utilities/cloud_io.py
sed -i 's/        return torch\.load(/        if weights_only is None:\n            weights_only = False\n        return torch.load(/' "$CLOUD_IO"

5-6. pyannote: use_auth_token → token

新しい huggingface_hubhf_hub_download()use_auth_token 引数が廃止され token= に変更された問題への対処です。関数シグネチャは変えず、呼び出し箇所のみ変更します。

対象ファイル:

  • pyannote/audio/core/pipeline.py 行102
  • pyannote/audio/core/model.py 行618, 655
       hf_hub_download(
           ...,
-          use_auth_token=use_auth_token,
+          token=use_auth_token,
       )
PYANNOTE_BASE=~/venv/whisperx-rocm/lib/python3.10/site-packages/pyannote/audio/core

# pipeline.py
sed -i 's/use_auth_token=use_auth_token/token=use_auth_token/' "$PYANNOTE_BASE/pipeline.py"

# model.py
sed -i 's/use_auth_token=use_auth_token/token=use_auth_token/' "$PYANNOTE_BASE/model.py"

Step 6:HuggingFace トークンの設定(話者区別を使う場合)

  1. huggingface.co/settings/tokens でトークンを取得
  2. 以下のモデルのUser Agreementを承認:
export HF_TOKEN="hf_xxxxxxxxxxxx"

実行コマンド

# 基本の文字起こし(GPU使用)
whisperx audio.wav --model small --language ja --device cuda --compute_type float16

# 話者区別あり
whisperx audio.wav --model large-v2 --language ja \
  --compute_type float32 --diarize --hf_token ${HF_TOKEN}

# メモリ不足の場合
whisperx audio.wav --model medium --language ja \
  --compute_type float16 --batch_size 8 --device cuda

環境の再起動後

仮想環境を有効化するたびに以下を設定します:

source ~/venv/whisperx-rocm/bin/activate
export LD_LIBRARY_PATH=/usr/local/lib:/opt/rocm/lib:$LD_LIBRARY_PATH
export HF_TOKEN="hf_xxxxxxxxxxxx"

トラブルシューティング

症状 原因 対処
CUDA available: False かつ cu128 バージョン CUDA版torchが入っている pip uninstall torch → ROCm wheel を再インストール
CUDA available: False かつ ROCm版torch ディレクトリ問題またはHSA設定 export HSA_OVERRIDE_GFX_VERSION=11.5.1 を試す
libomp.so: cannot open shared object file libompのシンボリックリンク不足 sudo ln -s libomp.so.5 libomp.so
CUDA devices: 0 (ctranslate2) ソースディレクトリで実行している cd ~ してから実行
list_audio_backends AttributeError torchaudio 2.9との非互換 Step 5のパッチを適用
AudioMetaData ImportError torchaudio 2.9との非互換 Step 5のパッチを適用
use_auth_token TypeError huggingface_hub更新 Step 5-6のパッチを適用

動作確認済み構成

コンポーネント バージョン
ROCm 7.2.0
Python 3.10
PyTorch 2.9.1+rocm7.2.0
torchaudio 2.9.0+rocm7.2.0
ctranslate2 4.6.2(ROCm版ソースビルド)
whisperx 3.7.4(paralin/whisperX-rocm rocmブランチ)
pyannote.audio 3.4.0

まとめ

Claude codeなしにはできませんでした。ホント便利

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?