ghs で llama b bf を実行する方法
Lambda labs では、より多くの人に ARM ツールに慣れてもらうために、現在 GH200 を半額で提供しています。これは、最大規模のオープンソース モデルを実際に実行する余裕がある可能性があることを意味します。唯一の注意点は、ソースから何かをビルドする必要がある場合があるということです。ここでは、GH200 でラマ 405b を完全な精度で実行する方法を説明します。
インスタンスの作成
Llama 405b は約 750GB なので、それを実行するには約 10 個の 96GB GPU が必要です。 (GH200 は、かなり優れた CPU-GPU メモリ スワップ速度を備えています。これが GH200 の重要な点のようなものです。そのため、3 つまでしか使用できません。トークンごとの時間はひどいものになりますが、合計スループットは許容範囲内です。バッチ処理を行っていることになります。) lambda labs にサインインし、GH200 インスタンスを多数作成します。 すべてに同じ共有ネットワーク ファイルシステムを与えるようにしてください。
IP アドレスを ~/ips.txt に保存します。
一括 SSH 接続ヘルパー
私は、kubernetes や slurm のような派手なものよりも、直接 bash と ssh を好みます。何人かのヘルパーがいればなんとかなります。
# skip fingerprint confirmation for ip in $(cat ~/ips.txt); do echo "doing $ip" ssh-keyscan $ip >> ~/.ssh/known_hosts done function run_ip() { ssh -i ~/.ssh/lambda_id_ed25519 ubuntu@$ip -- stdbuf -oL -eL bash -l -c "$(printf "%q" "$*")" < /dev/null } function run_k() { ip=$(sed -n "$k"p ~/ips.txt) run_ip "$@"; } function runhead() { ip="$(head -n1 ~/ips.txt)" run_ip "$@"; } function run_ips() { for ip in $ips; do ip=$ip run_ip "$@" |& sed "s/^/$ip\t /" & # pids="$pids $!" done wait &> /dev/null } function runall() { ips="$(cat ~/ips.txt)" run_ips "$@"; } function runrest() { ips="$(tail -n+2 ~/ips.txt)" run_ips "$@"; } function ssh_k() { ip=$(sed -n "$k"p ~/ips.txt) ssh -i ~/.ssh/lambda_id_ed25519 ubuntu@$ip } alias ssh_head='k=1 ssh_k' function killall() { pkill -ife '.ssh/lambda_id_ed25519' sleep 1 pkill -ife -9 '.ssh/lambda_id_ed25519' while [[ -n "$(jobs -p)" ]]; do fg || true; done }
NFSキャッシュを設定する
Python 環境とモデルの重みを NFS に置きます。キャッシュすると読み込みが大幅に速くなります。
# First, check the NFS works. # runall ln -s my_other_fs_name shared runhead 'echo world > shared/hello' runall cat shared/hello # Install and enable cachefilesd runall sudo apt-get update runall sudo apt-get install -y cachefilesd runall "echo ' RUN=yes CACHE_TAG=mycache CACHE_BACKEND=Path=/var/cache/fscache CACHEFS_RECLAIM=0 ' | sudo tee -a /etc/default/cachefilesd" runall sudo systemctl restart cachefilesd runall 'sudo journalctl -u cachefilesd | tail -n2' # Set the "fsc" option on the NFS mount runhead cat /etc/fstab # should have mount to ~/shared runall cp /etc/fstab etc-fstab-bak.txt runall sudo sed -i 's/,proto=tcp,/,proto=tcp,fsc,/g' /etc/fstab runall cat /etc/fstab # Remount runall sudo umount /home/ubuntu/wash2 runall sudo mount /home/ubuntu/wash2 runall cat /proc/fs/nfsfs/volumes # FSC column should say "yes" # Test cache speedup runhead dd if=/dev/urandom of=shared/bigfile bs=1M count=8192 runall dd if=shared/bigfile of=/dev/null bs=1M # First one takes 8 seconds runall dd if=shared/bigfile of=/dev/null bs=1M # Seond takes 0.6 seconds
conda環境を作成する
すべてのマシンでまったく同じコマンドを慎重に実行する代わりに、NFS で conda 環境を使用し、ヘッド ノードで制御するだけです。
# We'll also use a shared script instead of changing ~/.profile directly. # Easier to fix mistakes that way. runhead 'echo ". /opt/miniconda/etc/profile.d/conda.sh" >> shared/common.sh' runall 'echo "source /home/ubuntu/shared/common.sh" >> ~/.profile' runall which conda # Create the environment runhead 'conda create --prefix ~/shared/311 -y python=3.11' runhead '~/shared/311/bin/python --version' # double-check that it is executable runhead 'echo "conda activate ~/shared/311" >> shared/common.sh' runall which python
aphrodite の依存関係をインストールする
Aphrodite は vllm のフォークであり、起動が少し速くなり、追加機能がいくつかあります。
これは、openai 互換の推論 API とモデル自体を実行します。
トーチ、トリトン、フラッシュの注意が必要です。
aarch64 torch ビルドは pytorch.org から入手できます (自分でビルドする必要はありません)。
残りの 2 つは自分で作成するか、私が作成したホイールを使用することができます。
ソースからビルドする場合は、triton、flash-attention、および aphrodite の python setup.py bdist_wheel を 3 つの異なるマシンで並行して実行することで、時間を少し節約できます。または、同じマシン上で 1 つずつ実行することもできます。
runhead pip install 'numpy<2' torch==2.4.0 --index-url 'https://download.pytorch.org/whl/cu124' # fix for "libstdc++.so.6: version `GLIBCXX_3.4.30' not found" error: runhead conda install -y -c conda-forge libstdcxx-ng=12 runhead python -c 'import torch; print(torch.tensor(2).cuda() + 2, "torch ok")'
トリトンと車輪からのフラッシュ注意
runhead pip install 'https://github.com/qpwo/lambda-gh200-llama-405b-tutorial/releases/download/v0.1/triton-3.2.0+git755d4164-cp311-cp311-linux_aarch64.whl' runhead pip install 'https://github.com/qpwo/lambda-gh200-llama-405b-tutorial/releases/download/v0.1/aphrodite_flash_attn-2.6.1.post2-cp311-cp311-linux_aarch64.whl'
ソースからのトリトン
k=1 ssh_k # ssh into first machine pip install -U pip setuptools wheel ninja cmake setuptools_scm git config --global feature.manyFiles true # faster clones git clone https://github.com/triton-lang/triton.git ~/shared/triton cd ~/shared/triton/python git checkout 755d4164 # <-- optional, tested versions # Note that ninja already parallelizes everything to the extent possible, # so no sense trying to change the cmake flags or anything. python setup.py bdist_wheel pip install --no-deps dist/*.whl # good idea to download this too for later python -c 'import triton; print("triton ok")'
ソースからのフラッシュ アテンション
k=2 ssh_k # go into second machine git clone https://github.com/AlpinDale/flash-attention ~/shared/flash-attention cd ~/shared/flash-attention python setup.py bdist_wheel pip install --no-deps dist/*.whl python -c 'import aphrodite_flash_attn; import aphrodite_flash_attn_2_cuda; print("flash attn ok")'
アフロディーテをインストールする
私のホイールを使用することも、自分で組み立てることもできます。
車輪からのアフロディーテ
# skip fingerprint confirmation for ip in $(cat ~/ips.txt); do echo "doing $ip" ssh-keyscan $ip >> ~/.ssh/known_hosts done function run_ip() { ssh -i ~/.ssh/lambda_id_ed25519 ubuntu@$ip -- stdbuf -oL -eL bash -l -c "$(printf "%q" "$*")" < /dev/null } function run_k() { ip=$(sed -n "$k"p ~/ips.txt) run_ip "$@"; } function runhead() { ip="$(head -n1 ~/ips.txt)" run_ip "$@"; } function run_ips() { for ip in $ips; do ip=$ip run_ip "$@" |& sed "s/^/$ip\t /" & # pids="$pids $!" done wait &> /dev/null } function runall() { ips="$(cat ~/ips.txt)" run_ips "$@"; } function runrest() { ips="$(tail -n+2 ~/ips.txt)" run_ips "$@"; } function ssh_k() { ip=$(sed -n "$k"p ~/ips.txt) ssh -i ~/.ssh/lambda_id_ed25519 ubuntu@$ip } alias ssh_head='k=1 ssh_k' function killall() { pkill -ife '.ssh/lambda_id_ed25519' sleep 1 pkill -ife -9 '.ssh/lambda_id_ed25519' while [[ -n "$(jobs -p)" ]]; do fg || true; done }
ソースからのアフロディーテ
# First, check the NFS works. # runall ln -s my_other_fs_name shared runhead 'echo world > shared/hello' runall cat shared/hello # Install and enable cachefilesd runall sudo apt-get update runall sudo apt-get install -y cachefilesd runall "echo ' RUN=yes CACHE_TAG=mycache CACHE_BACKEND=Path=/var/cache/fscache CACHEFS_RECLAIM=0 ' | sudo tee -a /etc/default/cachefilesd" runall sudo systemctl restart cachefilesd runall 'sudo journalctl -u cachefilesd | tail -n2' # Set the "fsc" option on the NFS mount runhead cat /etc/fstab # should have mount to ~/shared runall cp /etc/fstab etc-fstab-bak.txt runall sudo sed -i 's/,proto=tcp,/,proto=tcp,fsc,/g' /etc/fstab runall cat /etc/fstab # Remount runall sudo umount /home/ubuntu/wash2 runall sudo mount /home/ubuntu/wash2 runall cat /proc/fs/nfsfs/volumes # FSC column should say "yes" # Test cache speedup runhead dd if=/dev/urandom of=shared/bigfile bs=1M count=8192 runall dd if=shared/bigfile of=/dev/null bs=1M # First one takes 8 seconds runall dd if=shared/bigfile of=/dev/null bs=1M # Seond takes 0.6 seconds
すべてのインストールが成功したかどうかを確認する
# We'll also use a shared script instead of changing ~/.profile directly. # Easier to fix mistakes that way. runhead 'echo ". /opt/miniconda/etc/profile.d/conda.sh" >> shared/common.sh' runall 'echo "source /home/ubuntu/shared/common.sh" >> ~/.profile' runall which conda # Create the environment runhead 'conda create --prefix ~/shared/311 -y python=3.11' runhead '~/shared/311/bin/python --version' # double-check that it is executable runhead 'echo "conda activate ~/shared/311" >> shared/common.sh' runall which python
重みをダウンロードする
https://huggingface.co/meta-llama/Llama-3.1-405B-Instruct に移動し、適切な権限があることを確認してください。承認には通常 1 時間ほどかかります。 https://huggingface.co/settings/tokens
からトークンを取得します。
runhead pip install 'numpy<2' torch==2.4.0 --index-url 'https://download.pytorch.org/whl/cu124' # fix for "libstdc++.so.6: version `GLIBCXX_3.4.30' not found" error: runhead conda install -y -c conda-forge libstdcxx-ng=12 runhead python -c 'import torch; print(torch.tensor(2).cuda() + 2, "torch ok")'
ラマ 405b を実行します
ray を起動することで、サーバーが相互に認識できるようにします。
runhead pip install 'https://github.com/qpwo/lambda-gh200-llama-405b-tutorial/releases/download/v0.1/triton-3.2.0+git755d4164-cp311-cp311-linux_aarch64.whl' runhead pip install 'https://github.com/qpwo/lambda-gh200-llama-405b-tutorial/releases/download/v0.1/aphrodite_flash_attn-2.6.1.post2-cp311-cp311-linux_aarch64.whl'
1 つのターミナル タブで aphrodite を開始できます:
k=1 ssh_k # ssh into first machine pip install -U pip setuptools wheel ninja cmake setuptools_scm git config --global feature.manyFiles true # faster clones git clone https://github.com/triton-lang/triton.git ~/shared/triton cd ~/shared/triton/python git checkout 755d4164 # <-- optional, tested versions # Note that ninja already parallelizes everything to the extent possible, # so no sense trying to change the cmake flags or anything. python setup.py bdist_wheel pip install --no-deps dist/*.whl # good idea to download this too for later python -c 'import triton; print("triton ok")'
次に、2 番目の端末でローカル マシンからクエリを実行します。
k=2 ssh_k # go into second machine git clone https://github.com/AlpinDale/flash-attention ~/shared/flash-attention cd ~/shared/flash-attention python setup.py bdist_wheel pip install --no-deps dist/*.whl python -c 'import aphrodite_flash_attn; import aphrodite_flash_attn_2_cuda; print("flash attn ok")'
runhead pip install 'https://github.com/qpwo/lambda-gh200-llama-405b-tutorial/releases/download/v0.1/aphrodite_engine-0.6.4.post1-cp311-cp311-linux_aarch64.whl'
テキストとしては良いペースですが、コードとしては少し遅いです。 2 つの 8xH100 サーバーを接続すると、1 秒あたり 16 トークンに近づきますが、コストが 3 倍かかります。
さらに読む
- 理論的には、Lambda labs API https://cloud.lambdalabs.com/api/v1/docs を使用してインスタンスの作成と破棄をスクリプト化できます。
- アフロディーテのドキュメント https://aphrodite.pygmalion.chat/
- vllm docs (API はほぼ同じ) https://docs.vllm.ai/en/latest/
以上がghs で llama b bf を実行する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











LinuxターミナルでPythonバージョンを表示する際の許可の問題の解決策PythonターミナルでPythonバージョンを表示しようとするとき、Pythonを入力してください...

fiddlereveryversings for the-middleの測定値を使用するときに検出されないようにする方法

PythonのPandasライブラリを使用する場合、異なる構造を持つ2つのデータフレーム間で列全体をコピーする方法は一般的な問題です。 2つのデータがあるとします...

10時間以内にコンピューター初心者プログラミングの基本を教える方法は?コンピューター初心者にプログラミングの知識を教えるのに10時間しかない場合、何を教えることを選びますか...

UvicornはどのようにしてHTTPリクエストを継続的に聞きますか? Uvicornは、ASGIに基づく軽量のWebサーバーです。そのコア機能の1つは、HTTPリクエストを聞いて続行することです...

Investing.comの反クラウリング戦略を理解する多くの人々は、Investing.com(https://cn.investing.com/news/latest-news)からのニュースデータをクロールしようとします。
