Lambda labs has half-off GH200s right now to get more people used to the ARM tooling. This means you can maybe actually afford to run the biggest open-source models! The only caveat is that you'll have to occasionally build something from source. Here's how I got llama 405b running with full precision on the GH200s.
Create instances
Llama 405b is about 750GB so you want about 10 96GB GPUS to run it. (The GH200 has pretty good CPU-GPU memory swapping speed -- that's kind of the whole point of the GH200 -- so you can use as few as 3. Time-per-token will be terrible, but total throughput is acceptable, if you're doing batch-processing.) Sign in to lambda labs and create a bunch of GH200 instances. Make sure to give them all the same shared network filesystem.
Save the ip addresses to ~/ips.txt.
Bulk ssh connection helpers
I prefer direct bash & ssh over anything fancy like kubernetes or slurm. It's manageable with some helpers.
# 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 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 }
Set up NFS cache
We'll be putting the python environment and the model weights in the NFS. It will load much faster if we cache it.
# 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
Create conda environment
Instead of carefully doing the exact same commands on every machine, we can use a conda environment in the NFS and just control it with the head node.
# 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
Install aphrodite dependencies
Aphrodite is a fork of vllm that starts a bit quicker and has some extra features.
It will run the openai-compatible inference API and the model itself.
You need torch, triton, and flash-attention.
You can get aarch64 torch builds from pytorch.org (you do not want to build it yourself).
The other two you can either build yourself or use the wheel I made.
If you build from source, then you can save a bit of time by running the python setup.py bdist_wheel for triton, flash-attention, and aphrodite in parallel on three different machines. Or you can do them one-by-one on the same machine.
runhead pip install 'numpy <h4> triton & flash attention from wheels </h4> <pre class="brush:php;toolbar:false">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'
triton from source
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 # <h4> flash-attention from source </h4> <pre class="brush:php;toolbar:false">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")'
Install aphrodite
You can use my wheel or build it yourself.
aphrodite from wheel
# 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 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 }
aphrodite from source
# 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
Check all installs succeeded
# 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
Download the weights
Go to https://huggingface.co/meta-llama/Llama-3.1-405B-Instruct and make sure you have the right permissions. The approval usually takes about an hour. Get a token from https://huggingface.co/settings/tokens
runhead pip install 'numpy <h3> run llama 405b </h3> <p>We'll make the servers aware of each other by starting ray.<br> </p> <pre class="brush:php;toolbar:false">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'
We can start aphrodite in one terminal tab:
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 # <p>And run a query from the local machine in a second terminal:<br> </p> <pre class="brush:php;toolbar:false">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'
A good pace for text, but a bit slow for code. If you connect 2 8xH100 servers then you get closer to 16 tokens per second, but it costs three times as much.
further reading
- theoretically you can script instance creation & destruction with the lambda labs API https://cloud.lambdalabs.com/api/v1/docs
- aphrodite docs https://aphrodite.pygmalion.chat/
- vllm docs (api is mostly the same) https://docs.vllm.ai/en/latest/
The above is the detailed content of How to run llama b bfwith ghs. For more information, please follow other related articles on the PHP Chinese website!

This tutorial demonstrates how to use Python to process the statistical concept of Zipf's law and demonstrates the efficiency of Python's reading and sorting large text files when processing the law. You may be wondering what the term Zipf distribution means. To understand this term, we first need to define Zipf's law. Don't worry, I'll try to simplify the instructions. Zipf's Law Zipf's law simply means: in a large natural language corpus, the most frequently occurring words appear about twice as frequently as the second frequent words, three times as the third frequent words, four times as the fourth frequent words, and so on. Let's look at an example. If you look at the Brown corpus in American English, you will notice that the most frequent word is "th

This article explains how to use Beautiful Soup, a Python library, to parse HTML. It details common methods like find(), find_all(), select(), and get_text() for data extraction, handling of diverse HTML structures and errors, and alternatives (Sel

This article compares TensorFlow and PyTorch for deep learning. It details the steps involved: data preparation, model building, training, evaluation, and deployment. Key differences between the frameworks, particularly regarding computational grap

Python's statistics module provides powerful data statistical analysis capabilities to help us quickly understand the overall characteristics of data, such as biostatistics and business analysis. Instead of looking at data points one by one, just look at statistics such as mean or variance to discover trends and features in the original data that may be ignored, and compare large datasets more easily and effectively. This tutorial will explain how to calculate the mean and measure the degree of dispersion of the dataset. Unless otherwise stated, all functions in this module support the calculation of the mean() function instead of simply summing the average. Floating point numbers can also be used. import random import statistics from fracti

Serialization and deserialization of Python objects are key aspects of any non-trivial program. If you save something to a Python file, you do object serialization and deserialization if you read the configuration file, or if you respond to an HTTP request. In a sense, serialization and deserialization are the most boring things in the world. Who cares about all these formats and protocols? You want to persist or stream some Python objects and retrieve them in full at a later time. This is a great way to see the world on a conceptual level. However, on a practical level, the serialization scheme, format or protocol you choose may determine the speed, security, freedom of maintenance status, and other aspects of the program

The article discusses popular Python libraries like NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, Django, Flask, and Requests, detailing their uses in scientific computing, data analysis, visualization, machine learning, web development, and H

This article guides Python developers on building command-line interfaces (CLIs). It details using libraries like typer, click, and argparse, emphasizing input/output handling, and promoting user-friendly design patterns for improved CLI usability.

This tutorial builds upon the previous introduction to Beautiful Soup, focusing on DOM manipulation beyond simple tree navigation. We'll explore efficient search methods and techniques for modifying HTML structure. One common DOM search method is ex


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
