From 96ea15990a17299e3e7a87489c614fac49c476bc Mon Sep 17 00:00:00 2001 From: Sam Blade <812101+samblade@user.noreply.gitee.com> Date: Thu, 30 Apr 2026 17:04:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20diffusers=200.?= =?UTF-8?q?33.0=20=E6=A1=86=E6=9E=B6=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 diffusers 0.33.0 GPU 镜像支持 - 基于 opencloudos9-cuda-devel:12.8 - 使用 uv 安装 Python 依赖 - 包含 test.sh GPU 测试脚本 --- frameworks/diffusers/0.33.0/Dockerfile | 32 +++++++++++++++++ frameworks/diffusers/0.33.0/README.md | 48 ++++++++++++++++++++++++++ frameworks/diffusers/0.33.0/build.conf | 4 +++ frameworks/diffusers/0.33.0/test.sh | 31 +++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 frameworks/diffusers/0.33.0/Dockerfile create mode 100644 frameworks/diffusers/0.33.0/README.md create mode 100644 frameworks/diffusers/0.33.0/build.conf create mode 100755 frameworks/diffusers/0.33.0/test.sh diff --git a/frameworks/diffusers/0.33.0/Dockerfile b/frameworks/diffusers/0.33.0/Dockerfile new file mode 100644 index 0000000..9a923f6 --- /dev/null +++ b/frameworks/diffusers/0.33.0/Dockerfile @@ -0,0 +1,32 @@ +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="Diffusers (GPU) on OpenCloudOS 9" + +# 安装 Python 3.11 及依赖 +RUN dnf install -y \ + python3.11 \ + python3.11-pip \ + && dnf clean all \ + && rm -rf /var/cache/yum/* \ + && ln -sf /usr/bin/python3.11 /usr/bin/python3 + +# 安装 diffusers 及常用的 GPU 依赖 +RUN pip3.11 install --no-cache-dir uv \ + && uv pip install --no-cache-dir \ + diffusers==0.33.0 \ + torch \ + torchvision \ + torchaudio \ + accelerate \ + 'transformers<4.48.0' \ + safetensors \ + --system + +# 设置 GPU 环境变量 +ENV NVIDIA_VISIBLE_DEVICES=all + +RUN echo $(date +"%Y-%m-%dT%H:%M:%S%z") > /opencloudos_build_date.txt + +CMD ["python3.11"] diff --git a/frameworks/diffusers/0.33.0/README.md b/frameworks/diffusers/0.33.0/README.md new file mode 100644 index 0000000..63d183d --- /dev/null +++ b/frameworks/diffusers/0.33.0/README.md @@ -0,0 +1,48 @@ +# Diffusers on OpenCloudOS 9 + +## 基本信息 +- **框架版本**:v0.33.0 +- **基础镜像**:opencloudos/opencloudos9-cuda-devel:12.8 +- **Python 版本**:3.11 +- **CUDA 版本**:12.8 + +## 构建 + +```bash +docker build -t oc9-diffusers:0.33.0 . +``` + +## 使用示例 + +```bash +# 验证 diffusers 版本 +docker run --rm --gpus all oc9-diffusers:0.33.0 python3 -c "import diffusers; print(diffusers.__version__)" + +# 验证 CUDA 可用性 +docker run --rm --gpus all oc9-diffusers:0.33.0 python3 -c "import torch; print(torch.cuda.is_available())" + +# 快速推理示例(需要联网下载模型) +docker run --rm --gpus all oc9-diffusers:0.33.0 python3 -c " +from diffusers import DiffusionPipeline +import torch +pipe = DiffusionPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', torch_dtype=torch.float16) +pipe = pipe.to('cuda') +print('Pipeline loaded on GPU') +" +``` + +## 测试验证 + +```bash +# 执行测试脚本(需要 GPU 环境) +bash test.sh oc9-diffusers:0.33.0 +``` + +测试脚本会验证以下内容: +- CUDA 环境是否可用 +- diffusers 是否正常导入 +- 核心组件(DiffusionPipeline、DDPMScheduler、UNet2DModel)是否可加载 + +## 已知问题 +- 首次运行时需要联网下载模型权重,建议提前挂载本地模型缓存目录以加速启动。 +- diffusers 0.33.0 依赖 `transformers` 中已移除的 `FLAX_WEIGHTS_NAME`,需固定 `transformers<4.48.0` 以避免 ImportError。 diff --git a/frameworks/diffusers/0.33.0/build.conf b/frameworks/diffusers/0.33.0/build.conf new file mode 100644 index 0000000..eb9b980 --- /dev/null +++ b/frameworks/diffusers/0.33.0/build.conf @@ -0,0 +1,4 @@ +# diffusers 0.33.0 on OpenCloudOS 9 (GPU) +IMAGE_NAME=oc9-diffusers +IMAGE_TAG=0.33.0 +GPU_TEST=true diff --git a/frameworks/diffusers/0.33.0/test.sh b/frameworks/diffusers/0.33.0/test.sh new file mode 100755 index 0000000..6c5289e --- /dev/null +++ b/frameworks/diffusers/0.33.0/test.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +IMAGE="${1:?ERROR: 缺少镜像参数。用法: bash test.sh }" + +echo "=== GPU 镜像功能测试 ===" + +# 1. 验证 CUDA 环境 +echo -n "检查 CUDA... " +docker run --rm --gpus all "$IMAGE" python3 -c " +import torch +assert torch.cuda.is_available(), 'CUDA not available' +print(f'GPU: {torch.cuda.get_device_name(0)}') +" && echo "✓ 通过" || { echo "✗ 失败"; exit 1; } + +# 2. 验证 diffusers 导入 +echo -n "检查 diffusers import... " +docker run --rm --gpus all "$IMAGE" python3 -c " +import diffusers +print(diffusers.__version__) +" && echo "✓ 通过" || { echo "✗ 失败"; exit 1; } + +# 3. 验证核心组件可用 +echo -n "检查 diffusers 核心组件... " +docker run --rm --gpus all "$IMAGE" python3 -c " +from diffusers import DiffusionPipeline, DDPMScheduler, UNet2DModel +import torch +print('核心组件加载正常') +" && echo "✓ 通过" || { echo "✗ 失败"; exit 1; } + +echo "=== 所有测试通过 ===" -- Gitee From 4a3db7c0a32ba00c1394938c98a379c9f39f6f46 Mon Sep 17 00:00:00 2001 From: samblade <812101+samblade@user.noreply.gitee.com> Date: Thu, 30 Apr 2026 09:43:52 +0000 Subject: [PATCH 2/3] update frameworks/diffusers/0.33.0/test.sh. Signed-off-by: samblade <812101+samblade@user.noreply.gitee.com> --- frameworks/diffusers/0.33.0/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/diffusers/0.33.0/test.sh b/frameworks/diffusers/0.33.0/test.sh index 6c5289e..89001cb 100755 --- a/frameworks/diffusers/0.33.0/test.sh +++ b/frameworks/diffusers/0.33.0/test.sh @@ -4,7 +4,7 @@ set -e IMAGE="${1:?ERROR: 缺少镜像参数。用法: bash test.sh }" echo "=== GPU 镜像功能测试 ===" - +docker system prune -f # 1. 验证 CUDA 环境 echo -n "检查 CUDA... " docker run --rm --gpus all "$IMAGE" python3 -c " -- Gitee From 4f76ef3ee839208aeb387e5e69753a94d2a38795 Mon Sep 17 00:00:00 2001 From: samblade <812101+samblade@user.noreply.gitee.com> Date: Thu, 30 Apr 2026 09:45:26 +0000 Subject: [PATCH 3/3] update frameworks/diffusers/0.33.0/test.sh. Signed-off-by: samblade <812101+samblade@user.noreply.gitee.com> --- frameworks/diffusers/0.33.0/test.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/diffusers/0.33.0/test.sh b/frameworks/diffusers/0.33.0/test.sh index 89001cb..56906f4 100755 --- a/frameworks/diffusers/0.33.0/test.sh +++ b/frameworks/diffusers/0.33.0/test.sh @@ -4,7 +4,6 @@ set -e IMAGE="${1:?ERROR: 缺少镜像参数。用法: bash test.sh }" echo "=== GPU 镜像功能测试 ===" -docker system prune -f # 1. 验证 CUDA 环境 echo -n "检查 CUDA... " docker run --rm --gpus all "$IMAGE" python3 -c " -- Gitee