pytorch

pytorchlab/pytorch Docker Image

轻量级PyTorch基础镜像,支持GPU(CUDA 12.6)和CPU,可选预捆绑YOLO权重,适用于生产环境部署,包含必要系统库并优化镜像大小。

下载次数: 0状态:社区镜像维护者:pytorchlab仓库类型:镜像最近更新:5 个月前
下载命令
点击查看

pytorchlab/pytorch

Minimal, production-ready PyTorch base images for GPU and CPU workloads — with optional pre-bundled YOLO weights for offline inference.


Overview

pytorchlab/pytorch provides slim, multi-variant Docker images on top of the official https://hub.docker.com/r/pytorch/pytorch base. Each image adds only what is needed for real-world deployments:

  • System libraries required by OpenCV (libGL, libglib2.0, libpq, libgeos)
  • Clean layer — __pycache__ removed at build time to minimize image size
  • YOLO variants — pre-downloaded Ultralytics weights bundled inside the image so that ECS/Kubernetes workers have zero outbound dependency at runtime

Available Tags

GPU (CUDA 12.6 + cuDNN 9)

Built from pytorch/pytorch:2.9.1-cuda12.6-cudnn9-runtime. Requires NVIDIA drivers compatible with CUDA 12.6+.

TagDescription
2.9.1-cuda12.6-cudnn9-runtimePyTorch + CUDA + system libs. Generic GPU base.
2.9.1-cuda12.6-cudnn9-yolo26mAbove + YOLO v2.6m & v2.6n weights in /app/weights (Ultralytics offline).
2.9.1-cuda12.6-cudnn9-yolo11mAbove + YOLO v11m & v2.6n weights in /app/weights (Ultralytics offline).

CPU (Python 3.11 Slim)

Built from python:3.11-slim with CPU-only PyTorch (~1.5 GB lighter than the CUDA variant).

TagDescription
2.4.1-cpu-py3.11-slimPyTorch (CPU-only) + system libs. Generic CPU base.
cpu-python3.11-yolo26mAbove + YOLO v2.6m & v2.6n weights in /app/weights (Ultralytics offline).
cpu-python3.11-yolo11mAbove + YOLO v11m & v2.6n weights in /app/weights (Ultralytics offline).

Quick Start

bash
# GPU — verify CUDA is available
docker pull pytorchlab/pytorch:2.9.1-cuda12.6-cudnn9-runtime
docker run --gpus all --rm pytorchlab/pytorch:2.9.1-cuda12.6-cudnn9-runtime \
  python -c "import torch; print('CUDA:', torch.cuda.is_available())"

# CPU — lightweight inference
docker pull pytorchlab/pytorch:2.4.1-cpu-py3.11-slim
docker run --rm pytorchlab/pytorch:2.4.1-cpu-py3.11-slim \
  python -c "import torch; print('PyTorch:', torch.__version__)"

Use as a Base Image

GPU workload

dockerfile
FROM pytorchlab/pytorch:2.9.1-cuda12.6-cudnn9-runtime

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
CMD ["python", "train.py"]

CPU workload / lightweight inference

dockerfile
FROM pytorchlab/pytorch:2.4.1-cpu-py3.11-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
CMD ["python", "inference.py"]

Offline YOLO inference (no internet required at runtime)

dockerfile
FROM pytorchlab/pytorch:2.9.1-cuda12.6-cudnn9-yolo26m

# Weights are pre-downloaded at /app/weights/yolo26m.pt & yolo26n.pt
# YOLO_OFFLINE=1 and YOLO_CONFIG_DIR=/app/weights are already set
WORKDIR /app
COPY . .
CMD ["python", "detect.py"]

Requirements

RequirementNotes
Docker Engine 20.10+Tested on Docker Desktop & Docker CE
NVIDIA Container ToolkitGPU tags only — https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
NVIDIA driver ≥ 525Required for CUDA 12.6 compatibility

Environment Variables (pre-set in YOLO variants)

VariableValueDescription
YOLO_CONFIG_DIR/app/weightsUltralytics config & weights directory
YOLO_OFFLINE1Disables Ultralytics auto-download at runtime

License

  • Image build scripts: MIT License
  • PyTorch: https://github.com/pytorch/pytorch/blob/main/LICENSE
  • Ultralytics YOLO (weights in YOLO variants): https://github.com/ultralytics/ultralytics/blob/main/LICENSE

Note: The YOLO weight files bundled in the YOLO-variant images are subject to the Ultralytics AGPL-3.0 license. Ensure your use case complies with this license.

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 pytorch 镜像标签

docker pull docker.xuanyuan.run/pytorchlab/pytorch:<标签>

DockerHub 原生拉取命令

docker pull pytorchlab/pytorch:<标签>
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载在线技术支持专业版保障服务可用付费会员免广告