README.md 2.52 KB
Newer Older
maxiao1's avatar
maxiao1 committed
1
# <div align="center"><strong>sglang</strong></div>
maxiao1's avatar
maxiao1 committed
2
3
4

## 简介

maxiao1's avatar
maxiao1 committed
5
sglang 是一个用于大语言模型(LLM)与多模态视觉语言模型(VLM)的高效推理与服务框架。通过前后端协同设计,提供更高吞吐与更可控的调用体验。
maxiao1's avatar
maxiao1 committed
6

maxiao1's avatar
maxiao1 committed
7
## 安装
maxiao1's avatar
maxiao1 committed
8

maxiao1's avatar
maxiao1 committed
9
> 组件支持组合安装;下表给出一个经过验证的环境组合示例,可按需替换为你本机/集群的镜像与版本。
maxiao1's avatar
maxiao1 committed
10

maxiao1's avatar
maxiao1 committed
11
12
13
14
15
16
17
| Python版本 | DTK版本        | 基础镜像(示例)                                                                                                          | 推荐安装方式       |
| ---------- | -------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| 3.10       | 25.04.1 及以上 | `image.sourcefind.cn:5000/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk25.04.1-rc5-rocblas101839-0811-das1.6-py3.10-20250812-beta` | 使用镜像 + 源码安装 |

### 1、使用镜像环境准备

#### 拉取并启动 Docker
maxiao1's avatar
maxiao1 committed
18
19

```bash
maxiao1's avatar
maxiao1 committed
20
# 拉取镜像
maxiao1's avatar
maxiao1 committed
21
22
docker pull image.sourcefind.cn:5000/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk25.04.1-rc5-rocblas101839-0811-das1.6-py3.10-20250812-beta

maxiao1's avatar
maxiao1 committed
23
24
25
26
27
28
29
30
# 启动容器(将 <Image ID> 替换为上面拉取镜像的 ID;路径按需修改)
docker run -it --name sglang-dev \
  --shm-size=1024G \
  -v /opt/hyhal:/opt/hyhal:ro \
  --device=/dev/kfd \
  --device=/dev/dri/ \
  --cap-add=SYS_PTRACE \
  <Image ID> /bin/bash
maxiao1's avatar
maxiao1 committed
31
32
```

maxiao1's avatar
maxiao1 committed
33
34
35
> 注意:
> 1) `-v /opt/hyhal:/opt/hyhal` 不能少;
> 2) 若 `pip install` 较慢,可添加镜像源:`-i https://pypi.tuna.tsinghua.edu.cn/simple/`。
maxiao1's avatar
maxiao1 committed
36

maxiao1's avatar
maxiao1 committed
37
### 2、源码准备
maxiao1's avatar
maxiao1 committed
38
39

```bash
maxiao1's avatar
maxiao1 committed
40
# 克隆代码仓库(容器内执行)
maxiao1's avatar
maxiao1 committed
41
git clone https://developer.sourcefind.cn/codes/OpenDAS/sglang
maxiao1's avatar
maxiao1 committed
42
cd sglang
maxiao1's avatar
maxiao1 committed
43
44
```

maxiao1's avatar
maxiao1 committed
45
46
47
### 3、编译与安装

#### 3.1 编译 `sgl-kernel`
maxiao1's avatar
maxiao1 committed
48
49
50
51
52
53

```bash
cd sgl-kernel
python setup_hip.py install
```

maxiao1's avatar
maxiao1 committed
54
55
#### 3.2 安装 sglang Python 依赖

maxiao1's avatar
maxiao1 committed
56
57
58
59
60
```bash
cd ..
pip install -e "python[all_hip]"
```

maxiao1's avatar
maxiao1 committed
61
62
63
64
65
66
67
## 注意事项

- **挂载依赖**:确保在 `docker run` 时挂载 `/opt/hyhal:/opt/hyhal`,否则运行期可能缺少必需依赖。
- **加速下载**:国内网络环境建议为 `pip` 添加清华源:`-i https://pypi.tuna.tsinghua.edu.cn/simple/`
- **设备访问**:容器需添加 `--device=/dev/kfd --device=/dev/dri/` 以启用 DCU/ROCm 设备访问。

## Known Issue
maxiao1's avatar
maxiao1 committed
68

maxiao1's avatar
maxiao1 committed
69
-
maxiao1's avatar
maxiao1 committed
70

maxiao1's avatar
maxiao1 committed
71
## 参考资料
maxiao1's avatar
maxiao1 committed
72

maxiao1's avatar
maxiao1 committed
73
74
- 仓库地址:`https://developer.sourcefind.cn/codes/OpenDAS/sglang`
- [README_ORIGIN](https://developer.sourcefind.cn/codes/OpenDAS/sglang/-/blob/v0.5.2rc1/README_ORIGIN.md)