NVIDIA RTX A6000 2枚を用いた環境で、vLLMを使用して openai/gpt-oss-20b を並列推論(Tensor Parallelism)させ、かつKVキャッシュ(Prefix Caching)を有効化して高速に動作させる手順をまとめます。
Linux個人環境(一般ユーザ権限)でPython環境を構築するためにMinicondaを利用します。 すでにConda環境がある場合は、このステップをスキップしてください。
cd ~/Downloads
# x86_64向け (ARM系の場合はURLを変更してください)
wget [https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh)
bash Miniconda3-latest-Linux-x86_64.sh
対話モードで以下のように回答します:
yes~/miniconda3 (デフォルト推奨)yes# Bashの場合
source ~/.bashrc
# Zshの場合
source ~/.zshrc
# バージョン確認
conda --version
conda-forge を優先設定にしておくと、パッケージ依存解決がスムーズになります。
conda config --add channels conda-forge
conda config --set channel_priority strict
vLLM用の仮想環境を作成し、必要なライブラリをインストールします。
conda create -n vllm python=3.11 -y
conda activate vllm
vLLM本体と、Hugging Face Hubへのログインツールを入れます。
pip install vllm huggingface_hub
モデルのダウンロード権限があるトークンを環境変数に設定します。
export HUGGINGFACE_HUB_TOKEN=あなたのトークン文字列
以下のコマンドでサーバーを立ち上げます。
--tensor-parallel-size 2)--enable-prefix-caching)python -m vllm.entrypoints.openai.api_server \
--model openai/gpt-oss-20b \
--tensor-parallel-size 2 \
--max-model-len 8192 \
--gpu-memory-utilization 0.95 \
--dtype bfloat16 \
--trust-remote-code \
--enforce-eager \
--enable-prefix-caching
| パラメータ | 説明 |
|---|---|
--tensor-parallel-size 2 |
GPUを2枚使用してモデルを分割ロードします(並列化)。 |
--enable-prefix-caching |
プロンプトのKVキャッシュを再利用し、処理を高速化します。 |
--gpu-memory-utilization 0.95 |
GPUメモリの95%をvLLMに使用させます。 |
--enforce-eager |
CUDAグラフ関連のエラーが出る場合にEagerモードで実行させます(安定性重視)。 |