【经验总结】Ubuntu 源代码方式安装 Microsoft DeepSpeed

devtools/2024/10/9 9:39:38/

1. 背景介绍

使用 DeepSpeed 在多服务器上分布式训练大模型

2. 安装方法

2.1 查看显卡参数

~$ CUDA_VISIBLE_DEVICES=0 python -c "import torch; print(torch.cuda.get_device_capability())"
(8, 0)
~$ CUDA_VISIBLE_DEVICES=0 python -c "import torch; print(torch.cuda.get_device_properties(torch.device('cuda')))"
_CudaDeviceProperties(name='NVIDIA A800 80GB PCIe', major=8, minor=0, total_memory=81050MB, multi_processor_count=108)
~$ CUDA_VISIBLE_DEVICES=0 python -c "import torch; print(torch.cuda.get_arch_list())"
['sm_50', 'sm_60', 'sm_61', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'sm_37', 'sm_90', 'compute_37']

2.2 源代码安装

2.2.1 创建虚拟环境

采用 clone 方式,新建一个 DeepSpeed 专用的 Anaconda 环境

~$ conda create -n deepspeed --clone peft

2.2.2 激活环境

~$ conda activate deepspeed

2.2.3 源代码安装 Transformers

遵循官方文档,通过下面的命令安装 Transformers:

~$ pip install git+https://github.com/huggingface/transformers

2.2.4 源代码安装 DeepSpeed

根据 GPU 实际情况设置参数 TORCH_CUDA_ARCH_LIST
如果需要使用 CPU Offload 优化器参数,设置参数 DS_BUILD_CPU_ADAM=1
如果需要使用 NVMe Offload,设置参数 DS_BUILD_UTILS=1

~$ git clone https://github.com/microsoft/DeepSpeed/
Cloning into 'DeepSpeed'...
remote: Enumerating objects: 45020, done.
remote: Counting objects: 100% (3618/3618), done.
remote: Compressing objects: 100% (413/413), done.
remote: Total 45020 (delta 3387), reused 3299 (delta 3202), pack-reused 41402
Receiving objects: 100% (45020/45020), 207.74 MiB | 14.32 MiB/s, done.
Resolving deltas: 100% (32479/32479), done.
Updating files: 100% (1554/1554), done.
~$ cd DeepSpeed/
~$ TORCH_CUDA_ARCH_LIST="8.0" DS_BUILD_CPU_ADAM=1 DS_BUILD_UTILS=1 pip install . \
--global-option="build_ext" --global-option="-j8" --no-cache -v \
--disable-pip-version-check 2>&1 | tee build.log

安装成功:

~$ pip show deepspeed
Name: deepspeed
Version: 0.14.3+fbdf0eaf
Summary: DeepSpeed library
Home-page: http://deepspeed.ai
Author: DeepSpeed Team
Author-email: deepspeed-info@microsoft.com
License: Apache Software License 2.0
Location: /public/home/acc5trotmy/.conda/envs/deepspeed/lib/python3.10/site-packages
Requires: hjson, ninja, numpy, packaging, psutil, py-cpuinfo, pydantic, pynvml, torch, tqdm
Required-by: 

deepspeed 命令:

~$ deepspeed 
[2024-04-24 12:05:52,629] [INFO] [real_accelerator.py:203:get_accelerator] Setting ds_accelerator to cuda (auto detect)
df: /public/home/acc5trotmy/.triton/autotune: No such file or directory[WARNING]  async_io requires the dev libaio .so object and headers but these were not found.[WARNING]  async_io: please install the libaio-dev package with apt[WARNING]  If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.[WARNING]  Please specify the CUTLASS repo directory as environment variable $CUTLASS_PATH[WARNING]  sparse_attn requires a torch version >= 1.5 and < 2.0 but detected 2.2[WARNING]  using untested triton version (2.2.0), only 1.0.0 is known to be compatible
usage: deepspeed [-h] [-H HOSTFILE] [-i INCLUDE] [-e EXCLUDE] [--num_nodes NUM_NODES] [--min_elastic_nodes MIN_ELASTIC_NODES][--max_elastic_nodes MAX_ELASTIC_NODES] [--num_gpus NUM_GPUS] [--master_port MASTER_PORT] [--master_addr MASTER_ADDR][--launcher LAUNCHER] [--launcher_args LAUNCHER_ARGS] [--module] [--no_python] [--no_local_rank] [--no_ssh_check] [--force_multi][--save_pid] [--enable_each_rank_log ENABLE_EACH_RANK_LOG] [--autotuning {tune,run}] [--elastic_training] [--bind_cores_to_rank][--bind_core_list BIND_CORE_LIST] [--ssh_port SSH_PORT]user_script ...
deepspeed: error: the following arguments are required: user_script, user_args

http://www.ppmy.cn/devtools/13448.html

相关文章

JavaScript与HTML交互

JavaScript与HTML交互 一、在页面中直接编写JS代码二、从外部引入JS代码一、在页面中直接编写JS代码 首先创建一个html页面,并在页面中编写一段JS代码,注意,JS代码要放在标签中,然后实现html代码和JavaScript的交互。 <!DOCTYPE html> <html lang="en"…

【python】使用python和selenium实现某平台自动化上传作品的全步骤

第一&#xff0c;我们需要下载python并安装 下载地址&#xff1a;https://www.python.org/downloads/release/python-3123/ 3.x版本的python自带pip工具&#xff0c;因此不需要额外下载。 ModuleNotFoundError: No module named seleniumpip用于下载python适用的各类模块&…

文献学习-37-动态场景中任意形状针的单目 3D 位姿估计:一种高效的视觉学习和几何建模方法

On the Monocular 3D Pose Estimation for Arbitrary Shaped Needle in Dynamic Scenes: An Efficient Visual Learning and Geometry Modeling Approach Authors: Bin Li,† , Student Member, IEEE, Bo Lu,† , Member, IEEE, Hongbin Lin, Yaxiang Wang, Fangxun Zhong, Me…

Python读写文本URL蓝牙WIFI自动连接电子名片位置坐标智能海报等NDEF标签

本示例使用的发卡器&#xff1a;https://item.taobao.com/item.htm?id615391857885&spma1z10.5-c.w4002-21818769070.11.60ad789erlonvk 近场通信&#xff08;Near Field Communication&#xff0c;简称NFC&#xff09;&#xff0c;是一种新兴的技术&…

HarmonyOS NEXT星河版之实战商城App瀑布流(含加载更多)

文章目录 一、目标二、开撸2.1 声明商品对象2.2 mock数据2.3 主页面2.4 加载更多2.5 完整代码 三、小结 一、目标 二、开撸 2.1 声明商品对象 export interface GoodsItem {title: stringimageUrl: string }2.2 mock数据 export const mockGoodsList: GoodsItem[] [{title:…

买婴儿洗衣机怎么选择?推荐四大表现突出的宝藏婴儿洗衣机

现在还有人把宝宝衣服跟大人的混洗吗&#xff1f;或者把婴儿衣物跟其他衣物混洗吗&#xff1f;赶紧停止吧&#xff01;这样会带来非常严重的细菌交叉的感染&#xff0c;有小孩的家庭&#xff0c;或者说打算生小孩的家庭&#xff0c;一定要入手一台小型婴儿洗衣机&#xff0c;宝…

实验4 数字频率计

实验目的&#xff1a; 1、使用铆孔U7输出一个脉冲&#xff0c;频率不定。 2、使用铆孔V7测量脉冲频率&#xff0c;并在数码管上显示。 实验内容及步骤&#xff1a; 设计原理 测量频率的方法有很多&#xff0c;按照其工作原理分为无源测量法、比较法、示波器法和计数法等。…

在Windows电脑上快速运行AI大语言模型-Llama3

概述 近期 Meta 发布了最新的 Llama3 模型&#xff0c;并开源了开源代码。Meta Llama 3 现已推出 8B 和 70B 预训练和指令调整版本&#xff0c;可支持广泛的应用程序。 并且 Llama 3 在语言细微差别、上下文理解和翻译和对话生成等复杂任务方面表现出色。 我们可以在 Window…