diff --git a/frameworks/pytorch/2.10.0/Dockerfile b/frameworks/pytorch/2.10.0/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3185627ca7fb32151c3a865a8e525a2efc30537e --- /dev/null +++ b/frameworks/pytorch/2.10.0/Dockerfile @@ -0,0 +1,25 @@ + +FROM opencloudos/opencloudos9-cuda-devel:12.8 + +LABEL maintainer="stronking 363133710@qq.com" +LABEL org.opencontainers.image.source="https://gitee.com/OpenCloudOS/ai-agent-container" +LABEL org.opencontainers.image.description="Torch 2.10.0 (GPU) on OpenCloudOS 9" + +ENV NVIDIA_VISIBLE_DEVICES=all \ + PYTHONUNBUFFERED=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_DEFAULT_TIMEOUT=120 + + +WORKDIR /home + +RUN --mount=type=cache,id=pip-cache-opencloudos9-cu128,target=/root/.cache/pip \ + pip install \ + torch==2.10.0 \ + torchvision==0.25.0 \ + torchaudio==2.10.0 \ + --index-url https://download.pytorch.org/whl/cu128 + +COPY test.sh . + +CMD ["python3"] \ No newline at end of file diff --git a/frameworks/pytorch/2.10.0/README.md b/frameworks/pytorch/2.10.0/README.md new file mode 100644 index 0000000000000000000000000000000000000000..81fcbf520c8a1537921251d1ab85c41b870487ae --- /dev/null +++ b/frameworks/pytorch/2.10.0/README.md @@ -0,0 +1,20 @@ +# Torch 2.10.0 on OpenCloudOS 9 + +## 基本信息 +- **框架版本**:v2.10.0 +- **基础镜像**:opencloudos9-cuda-devel:12.8 +- **Python 版本**:3.11 +- **CUDA 版本**: 12.x 或 更高 + +## 构建 + +docker build -t oc9-pytorch:2.10.0 . + +## 镜像启动命令 + +docker run -d --gpus all --name oc9-pytorch oc9-pytorch:2.10.0 + +## 镜像测试命令 + +docker run --rm --gpus all oc9-pytorch:2.10.0 bash test.sh + diff --git a/frameworks/pytorch/2.10.0/build.conf b/frameworks/pytorch/2.10.0/build.conf new file mode 100644 index 0000000000000000000000000000000000000000..fff269862299e4313eb586f485b6f862e3e3b939 --- /dev/null +++ b/frameworks/pytorch/2.10.0/build.conf @@ -0,0 +1,4 @@ +# pytorch 2.10.0 on OpenCloudOS 9 (GPU) +IMAGE_NAME=oc9-pytorch +IMAGE_TAG=2.10.0 +GPU_TEST=true \ No newline at end of file diff --git a/frameworks/pytorch/2.10.0/test.sh b/frameworks/pytorch/2.10.0/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71e9e0a7683912d1386e6daad10342577d3377e5 --- /dev/null +++ b/frameworks/pytorch/2.10.0/test.sh @@ -0,0 +1,204 @@ +#!/bin/bash +set -e + +IMAGE="${1:-}" + +if [ -z "${IMAGE}" ]; then + echo "用法: bash test.sh <镜像名:标签>" + exit 1 +fi + +if ! command -v docker >/dev/null 2>&1; then + echo "✗ 未找到 docker" + exit 1 +fi + +echo "=== PyTorch 容器基础功能测试 ===" +echo "测试镜像: ${IMAGE}" + +docker run --rm --gpus all "${IMAGE}" /bin/bash -lc ' +set -e + +export CUDA_HOME=/usr/local/cuda +export PATH=/usr/local/cuda/bin:$PATH +export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:-} + +echo "=== PyTorch 基础功能测试 ===" + +# 说明: +# CI 的 GPU_TEST=true 会额外执行 torch.cuda.is_available() 验证 CUDA。 +# 因此这里默认不强制要求 CUDA,避免基础测试因为未挂载 GPU 失败。 +# 如需强制测试 CUDA,可在运行 test.sh 时设置 REQUIRE_CUDA=1。 +REQUIRE_CUDA="${REQUIRE_CUDA:-0}" + +echo "REQUIRE_CUDA=${REQUIRE_CUDA}" + +pass() { + echo "✓ $1" +} + +fail() { + echo "✗ $1" + exit 1 +} + +check() { + local name="$1" + shift + + echo "检查 ${name}..." + if "$@"; then + pass "${name}" + else + fail "${name}" + fi +} + +echo +echo "=== 1. Python / PyTorch Import 检查 ===" + +check "python3 存在" command -v python3 + +check "import torch / torchvision / torchaudio" python3 - <<'"'"'PY'"'"' +import torch +import torchvision +import torchaudio + +print("torch:", torch.__version__) +print("torchvision:", torchvision.__version__) +print("torchaudio:", torchaudio.__version__) +print("torch path:", torch.__file__) +PY + + +echo +echo "=== 2. CPU 基础功能检查 ===" + +check "CPU Tensor 计算" python3 - <<'"'"'PY'"'"' +import torch + +x = torch.randn(512, 512) +y = torch.randn(512, 512) +z = x @ y + +assert z.shape == (512, 512) +assert torch.isfinite(z).all() + +print("CPU matmul OK") +PY + + +check "Autograd 自动求导" python3 - <<'"'"'PY'"'"' +import torch + +x = torch.tensor([1.0, 2.0, 3.0], requires_grad=True) +y = (x * x).sum() +y.backward() + +expected = torch.tensor([2.0, 4.0, 6.0]) +assert torch.allclose(x.grad, expected) + +print("Autograd OK") +PY + + +echo +echo "=== 3. CUDA 环境信息检查 ===" + +if command -v nvidia-smi >/dev/null 2>&1; then + echo "检测到 nvidia-smi:" + nvidia-smi || true +else + echo "未检测到 nvidia-smi,跳过 nvidia-smi 检查" +fi + +if command -v nvcc >/dev/null 2>&1; then + check "nvcc --version" nvcc --version +else + if [ "${REQUIRE_CUDA}" = "1" ]; then + fail "REQUIRE_CUDA=1,但未找到 nvcc" + else + echo "未找到 nvcc,跳过 nvcc 检查" + fi +fi + + +echo +echo "=== 4. PyTorch CUDA 功能检查 ===" + +check "torch CUDA 状态查询" python3 - < 0, "No CUDA device found" +else: + if not torch.cuda.is_available(): + print("CUDA not available, skip GPU assertion") +PY + + +if [ "${REQUIRE_CUDA}" = "1" ]; then + check "GPU Tensor 计算" python3 - <<'"'"'PY'"'"' +import torch + +assert torch.cuda.is_available(), "CUDA is not available" + +device = torch.device("cuda:0") + +print("GPU name:", torch.cuda.get_device_name(0)) + +x = torch.randn(1024, 1024, device=device) +y = torch.randn(1024, 1024, device=device) +z = x @ y + +torch.cuda.synchronize() + +assert z.is_cuda +assert z.shape == (1024, 1024) +assert torch.isfinite(z).all() + +print("GPU matmul OK") +PY +else + echo "REQUIRE_CUDA=0,跳过 GPU Tensor 计算" +fi + + +echo +echo "=== 5. torchvision / torchaudio 基础功能检查 ===" + +check "torchvision transforms" python3 - <<'"'"'PY'"'"' +import torchvision.transforms as T + +transform = T.Compose([ + T.Resize((224, 224)), + T.ToTensor(), +]) + +assert transform is not None +print("torchvision transforms OK") +PY + + +check "torchaudio import" python3 - <<'"'"'PY'"'"' +import torchaudio + +print("torchaudio version:", torchaudio.__version__) +print("torchaudio OK") +PY + + +echo +echo "=== 所有 PyTorch 容器基础测试通过 ===" +' + +echo "✓ 镜像 ${IMAGE} 功能测试通过" +exit 0 \ No newline at end of file diff --git a/frameworks/pytorch/2.10.0/test_result.png b/frameworks/pytorch/2.10.0/test_result.png new file mode 100644 index 0000000000000000000000000000000000000000..b1b3dc48a71cbcdc352b7e572c0fa887a4e7bbdd Binary files /dev/null and b/frameworks/pytorch/2.10.0/test_result.png differ diff --git a/frameworks/pytorch/2.11.0/Dockerfile b/frameworks/pytorch/2.11.0/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c18270339dc08c8ed6b3c7f859388db0a3ee926 --- /dev/null +++ b/frameworks/pytorch/2.11.0/Dockerfile @@ -0,0 +1,24 @@ + +FROM opencloudos/opencloudos9-cuda-devel:12.8 + +LABEL maintainer="stronking 363133710@qq.com" +LABEL org.opencontainers.image.source="https://gitee.com/OpenCloudOS/ai-agent-container" +LABEL org.opencontainers.image.description="Torch 2.11.0 (GPU) on OpenCloudOS 9" + +ENV NVIDIA_VISIBLE_DEVICES=all \ + PYTHONUNBUFFERED=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_DEFAULT_TIMEOUT=120 + + +WORKDIR /home + +RUN --mount=type=cache,id=pip-cache-opencloudos9-cu128,target=/root/.cache/pip \ + pip install \ + torch==2.11.0 \ + torchvision==0.26.0 \ + torchaudio==2.11.0 \ + --index-url https://download.pytorch.org/whl/cu128 +COPY test.sh . + +CMD ["python3"] \ No newline at end of file diff --git a/frameworks/pytorch/2.11.0/README.md b/frameworks/pytorch/2.11.0/README.md new file mode 100644 index 0000000000000000000000000000000000000000..299d2414cd6686525589a57edfa3e897a234dc1c --- /dev/null +++ b/frameworks/pytorch/2.11.0/README.md @@ -0,0 +1,20 @@ +# Torch 2.11.0 on OpenCloudOS 9 + +## 基本信息 +- **框架版本**:v2.11.0 +- **基础镜像**:opencloudos9-cuda-devel:12.8 +- **Python 版本**:3.11 +- **CUDA 版本**: 12.x 或 更高 + +## 构建 + +docker build -t oc9-pytorch:2.11.0 . + +## 镜像启动命令 + +docker run -d --gpus all --name oc9-pytorch oc9-pytorch:2.11.0 + +## 镜像测试命令 + +docker run --rm --gpus all oc9-pytorch:2.11.0 bash test.sh + diff --git a/frameworks/pytorch/2.11.0/build.conf b/frameworks/pytorch/2.11.0/build.conf new file mode 100644 index 0000000000000000000000000000000000000000..f101d2580ae45e2f652dd06e4e22d5c54ce1fcac --- /dev/null +++ b/frameworks/pytorch/2.11.0/build.conf @@ -0,0 +1,4 @@ +# pytorch 2.11.0 on OpenCloudOS 9 (GPU) +IMAGE_NAME=oc9-pytorch +IMAGE_TAG=2.11.0 +GPU_TEST=true \ No newline at end of file diff --git a/frameworks/pytorch/2.11.0/test.sh b/frameworks/pytorch/2.11.0/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71e9e0a7683912d1386e6daad10342577d3377e5 --- /dev/null +++ b/frameworks/pytorch/2.11.0/test.sh @@ -0,0 +1,204 @@ +#!/bin/bash +set -e + +IMAGE="${1:-}" + +if [ -z "${IMAGE}" ]; then + echo "用法: bash test.sh <镜像名:标签>" + exit 1 +fi + +if ! command -v docker >/dev/null 2>&1; then + echo "✗ 未找到 docker" + exit 1 +fi + +echo "=== PyTorch 容器基础功能测试 ===" +echo "测试镜像: ${IMAGE}" + +docker run --rm --gpus all "${IMAGE}" /bin/bash -lc ' +set -e + +export CUDA_HOME=/usr/local/cuda +export PATH=/usr/local/cuda/bin:$PATH +export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:-} + +echo "=== PyTorch 基础功能测试 ===" + +# 说明: +# CI 的 GPU_TEST=true 会额外执行 torch.cuda.is_available() 验证 CUDA。 +# 因此这里默认不强制要求 CUDA,避免基础测试因为未挂载 GPU 失败。 +# 如需强制测试 CUDA,可在运行 test.sh 时设置 REQUIRE_CUDA=1。 +REQUIRE_CUDA="${REQUIRE_CUDA:-0}" + +echo "REQUIRE_CUDA=${REQUIRE_CUDA}" + +pass() { + echo "✓ $1" +} + +fail() { + echo "✗ $1" + exit 1 +} + +check() { + local name="$1" + shift + + echo "检查 ${name}..." + if "$@"; then + pass "${name}" + else + fail "${name}" + fi +} + +echo +echo "=== 1. Python / PyTorch Import 检查 ===" + +check "python3 存在" command -v python3 + +check "import torch / torchvision / torchaudio" python3 - <<'"'"'PY'"'"' +import torch +import torchvision +import torchaudio + +print("torch:", torch.__version__) +print("torchvision:", torchvision.__version__) +print("torchaudio:", torchaudio.__version__) +print("torch path:", torch.__file__) +PY + + +echo +echo "=== 2. CPU 基础功能检查 ===" + +check "CPU Tensor 计算" python3 - <<'"'"'PY'"'"' +import torch + +x = torch.randn(512, 512) +y = torch.randn(512, 512) +z = x @ y + +assert z.shape == (512, 512) +assert torch.isfinite(z).all() + +print("CPU matmul OK") +PY + + +check "Autograd 自动求导" python3 - <<'"'"'PY'"'"' +import torch + +x = torch.tensor([1.0, 2.0, 3.0], requires_grad=True) +y = (x * x).sum() +y.backward() + +expected = torch.tensor([2.0, 4.0, 6.0]) +assert torch.allclose(x.grad, expected) + +print("Autograd OK") +PY + + +echo +echo "=== 3. CUDA 环境信息检查 ===" + +if command -v nvidia-smi >/dev/null 2>&1; then + echo "检测到 nvidia-smi:" + nvidia-smi || true +else + echo "未检测到 nvidia-smi,跳过 nvidia-smi 检查" +fi + +if command -v nvcc >/dev/null 2>&1; then + check "nvcc --version" nvcc --version +else + if [ "${REQUIRE_CUDA}" = "1" ]; then + fail "REQUIRE_CUDA=1,但未找到 nvcc" + else + echo "未找到 nvcc,跳过 nvcc 检查" + fi +fi + + +echo +echo "=== 4. PyTorch CUDA 功能检查 ===" + +check "torch CUDA 状态查询" python3 - < 0, "No CUDA device found" +else: + if not torch.cuda.is_available(): + print("CUDA not available, skip GPU assertion") +PY + + +if [ "${REQUIRE_CUDA}" = "1" ]; then + check "GPU Tensor 计算" python3 - <<'"'"'PY'"'"' +import torch + +assert torch.cuda.is_available(), "CUDA is not available" + +device = torch.device("cuda:0") + +print("GPU name:", torch.cuda.get_device_name(0)) + +x = torch.randn(1024, 1024, device=device) +y = torch.randn(1024, 1024, device=device) +z = x @ y + +torch.cuda.synchronize() + +assert z.is_cuda +assert z.shape == (1024, 1024) +assert torch.isfinite(z).all() + +print("GPU matmul OK") +PY +else + echo "REQUIRE_CUDA=0,跳过 GPU Tensor 计算" +fi + + +echo +echo "=== 5. torchvision / torchaudio 基础功能检查 ===" + +check "torchvision transforms" python3 - <<'"'"'PY'"'"' +import torchvision.transforms as T + +transform = T.Compose([ + T.Resize((224, 224)), + T.ToTensor(), +]) + +assert transform is not None +print("torchvision transforms OK") +PY + + +check "torchaudio import" python3 - <<'"'"'PY'"'"' +import torchaudio + +print("torchaudio version:", torchaudio.__version__) +print("torchaudio OK") +PY + + +echo +echo "=== 所有 PyTorch 容器基础测试通过 ===" +' + +echo "✓ 镜像 ${IMAGE} 功能测试通过" +exit 0 \ No newline at end of file diff --git a/frameworks/pytorch/2.11.0/test_result.png b/frameworks/pytorch/2.11.0/test_result.png new file mode 100644 index 0000000000000000000000000000000000000000..53eb6b3807245bf88ce9dc07eabfe3d9b457bdc5 Binary files /dev/null and b/frameworks/pytorch/2.11.0/test_result.png differ