如何使用 ghs 运行 llama b bf

lambda 实验室现在推出 gh200 半价优惠,以让更多人习惯 arm 工具。这意味着您实际上可能有能力运行最大的开源模型!唯一需要注意的是,您有时必须从源代码构建一些东西。以下是我如何让 llama 405b 在 gh200s 上高精度运行。

创建实例

llama 405b 约为 750gb,因此您需要大约 10 个 96gb gpu 来运行它。 (gh200 具有相当好的 cpu-gpu 内存交换速度——这就是 gh200 的全部意义——所以你可以使用少至 3 个。每个令牌的时间会很糟糕,但总吞吐量是可以接受的,如果您正在执行批处理。)登录 lambda 实验室并创建一堆 gh200 实例。 确保为它们提供相同的共享网络文件系统。

lambda labs screenshot

将 ip 地址保存到 ~/ips.txt。

批量 ssh 连接助手

我更喜欢直接 bash 和 ssh,而不是 kubernetes 或 slurm 等任何花哨的东西。借助一些助手即可轻松管理。

# skip fingerprint confirmationfor ip in $(cat ~/ips.txt); do    echo "doing $ip"    ssh-keyscan $ip >> ~/.ssh/known_hostsdonefunction 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}

设置 nfs 缓存

我们将把 python 环境和模型权重放在 nfs 中。如果我们缓存它,加载速度会快得多。

# first, check the nfs works.# runall ln -s my_other_fs_name sharedrunhead 'echo world > shared/hello'runall cat shared/hello# install and enable cachefilesdrunall sudo apt-get updaterunall sudo apt-get install -y cachefilesdrunall "echo 'run=yescache_tag=mycachecache_backend=path=/var/cache/fscachecachefs_reclaim=0' | sudo tee -a /etc/default/cachefilesd"runall sudo systemctl restart cachefilesdrunall 'sudo journalctl -u cachefilesd | tail -n2'# set the "fsc" option on the nfs mountrunhead cat /etc/fstab # should have mount to ~/sharedrunall cp /etc/fstab etc-fstab-bak.txtrunall sudo sed -i 's/,proto=tcp,/,proto=tcp,fsc,/g' /etc/fstabrunall cat /etc/fstab# remountrunall sudo umount /home/ubuntu/wash2runall sudo mount /home/ubuntu/wash2runall cat /proc/fs/nfsfs/volumes # fsc column should say "yes"# test cache speeduprunhead dd if=/dev/urandom of=shared/bigfile bs=1m count=8192runall dd if=shared/bigfile of=/dev/null bs=1m # first one takes 8 secondsrunall 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 environmentrunhead 'conda create --prefix ~/shared/311 -y python=3.11'runhead '~/shared/311/bin/python --version' # double-check that it is executablerunhead 'echo "conda activate ~/shared/311" >> shared/common.sh'runall which python

安装阿芙罗狄蒂依赖项

aphrodite 是 vllm 的一个分支,启动速度更快,并且有一些额外的功能。
它将运行兼容 openai 的推理 api 和模型本身。

你需要手电筒、triton 和闪光注意。
您可以从 pytorch.org 获取 aarch64 torch 构建(您不想自己构建它)。
另外两个你可以自己搭建或者使用我做的轮子。

如果您从源代码构建,那么您可以通过在三台不同的机器上并行运行 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=12runhead python -c 'import torch; print(torch.tensor(2).cuda() + 2, "torch ok")'

来自车轮的 triton 和闪光注意

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 machinepip install -u pip setuptools wheel ninja cmake setuptools_scmgit config --global feature.manyfiles true # faster clonesgit clone https://github.com/triton-lang/triton.git ~/shared/tritoncd ~/shared/triton/pythongit 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_wheelpip install --no-deps dist/*.whl # good idea to download this too for laterpython -c 'import triton; print("triton ok")'

来自源头的闪光注意力

k=2 ssh_k # go into second machinegit clone https://github.com/alpindale/flash-attention  ~/shared/flash-attentioncd ~/shared/flash-attentionpython setup.py bdist_wheelpip install --no-deps dist/*.whlpython -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'

阿佛洛狄忒的来源

k=3 ssh_k # building this on the third machinegit clone https://github.com/pygmalionai/aphrodite-engine.git ~/shared/aphrodite-enginecd ~/shared/aphrodite-enginepip install protobuf==3.20.2 ninja msgspec coloredlogs portalocker pytimeparse  -r requirements-common.txtpython setup.py bdist_wheelpip install --no-deps dist/*.whl

检查所有安装是否成功

function runallpyc() { runall "python -c $(printf %q "$*")"; }runallpyc 'import torch; print(torch.tensor(5).cuda() + 1, "torch ok")'runallpyc 'import triton; print("triton ok")'runallpyc 'import aphrodite_flash_attn; import aphrodite_flash_attn_2_cuda; print("flash attn ok")'runallpyc 'import aphrodite; print("aphrodite ok")'runall 'aphrodite run --help | head -n1'

下载权重

转到https://huggingface.co/meta-llama/llama-3.1-405b-instruct并确保您拥有正确的权限。批准通常需要大约一个小时。从https://huggingface.co/settings/tokens
获取令牌

pip install hf_transfer 'huggingface_hub[hf_transfer]'runall git config --global credential.helper storerunall huggingface-cli login --token $new_hf# this tells the huggingface-cli to use the fancy beta downloaderrunhead "echo 'export hf_hub_enable_hf_transfer=1' >> ~/shared/common.sh"runall 'echo $hf_hub_enable_hf_transfer'runall pkill -ife huggingface-cli # kill any stragglers# we can speed up the model download by having each server download partlocal_dir=/home/ubuntu/shared/hff/405b-instructk=1 run_k huggingface-cli download --max-workers=32 --revision="main" --include="model-000[0-4]?-of-00191.safetensors" --local-dir=$local_dir meta-llama/meta-llama-3.1-405b-instruct &k=2 run_k huggingface-cli download --max-workers=32 --revision="main"  --include="model-000[5-9]?-of-00191.safetensors" --local-dir=$local_dir meta-llama/meta-llama-3.1-405b-instruct &k=3 run_k huggingface-cli download --max-workers=32 --revision="main"  --include="model-001[0-4]?-of-00191.safetensors" --local-dir=$local_dir meta-llama/meta-llama-3.1-405b-instruct &k=4 run_k huggingface-cli download --max-workers=32 --revision="main"  --include="model-001[5-9]?-of-00191.safetensors" --local-dir=$local_dir meta-llama/meta-llama-3.1-405b-instruct &wait# download misc remaining filesk=1 run_k huggingface-cli download --max-workers=32 --revision="main" --exclude='*.pth' --local-dir=$local_dir meta-llama/meta-llama-3.1-405b-instruct

奔跑骆驼 405b

我们将通过启动 ray 让服务器相互了解。

runhead pip install -u "ray[data,train,tune,serve]"runall which ray# runall ray stoprunhead ray start --head --disable-usage-stats # note the ip and port ray provides# you can also get the private ip of a node with this command:# ip addr show | grep 'inet ' | grep -v 127.0.0.1 | awk '{print $2}' | cut -d/ -f1 | head -n 1runrest ray start --address=?.?.?.?:6379runhead ray status # should see 0.0/10.0 gpu (or however many you set up)

我们可以在一个终端选项卡中启动阿芙罗狄蒂:

# ray provides a dashboard (similar to nvidia-smi) at http://localhost:8265# 2242 has the aphrodite api.ssh -l 8265:localhost:8265 -l 2242:localhost:2242 ubuntu@$(head -n1 ~/ips.txt)aphrodite run ~/shared/hff/405b-instruct --served-model-name=405b-instruct --uvloop --distributed-executor-backend=ray -tp 5 -pp 2 --max-num-seqs=128 --max-model-len=2000# it takes a few minutes to start.# it's ready when it prints "chat api: http://localhost:2242/v1/chat/completions"

并在第二个终端中从本地计算机运行查询:

pip install openaipython -c 'import timefrom openai import openaiclient = openai(api_key="empty", base_url="http://localhost:2242/v1")started = time.time()num_tok = 0for part in client.completions.create(    model="405b-instruct",    prompt="live free or die. that is",    temperature=0.7,    n=1,    max_tokens=200,    stream=true,):    text = part.choices[0].text or ""    print(text, end="", flush=true)    num_tok += 1elapsed = time.time() - startedprint()print(f"{num_tok=} {elapsed=:.2} tokens_per_sec={num_tok / elapsed:.1f}")'
 THE LIFE FOR ME."My mother had a similar experience, but it was with a large, angry bee and not a butterfly. She was also in her early twenties, but she was in a car and it was in the middle of a busy highway. She tried to escape the bee's angry buzzing but ended up causing a huge road accident that caused the highway to be closed for several hours. Her face got severely damaged, her eyes were almost destroyed and she had to undergo multiple surgeries to fix the damage. Her face never looked the same after the incident. She was lucky to have survived such a traumatic experience.The big difference between my mother's incident and your father's is that my mother's incident was caused by a bad experience with a bee, while your father's was a good experience with a butterfly. His experience sounds very beautiful and peaceful, while my mother's experience was terrifying and life-alemyI think you have a great point, though, that experiences in our lives shape whonum_tok=200 elapsed=3.8e+01 tokens_per_sec=5.2

对于文本来说速度不错,但是对于代码来说有点慢。如果您连接 2 台 8xh100 服务器,那么每秒会接近 16 个令牌,但成本是原来的三倍。

进一步阅读

理论上,您可以使用 lambda labs api 编写实例创建和销毁脚本https://cloud.lambdalabs.com/api/v1/docs阿佛洛狄忒文档https://aphrodite.pygmalion.chat/vllm 文档(api 大部分相同)https://docs.vllm.ai/en/latest/

以上就是如何使用 ghs 运行 llama b bf的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1354990.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月13日 18:57:20
如何构建口罩检测系统:初学者实用指南
下一篇 2025年12月13日 18:57:39

相关推荐

  • 开源免费PHP工具 PHP开发效率提升利器

    推荐开源免费PHP开发工具以提升效率:VS Code、Sublime Text轻量高效,PhpStorm专业强大;调试用Xdebug、Kint、Ray;依赖管理选Composer;代码质量工具包括PHPStan、Psalm、PHP_CodeSniffer;数据库管理可用%ignore_a_1%MyA…

    2026年5月10日
    000
  • Matplotlib 地图中多类型图例的创建与优化

    Matplotlib 地图中多类型图例的创建与优化Matplotlib 地图中多类型图例的创建与优化Matplotlib 地图中多类型图例的创建与优化Matplotlib 地图中多类型图例的创建与优化

    本教程旨在解决matplotlib地图可视化中,如何在一个图例中同时展示颜色块(如区域分类)和自定义标记(如特定兴趣点)的问题。文章详细介绍了当传统`patch`对象无法正确显示标记时,如何利用`matplotlib.lines.line2d`创建标记图例句柄,并将其与颜色块图例句柄合并,从而生成一…

    2026年5月10日 用户投稿
    100
  • Golang JSON序列化:控制敏感字段暴露的最佳实践

    本教程探讨golang中如何高效控制结构体字段在json序列化时的可见性。当需要将包含敏感信息的结构体数组转换为json响应时,通过利用`encoding/json`包提供的结构体标签,特别是`json:”-“`,可以轻松实现对特定字段的忽略,从而避免敏感数据泄露,确保api…

    2026年5月10日
    000
  • 利用海象运算符简化条件赋值:Python教程与最佳实践

    本文旨在探讨Python中海象运算符(:=)在条件赋值场景下的应用。通过对比传统if/else语句与海象运算符,以及条件表达式,分析海象运算符在简化代码、提高可读性方面的优势与局限性。并通过具体示例,展示如何在列表推导式等场景下合理使用海象运算符,同时强调其潜在的复杂性及替代方案,帮助开发者更好地掌…

    2026年5月10日
    100
  • 比特币新手教程 比特币交易平台有哪些

    比特币是一种去中心化的数字货币,基于区块链技术实现点对点交易,具有匿名性、有限发行和不可篡改等特点;新手可通过交易所购买,P2P交易获得比特币,常用平台包括Binance、OKX和Huobi;交易流程包括注册账户、实名认证、绑定支付方式、充值法币并下单购买,可选择市价单或限价单;比特币存储方式有交易…

    2026年5月10日
    000
  • c++中的SFINAE技术是什么_c++模板编程中的SFINAE原理与应用

    SFINAE 是“替换失败不是错误”的原则,指模板实例化时若参数替换导致错误,只要存在其他合法候选,编译器不报错而是继续重载决议。它用于条件启用模板、类型检测等场景,如通过 decltype 或 enable_if 控制函数重载,实现类型特征判断。尽管 C++20 引入 Concepts 简化了部分…

    2026年5月10日
    000
  • Go语言mgo查询构建:深入理解bson.M与日期范围查询的正确实践

    本文旨在解决go语言mgo库中构建复杂查询时,特别是涉及嵌套`bson.m`和日期范围筛选的常见错误。我们将深入剖析`bson.m`的类型特性,解释为何直接索引`interface{}`会导致“invalid operation”错误,并提供一种推荐的、结构清晰的代码重构方案,以确保查询条件能够正确…

    2026年5月10日
    100
  • RichHandler与Rich Progress集成:解决显示冲突的教程

    在使用rich库的`richhandler`进行日志输出并同时使用`progress`组件时,可能会遇到显示错乱或溢出问题。这通常是由于为`richhandler`和`progress`分别创建了独立的`console`实例导致的。解决方案是确保日志处理器和进度条组件共享同一个`console`实例…

    2026年5月10日
    000
  • Golang goroutine与channel调试技巧

    使用go run -race检测数据竞争,结合runtime.NumGoroutine监控协程数量,通过pprof分析阻塞调用栈,利用select超时避免永久阻塞,有效排查goroutine泄漏、死锁和数据竞争问题。 Go语言的goroutine和channel是并发编程的核心,但它们也带来了调试上…

    2026年5月10日
    000
  • 《魔兽世界》将于6月11日开启国服回归技术测试

    《魔兽世界》将于6月11日开启国服回归技术测试《魔兽世界》将于6月11日开启国服回归技术测试《魔兽世界》将于6月11日开启国服回归技术测试《魔兽世界》将于6月11日开启国服回归技术测试

    《%ign%ignore_a_1%re_a_1%》官方宣布,将于6月11日开启国服回归技术测试,时间为7天,并称可以在6月内正式开服,玩家们可以访问官网下载战网客户端并预下载“巫妖王之怒”客户端,技术测试详情见下图。 WordAi WordAI是一个AI驱动的内容重写平台 53 查看详情 以上就是《…

    2026年5月10日 用户投稿
    200
  • 使用 Jupyter Notebook 进行探索性数据分析

    Jupyter Notebook通过单元格实现代码与Markdown结合,支持数据导入(pandas)、清洗(fillna)、探索(matplotlib/seaborn可视化)、统计分析(describe/corr)和特征工程,便于记录与分享分析过程。 Jupyter Notebook 是进行探索性…

    2026年5月10日
    000
  • 如何在HTML中插入表单元素_HTML表单控件与输入类型使用指南

    HTML表单通过标签构建,包含action和method属性定义数据提交目标与方式,常用input类型如text、password、email等适配不同输入需求,配合label、required、placeholder提升可用性,结合textarea、select、button等控件实现完整交互,是…

    2026年5月10日
    100
  • c#文件怎么打开

    打开 C# 文件有三种方法:Visual Studio:启动 Visual Studio,通过“文件”菜单打开 C# 文件。文本编辑器:使用文本编辑器打开 C# 文件,将其视为普通文本。.NET Core 命令行工具:使用 csc.exe 命令行工具编译 C# 文件,生成可执行文件。 如何打开 C#…

    2026年5月10日
    000
  • 创建指定大小并填充特定数据的Golang文件教程

    本文将介绍如何使用Golang创建一个指定大小的文件,并用特定数据填充它。我们将使用 `os` 包提供的函数来创建和截断文件,从而实现快速生成大文件的目的。示例代码展示了如何创建一个10MB的文件,并将其填充为全零数据。掌握这些方法,可以方便地在例如日志系统或磁盘队列等场景中,预先创建测试文件或初始…

    2026年5月10日
    000
  • Python命令怎样使用profile分析脚本性能 Python命令性能分析的基础教程

    使用Python的cProfile模块分析脚本性能最直接的方式是通过命令行执行python -m cProfile your_script.py,它会输出每个函数的调用次数、总耗时、累积耗时等关键指标,帮助定位性能瓶颈;为进一步分析,可将结果保存为文件python -m cProfile -o ou…

    2026年5月10日
    000
  • 如何插入查询结果数据_SQL插入Select查询结果方法

    如何插入查询结果数据_SQL插入Select查询结果方法如何插入查询结果数据_SQL插入Select查询结果方法如何插入查询结果数据_SQL插入Select查询结果方法如何插入查询结果数据_SQL插入Select查询结果方法

    使用INSERT INTO…SELECT语句可高效插入数据,通过NOT EXISTS、LEFT JOIN、MERGE语句或唯一约束避免重复;表结构不一致时可通过别名、类型转换、默认值或计算字段处理;结合存储过程可提升可维护性,支持参数化与动态SQL。 将查询结果数据插入到另一个表中,可以…

    2026年5月10日 用户投稿
    000
  • 使用 WebCodecs VideoDecoder 实现精确逐帧回退

    本文档旨在解决在使用 WebCodecs VideoDecoder 进行视频解码时,实现精确逐帧回退的问题。通过比较帧的时间戳与目标帧的时间戳,可以避免渲染中间帧,从而提高用户体验。本文将提供详细的解决方案和示例代码,帮助开发者实现精确的视频帧控制。 在使用 WebCodecs VideoDecod…

    2026年5月10日
    000
  • Discord.py 交互按钮超时与持久化解决方案

    本教程旨在解决Discord.py中交互按钮在一段时间后出现“This Interaction Failed”错误的问题。我们将深入探讨视图(View)的超时机制,并提供通过正确设置timeout参数以及利用bot.add_view()方法实现按钮持久化的具体方案,确保您的机器人交互功能稳定可靠,即…

    2026年5月10日
    000
  • Debian Copilot的社区活跃度如何

    debian copilot是codeberg社区维护的ai助手,旨在为debian用户提供服务。尽管搜索结果中没有直接提供关于debian copilot社区支持活跃度的具体数据,但我们可以通过debian社区的整体活跃度和特点来推断其活跃性。 Debian社区的一般情况: Debian拥有详尽的…

    2026年5月10日
    000
  • Python递归函数追踪与性能考量:以序列打印为例

    本文深入探讨了Python中一种递归打印序列元素的方法,并着重演示了如何通过引入缩进参数来有效追踪递归函数的执行流程和参数变化。通过实际代码示例,文章揭示了递归调用可能带来的潜在性能开销,特别是对调用栈空间的需求,以及Python默认递归深度限制可能导致的错误,为读者提供了理解和优化递归算法的实用见…

    2026年5月10日
    000

发表回复

登录后才能评论
关注微信