From 2d6a9938af3524a09a2c115ff918e29d6ec71af3 Mon Sep 17 00:00:00 2001 From: acefei <5701068+acefei@user.noreply.gitee.com> Date: Wed, 29 Apr 2026 11:58:13 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20SGLang=200.5.8/0.5?= =?UTF-8?q?.9/0.5.10=20=E5=AE=B9=E5=99=A8=E9=95=9C=E5=83=8F=E9=80=82?= =?UTF-8?q?=E9=85=8D=20OC9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: acefei <5701068+acefei@user.noreply.gitee.com> --- frameworks/sglang/0.5.10/Dockerfile | 32 ++++++++ frameworks/sglang/0.5.10/README.md | 76 ++++++++++++++++++ frameworks/sglang/0.5.10/build.conf | 4 + frameworks/sglang/0.5.8/Dockerfile | 32 ++++++++ frameworks/sglang/0.5.8/README.md | 76 ++++++++++++++++++ frameworks/sglang/0.5.8/build.conf | 4 + frameworks/sglang/0.5.9/Dockerfile | 32 ++++++++ frameworks/sglang/0.5.9/README.md | 76 ++++++++++++++++++ frameworks/sglang/0.5.9/build.conf | 4 + frameworks/sglang/common.sh | 105 +++++++++++++++++++++++++ frameworks/sglang/test.sh | 116 ++++++++++++++++++++++++++++ 11 files changed, 557 insertions(+) create mode 100644 frameworks/sglang/0.5.10/Dockerfile create mode 100644 frameworks/sglang/0.5.10/README.md create mode 100644 frameworks/sglang/0.5.10/build.conf create mode 100644 frameworks/sglang/0.5.8/Dockerfile create mode 100644 frameworks/sglang/0.5.8/README.md create mode 100644 frameworks/sglang/0.5.8/build.conf create mode 100644 frameworks/sglang/0.5.9/Dockerfile create mode 100644 frameworks/sglang/0.5.9/README.md create mode 100644 frameworks/sglang/0.5.9/build.conf create mode 100644 frameworks/sglang/common.sh create mode 100755 frameworks/sglang/test.sh diff --git a/frameworks/sglang/0.5.10/Dockerfile b/frameworks/sglang/0.5.10/Dockerfile new file mode 100644 index 0000000..28a69a9 --- /dev/null +++ b/frameworks/sglang/0.5.10/Dockerfile @@ -0,0 +1,32 @@ +# SGLang 0.5.10 on OpenCloudOS 9 (GPU) +FROM opencloudos/opencloudos9-cuda-devel:12.8 + +LABEL maintainer="OpenCloudOS Community " +LABEL org.opencontainers.image.source="https://gitee.com/OpenCloudOS/ai-agent-container" +LABEL org.opencontainers.image.description="SGLang 0.5.10 (GPU) on OpenCloudOS 9" + +# 1. 安装系统级依赖并清理缓存 +RUN dnf install -y \ + python3-pip \ + git \ + && dnf clean all \ + && rm -rf /var/cache/yum/* + +# 2. 安装 Python 包管理器和 SGLang +RUN pip3 install --no-cache-dir uv \ + && uv pip install --no-cache-dir --prerelease=allow "sglang[all]==0.5.10" --system + +# 3. 注册 PyTorch/NVIDIA pip 包内的共享库到动态链接器(修复 libnvshmem_host.so.3 找不到等问题) +RUN find /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 -type d -path '*/nvidia/*/lib' 2>/dev/null \ + > /etc/ld.so.conf.d/nvidia-pip.conf \ + && ldconfig + +# 4. 设置 GPU 环境变量 +ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility + +WORKDIR /workspace + +RUN echo $(date +"%Y-%m-%dT%H:%M:%S%z") > /opencloudos_build_date.txt + +CMD ["python3", "-c", "import sglang; print(f'SGLang {sglang.__version__} ready')"] diff --git a/frameworks/sglang/0.5.10/README.md b/frameworks/sglang/0.5.10/README.md new file mode 100644 index 0000000..94f162a --- /dev/null +++ b/frameworks/sglang/0.5.10/README.md @@ -0,0 +1,76 @@ +# SGLang on OpenCloudOS 9 + +## 一、镜像信息 + +- **镜像名**:`oc9-sglang:0.5.10` +- **基础镜像**:`opencloudos/opencloudos9-cuda-devel:12.8` +- **Python 版本**:3.11(基础镜像默认) +- **CUDA 版本**:12.8 +- **核心组件**:SGLang 0.5.10(含 `[all]` 扩展,包含 vLLM、flashinfer 等推理依赖) +- **工作目录**:`/workspace` +- **上游项目**:[sgl-project/sglang](https://github.com/sgl-project/sglang) + +## 二、构建镜像 + +```bash +docker build -t oc9-sglang:0.5.10 . +``` + +## 三、使用示例 + +### 1. 验证 SGLang 安装 + +```bash +docker run --rm --gpus all oc9-sglang:0.5.10 \ + python3 -c "import sglang as sgl; print(sgl.__version__)" +``` + +### 2. 启动推理服务 + +下载模型权重(以 Qwen2.5-7B-Instruct 为例): + +```bash +sudo dnf install -y git-lfs +sudo git lfs install +sudo mkdir -p /models +sudo git clone https://www.modelscope.cn/Qwen/Qwen2.5-7B-Instruct.git \ + /models/Qwen2.5-7B-Instruct +``` + +启动 OpenAI 兼容服务: + +```bash +docker run -itd --name sglang_serving --rm \ + --gpus all \ + --shm-size 16g \ + -p 30000:30000 \ + -v /models/Qwen2.5-7B-Instruct:/models/Qwen2.5-7B-Instruct \ + oc9-sglang:0.5.10 \ + python3 -m sglang.launch_server \ + --model-path /models/Qwen2.5-7B-Instruct \ + --host 0.0.0.0 \ + --port 30000 +``` + +### 3. 访问服务 + +```bash +curl http://localhost:30000/v1/chat/completions \ + -H 'Content-Type: application/json' \ + -d '{ + "model": "Qwen2.5-7B-Instruct", + "messages": [{"role": "user", "content": "你好"}], + "max_tokens": 128 + }' +``` + +## 四、功能验证 + +```bash +bash ../test.sh oc9-sglang:0.5.10 +``` + +## 五、已知问题 + +- SGLang 对 GPU 计算能力有要求(推荐 SM 8.0+,如 A100/H100/L40/RTX 30 系及以上)。低计算能力的 GPU 可能在加载 flashinfer/triton 内核时报错。 +- 首次启动模型时,flashinfer 会即时编译 CUDA 内核,启动时间较长,属正常现象。 diff --git a/frameworks/sglang/0.5.10/build.conf b/frameworks/sglang/0.5.10/build.conf new file mode 100644 index 0000000..c59fd68 --- /dev/null +++ b/frameworks/sglang/0.5.10/build.conf @@ -0,0 +1,4 @@ +# SGLang 0.5.10 on OpenCloudOS 9 (GPU) +IMAGE_NAME=oc9-sglang +IMAGE_TAG=0.5.10 +GPU_TEST=true diff --git a/frameworks/sglang/0.5.8/Dockerfile b/frameworks/sglang/0.5.8/Dockerfile new file mode 100644 index 0000000..e10d0b7 --- /dev/null +++ b/frameworks/sglang/0.5.8/Dockerfile @@ -0,0 +1,32 @@ +# SGLang 0.5.8 on OpenCloudOS 9 (GPU) +FROM opencloudos/opencloudos9-cuda-devel:12.8 + +LABEL maintainer="OpenCloudOS Community " +LABEL org.opencontainers.image.source="https://gitee.com/OpenCloudOS/ai-agent-container" +LABEL org.opencontainers.image.description="SGLang 0.5.8 (GPU) on OpenCloudOS 9" + +# 1. 安装系统级依赖并清理缓存 +RUN dnf install -y \ + python3-pip \ + git \ + && dnf clean all \ + && rm -rf /var/cache/yum/* + +# 2. 安装 Python 包管理器和 SGLang +RUN pip3 install --no-cache-dir uv \ + && uv pip install --no-cache-dir "sglang[all]==0.5.8" --system + +# 3. 注册 PyTorch/NVIDIA pip 包内的共享库到动态链接器(修复 libnvshmem_host.so.3 找不到等问题) +RUN find /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 -type d -path '*/nvidia/*/lib' 2>/dev/null \ + > /etc/ld.so.conf.d/nvidia-pip.conf \ + && ldconfig + +# 4. 设置 GPU 环境变量 +ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility + +WORKDIR /workspace + +RUN echo $(date +"%Y-%m-%dT%H:%M:%S%z") > /opencloudos_build_date.txt + +CMD ["python3", "-c", "import sglang; print(f'SGLang {sglang.__version__} installed')"] diff --git a/frameworks/sglang/0.5.8/README.md b/frameworks/sglang/0.5.8/README.md new file mode 100644 index 0000000..42c6304 --- /dev/null +++ b/frameworks/sglang/0.5.8/README.md @@ -0,0 +1,76 @@ +# SGLang on OpenCloudOS 9 + +## 一、镜像信息 + +- **镜像名**:`oc9-sglang:0.5.8` +- **基础镜像**:`opencloudos/opencloudos9-cuda-devel:12.8` +- **Python 版本**:3.11(基础镜像默认) +- **CUDA 版本**:12.8 +- **核心组件**:SGLang 0.5.8(含 `[all]` 扩展,包含 vLLM、flashinfer 等推理依赖) +- **工作目录**:`/workspace` +- **上游项目**:[sgl-project/sglang](https://github.com/sgl-project/sglang) + +## 二、构建镜像 + +```bash +docker build -t oc9-sglang:0.5.8 . +``` + +## 三、使用示例 + +### 1. 验证 SGLang 安装 + +```bash +docker run --rm --gpus all oc9-sglang:0.5.8 \ + python3 -c "import sglang as sgl; print(sgl.__version__)" +``` + +### 2. 启动推理服务 + +下载模型权重(以 Qwen2.5-7B-Instruct 为例): + +```bash +sudo dnf install -y git-lfs +sudo git lfs install +sudo mkdir -p /models +sudo git clone https://www.modelscope.cn/Qwen/Qwen2.5-7B-Instruct.git \ + /models/Qwen2.5-7B-Instruct +``` + +启动 OpenAI 兼容服务: + +```bash +docker run -itd --name sglang_serving --rm \ + --gpus all \ + --shm-size 16g \ + -p 30000:30000 \ + -v /models/Qwen2.5-7B-Instruct:/models/Qwen2.5-7B-Instruct \ + oc9-sglang:0.5.8 \ + python3 -m sglang.launch_server \ + --model-path /models/Qwen2.5-7B-Instruct \ + --host 0.0.0.0 \ + --port 30000 +``` + +### 3. 访问服务 + +```bash +curl http://localhost:30000/v1/chat/completions \ + -H 'Content-Type: application/json' \ + -d '{ + "model": "Qwen2.5-7B-Instruct", + "messages": [{"role": "user", "content": "你好"}], + "max_tokens": 128 + }' +``` + +## 四、功能验证 + +```bash +bash ../test.sh oc9-sglang:0.5.8 +``` + +## 五、已知问题 + +- SGLang 对 GPU 计算能力有要求(推荐 SM 8.0+,如 A100/H100/L40/RTX 30 系及以上)。低计算能力的 GPU 可能在加载 flashinfer/triton 内核时报错。 +- 首次启动模型时,flashinfer 会即时编译 CUDA 内核,启动时间较长,属正常现象。 diff --git a/frameworks/sglang/0.5.8/build.conf b/frameworks/sglang/0.5.8/build.conf new file mode 100644 index 0000000..6ae9f10 --- /dev/null +++ b/frameworks/sglang/0.5.8/build.conf @@ -0,0 +1,4 @@ +# SGLang 0.5.8 on OpenCloudOS 9 (GPU) +IMAGE_NAME=oc9-sglang +IMAGE_TAG=0.5.8 +GPU_TEST=true diff --git a/frameworks/sglang/0.5.9/Dockerfile b/frameworks/sglang/0.5.9/Dockerfile new file mode 100644 index 0000000..b2d44f2 --- /dev/null +++ b/frameworks/sglang/0.5.9/Dockerfile @@ -0,0 +1,32 @@ +# SGLang 0.5.9 on OpenCloudOS 9 (GPU) +FROM opencloudos/opencloudos9-cuda-devel:12.8 + +LABEL maintainer="OpenCloudOS Community " +LABEL org.opencontainers.image.source="https://gitee.com/OpenCloudOS/ai-agent-container" +LABEL org.opencontainers.image.description="SGLang 0.5.9 (GPU) on OpenCloudOS 9" + +# 1. 安装系统级依赖并清理缓存 +RUN dnf install -y \ + python3-pip \ + git \ + && dnf clean all \ + && rm -rf /var/cache/yum/* + +# 2. 安装 Python 包管理器和 SGLang +RUN pip3 install --no-cache-dir uv \ + && uv pip install --no-cache-dir "sglang[all]==0.5.9" --system + +# 3. 注册 PyTorch/NVIDIA pip 包内的共享库到动态链接器(修复 libnvshmem_host.so.3 找不到等问题) +RUN find /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 -type d -path '*/nvidia/*/lib' 2>/dev/null \ + > /etc/ld.so.conf.d/nvidia-pip.conf \ + && ldconfig + +# 4. 设置 GPU 环境变量 +ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility + +WORKDIR /workspace + +RUN echo $(date +"%Y-%m-%dT%H:%M:%S%z") > /opencloudos_build_date.txt + +CMD ["python3", "-c", "import sglang; print(f'SGLang {sglang.__version__} ready')"] diff --git a/frameworks/sglang/0.5.9/README.md b/frameworks/sglang/0.5.9/README.md new file mode 100644 index 0000000..dbe0062 --- /dev/null +++ b/frameworks/sglang/0.5.9/README.md @@ -0,0 +1,76 @@ +# SGLang on OpenCloudOS 9 + +## 一、镜像信息 + +- **镜像名**:`oc9-sglang:0.5.9` +- **基础镜像**:`opencloudos/opencloudos9-cuda-devel:12.8` +- **Python 版本**:3.11(基础镜像默认) +- **CUDA 版本**:12.8 +- **核心组件**:SGLang 0.5.9(含 `[all]` 扩展,包含 vLLM、flashinfer 等推理依赖) +- **工作目录**:`/workspace` +- **上游项目**:[sgl-project/sglang](https://github.com/sgl-project/sglang) + +## 二、构建镜像 + +```bash +docker build -t oc9-sglang:0.5.9 . +``` + +## 三、使用示例 + +### 1. 验证 SGLang 安装 + +```bash +docker run --rm --gpus all oc9-sglang:0.5.9 \ + python3 -c "import sglang as sgl; print(sgl.__version__)" +``` + +### 2. 启动推理服务 + +下载模型权重(以 Qwen2.5-7B-Instruct 为例): + +```bash +sudo dnf install -y git-lfs +sudo git lfs install +sudo mkdir -p /models +sudo git clone https://www.modelscope.cn/Qwen/Qwen2.5-7B-Instruct.git \ + /models/Qwen2.5-7B-Instruct +``` + +启动 OpenAI 兼容服务: + +```bash +docker run -itd --name sglang_serving --rm \ + --gpus all \ + --shm-size 16g \ + -p 30000:30000 \ + -v /models/Qwen2.5-7B-Instruct:/models/Qwen2.5-7B-Instruct \ + oc9-sglang:0.5.9 \ + python3 -m sglang.launch_server \ + --model-path /models/Qwen2.5-7B-Instruct \ + --host 0.0.0.0 \ + --port 30000 +``` + +### 3. 访问服务 + +```bash +curl http://localhost:30000/v1/chat/completions \ + -H 'Content-Type: application/json' \ + -d '{ + "model": "Qwen2.5-7B-Instruct", + "messages": [{"role": "user", "content": "你好"}], + "max_tokens": 128 + }' +``` + +## 四、功能验证 + +```bash +bash ../test.sh oc9-sglang:0.5.9 +``` + +## 五、已知问题 + +- SGLang 对 GPU 计算能力有要求(推荐 SM 8.0+,如 A100/H100/L40/RTX 30 系及以上)。低计算能力的 GPU 可能在加载 flashinfer/triton 内核时报错。 +- 首次启动模型时,flashinfer 会即时编译 CUDA 内核,启动时间较长,属正常现象。 diff --git a/frameworks/sglang/0.5.9/build.conf b/frameworks/sglang/0.5.9/build.conf new file mode 100644 index 0000000..67c9cf6 --- /dev/null +++ b/frameworks/sglang/0.5.9/build.conf @@ -0,0 +1,4 @@ +# SGLang 0.5.9 on OpenCloudOS 9 (GPU) +IMAGE_NAME=oc9-sglang +IMAGE_TAG=0.5.9 +GPU_TEST=true diff --git a/frameworks/sglang/common.sh b/frameworks/sglang/common.sh new file mode 100644 index 0000000..19942ec --- /dev/null +++ b/frameworks/sglang/common.sh @@ -0,0 +1,105 @@ +#!/bin/bash +#=============================================================================== +# 框架测试公共库(被各 framework 的 test.sh 通过 `source` 引入) +# +# 提供: +# select_version [prompt_label] +# 扫描 //Dockerfile,交互式选择版本, +# 将所选版本写入 指定的全局变量。 +# +# ensure_image +# 若本地不存在镜像,则从 (应包含 Dockerfile)构建。 +# +# run_case <描述> [docker 额外参数...] -- <命令...> +# 在 $IMAGE 中执行命令,自动打印 ✓/✗,失败即退出。 +# +# run_py <描述> [docker 额外参数...] +# run_case 的便捷封装,执行 `python3 -c `。 +# +# 调用方需在 source 本文件前/后定义 $IMAGE 变量供 run_case/run_py 使用。 +#=============================================================================== + +# -------- 交互式版本选择 -------- +# 用法:select_version [prompt_label] +select_version() { + local fw_dir="$1" + local out_var="$2" + local label="${3:-版本}" + + local -a versions + mapfile -t versions < <( + find "$fw_dir" -mindepth 2 -maxdepth 2 -name Dockerfile -printf '%h\n' \ + | xargs -n1 basename | sort -V + ) + if [[ ${#versions[@]} -eq 0 ]]; then + echo "✗ 未在 $fw_dir 下发现任何 /Dockerfile" >&2 + return 1 + fi + + echo "可用${label}:" >&2 + local i + for i in "${!versions[@]}"; do + printf " %d) %s\n" "$((i+1))" "${versions[$i]}" >&2 + done + local default_idx=${#versions[@]} + local sel + read -r -p "请选择${label} [默认 ${default_idx}=${versions[$((default_idx-1))]}]: " sel + sel="${sel:-$default_idx}" + if ! [[ "$sel" =~ ^[0-9]+$ ]] || (( sel < 1 || sel > ${#versions[@]} )); then + echo "✗ 无效选择: $sel" >&2 + return 1 + fi + printf -v "$out_var" '%s' "${versions[$((sel-1))]}" +} + +# -------- 镜像存在性检查 + 自动构建 -------- +# 用法:ensure_image +# 环境变量: +# FORCE_REBUILD=1 强制重新构建镜像(删除旧镜像并使用 --no-cache 重新构建) +ensure_image() { + local image="$1" + local context="$2" + + if [[ "${FORCE_REBUILD:-0}" == "1" ]]; then + echo "FORCE_REBUILD=1:强制重建镜像 ${image}(删除旧镜像 + --no-cache)..." + sudo docker image rm -f "$image" >/dev/null 2>&1 || true + sudo docker build --no-cache --pull -t "$image" "$context" + echo "✓ 镜像强制重建完成: $image" + return 0 + fi + + if sudo docker image inspect "$image" >/dev/null 2>&1; then + echo "✓ 镜像已存在: $image(如需重建请使用 FORCE_REBUILD=1 或 --rebuild)" + return 0 + fi + + echo "镜像 ${image} 不存在,开始构建..." + sudo docker build -t "$image" "$context" + echo "✓ 镜像构建完成: $image" +} + +# -------- 测试运行器 -------- +# 用法:run_case <描述> [docker 额外参数...] -- <命令...> +# "--" 之前的参数追加给 `docker run`(如 --gpus all);之后是容器内命令。 +run_case() { + local desc="$1"; shift + local -a docker_args=() + while [[ $# -gt 0 && "$1" != "--" ]]; do + docker_args+=("$1"); shift + done + [[ "${1:-}" == "--" ]] && shift + + echo -n "${desc}... " + if sudo docker run --rm "${docker_args[@]}" "$IMAGE" "$@"; then + echo "✓ 通过" + else + echo "✗ 失败" + exit 1 + fi +} + +# 用法:run_py <描述> [docker 额外参数...] +run_py() { + local desc="$1"; local code="$2"; shift 2 + run_case "$desc" "$@" -- python3 -c "$code" +} diff --git a/frameworks/sglang/test.sh b/frameworks/sglang/test.sh new file mode 100755 index 0000000..3698552 --- /dev/null +++ b/frameworks/sglang/test.sh @@ -0,0 +1,116 @@ +#!/bin/bash +#=============================================================================== +# SGLang 镜像功能测试脚本 +# +# 用法:bash test.sh [--rebuild] +# +# 行为: +# - 自动扫描 .//Dockerfile,交互式选择 SGLang 版本。 +# - 镜像名固定为 oc9-sglang:;若本地不存在则自动构建。 +# - --rebuild 或 FORCE_REBUILD=1:强制重建镜像(删除旧镜像并使用 --no-cache)。 +#=============================================================================== +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +DEFAULT_IMAGE_NAME="oc9-sglang" + +# 解析参数 +for arg in "$@"; do + case "$arg" in + --rebuild|-r) export FORCE_REBUILD=1 ;; + -h|--help) + grep -E '^#( |$)' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + esac +done + +# 引入公共库(select_version / ensure_image / run_case / run_py) +# shellcheck source=./common.sh +source "$SCRIPT_DIR/common.sh" + +select_version "$SCRIPT_DIR" SGLANG_VERSION "SGLang 版本" +VERSION_DIR="$SCRIPT_DIR/$SGLANG_VERSION" +IMAGE="${DEFAULT_IMAGE_NAME}:${SGLANG_VERSION}" + +ensure_image "$IMAGE" "$VERSION_DIR" + +echo "" +echo "=== SGLang ${SGLANG_VERSION} 基础功能测试 ===" +echo "运行时间:$(date '+%Y-%m-%d %H:%M:%S')" +echo "镜像:${IMAGE}" +echo "" + +# ============================================================ +# 阶段一:CPU 安全检查(不依赖 GPU 驱动 / libcuda.so.1) +# ============================================================ +echo "--- 阶段一:安装验证 ---" + +run_py "检查 sglang 版本" " +import sglang as sgl +version = sgl.__version__ +print(version) +assert version == '${SGLANG_VERSION}', f'期望 ${SGLANG_VERSION},实际 {version}' +" + +run_py "检查 sglang 主模块导入" " +import sglang as sgl +print('ok') +" + +run_py "检查 torch CUDA 构建" " +import torch +assert torch.version.cuda is not None, 'torch 未使用 CUDA 构建' +print(f'torch={torch.__version__}, cuda={torch.version.cuda}') +" + +echo "" + +# ============================================================ +# 阶段二:GPU 运行时检查 +# 注意:sglang.srt.* 深层模块会加载 sgl_kernel,依赖 libcuda.so.1, +# 必须在挂载了 NVIDIA 运行时(--gpus all)的容器中执行。 +# ============================================================ +echo "--- 阶段二:GPU 运行时检查 ---" + +if ! command -v nvidia-smi &>/dev/null; then + echo "⚠ 未检测到 nvidia-smi,跳过 GPU 测试(请在 GPU 实例上运行)" + echo "" + echo "=== 阶段一全部通过,阶段二已跳过(无 GPU 环境) ===" + exit 0 +fi + +run_case "检查 nvidia-smi" --gpus all -- \ + nvidia-smi --query-gpu=name,driver_version,memory.total --format=csv,noheader + +run_py "检查 torch.cuda.is_available()" " +import torch +assert torch.cuda.is_available(), 'torch 无法访问 GPU' +print(f'GPU 数量: {torch.cuda.device_count()}') +for i in range(torch.cuda.device_count()): + print(f' GPU {i}: {torch.cuda.get_device_name(i)}') +" --gpus all + +run_case "检查 sglang.launch_server CLI" --gpus all -- \ + bash -c "python3 -m sglang.launch_server --help >/dev/null" + +run_py "检查 sglang ServerArgs 导入" " +from sglang.srt.server_args import ServerArgs +print('ok') +" --gpus all + +run_py "检查 sglang OpenAI 兼容入口导入" " +from sglang.srt.entrypoints.http_server import launch_server +print('ok') +" --gpus all + +run_py "检查 sglang 平台探测" " +import torch, sglang as sgl +print(f'sglang={sgl.__version__}, torch={torch.__version__}, cuda={torch.version.cuda}') +" --gpus all + +echo "" +echo "--- 阶段三:完整推理测试 ---" +echo " 请使用项目根目录的 cuda_test.sh 进行端到端推理验证:" +echo " bash cuda_test.sh --vllm-model " +echo "" + +echo "=== 所有测试通过 ===" -- Gitee