ghs를 사용하여 Lama b BF를 실행하는 방법
Lambda 연구소는 더 많은 사람들이 ARM 도구에 익숙해지도록 하기 위해 현재 GH200을 절반만 보유하고 있습니다. 이는 실제로 가장 큰 오픈 소스 모델을 실행할 여유가 있다는 것을 의미합니다! 유일한 주의 사항은 때때로 소스에서 무언가를 빌드해야 한다는 것입니다. GH200에서 Lama 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 캐시 설정
파이썬 환경과 모델 가중치를 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
콘다 환경 만들기
모든 머신에서 정확히 동일한 명령을 신중하게 수행하는 대신 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는 조금 더 빠르게 시작하고 몇 가지 추가 기능을 갖춘 vllm의 포크입니다.
openai 호환 추론 API와 모델 자체를 실행합니다.
토치, 트리톤, 플래시 어텐션이 필요합니다.
pytorch.org에서 aarch64 토치 빌드를 얻을 수 있습니다(직접 빌드하고 싶지는 않습니다).
나머지 두 개는 직접 만들거나 제가 만든 바퀴를 사용할 수 있습니다.
소스에서 빌드하는 경우 세 가지 다른 시스템에서 triton, flash-attention 및 aphrodite에 대한 python setup.py bdist_wheel을 병렬로 실행하여 약간의 시간을 절약할 수 있습니다. 아니면 같은 기계에서 하나씩 수행할 수도 있습니다.
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'
하나의 터미널 탭에서 아프로디테를 시작할 수 있습니다:
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")'
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'
텍스트 속도는 적당하지만 코드 속도는 약간 느립니다. 8xH100 서버 2대를 연결하면 초당 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를 사용하여 Lama b BF를 실행하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 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
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Linux 터미널에서 Python 버전을 보려고 할 때 Linux 터미널에서 Python 버전을 볼 때 권한 문제에 대한 솔루션 ... Python을 입력하십시오 ...

Fiddlerevery Where를 사용할 때 Man-in-the-Middle Reading에 Fiddlereverywhere를 사용할 때 감지되는 방법 ...

Python의 Pandas 라이브러리를 사용할 때는 구조가 다른 두 데이터 프레임 사이에서 전체 열을 복사하는 방법이 일반적인 문제입니다. 두 개의 dats가 있다고 가정 해

Uvicorn은 HTTP 요청을 어떻게 지속적으로 듣습니까? Uvicorn은 ASGI를 기반으로 한 가벼운 웹 서버입니다. 핵심 기능 중 하나는 HTTP 요청을 듣고 진행하는 것입니다 ...

10 시간 이내에 컴퓨터 초보자 프로그래밍 기본 사항을 가르치는 방법은 무엇입니까? 컴퓨터 초보자에게 프로그래밍 지식을 가르치는 데 10 시간 밖에 걸리지 않는다면 무엇을 가르치기로 선택 하시겠습니까?

Linux 터미널에서 Python 사용 ...

Investing.com의 크롤링 전략 이해 많은 사람들이 종종 Investing.com (https://cn.investing.com/news/latest-news)에서 뉴스 데이터를 크롤링하려고합니다.
