1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Qwen2.5-VL-7B-InstructをvLLMで動かす方法

Last updated at Posted at 2025-02-05

初めに

最近、大規模言語モデル(LLM)の推論を高速化するためのライブラリとして、vLLMが注目を集めています。今回は、Qwen2.5-VL-7B-InstructというモデルをvLLMを使って動かす方法を紹介します。

環境構築

まず、必要な環境を構築します。以下のコマンドを実行して、新しいconda環境を作成し、アクティベートします。

conda create -n vllm_qwen2_5_vl python=3.12 -y
conda activate vllm_qwen2_5_vl

vLLMのインストール

次に、vLLMをインストールします。

pip install vllm

依存ライブラリのインストール

vLLMを動かすために必要な依存ライブラリをインストールします。

今後、vLLMのGithub Repoにマージされたら、pip install vllmだけを実行すればよいです。

pip install "git+https://github.com/huggingface/transformers"
pip install flash-attn --no-build-isolation

また、Hugging Face Hubからモデルをダウンロードするためのツールもインストールします。

pip install "huggingface_hub[hf_transfer]"

モデルのダウンロード

Qwen2.5-VL-7B-InstructモデルをHugging Face Hubからダウンロードします。

HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download Qwen/Qwen2.5-VL-7B-Instruct

vLLMサーバーの起動

最後に、vLLMを使ってモデルをサーバーとして起動します。以下のコマンドを実行してください。

VLLM_USE_V1=1 \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
vllm serve Qwen/Qwen2.5-VL-7B-Instruct --trust-remote-code --served-model-name gpt-4 --gpu-memory-utilization 0.98 --tensor-parallel-size 4 --port 8000

このコマンドでは、以下のオプションを指定しています。

  • --trust-remote-code: リモートコードを信頼して実行します。
  • --served-model-name gpt-4: サーバーで提供するモデルの名前をgpt-4とします。
  • --gpu-memory-utilization 0.98: GPUメモリの使用率を98%に設定します。
  • --tensor-parallel-size 4: テンソル並列処理のサイズを4に設定します。
  • --port 8000: サーバーをポート8000で起動します。

まとめ

以上で、Qwen2.5-VL-7B-InstructをvLLMを使って動かすための手順を紹介しました。vLLMを使うことで、大規模言語モデルの推論を高速化することができます。ぜひ試してみてください!

参考

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?