pytorchlab/pytorch Docker Image
轻量级PyTorch基础镜像,支持GPU(CUDA 12.6)和CPU,可选预捆绑YOLO权重,适用于生产环境部署,包含必要系统库并优化镜像大小。
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+.
| Tag | Description |
|---|---|
2.9.1-cuda12.6-cudnn9-runtime | PyTorch + CUDA + system libs. Generic GPU base. |
2.9.1-cuda12.6-cudnn9-yolo26m | Above + YOLO v2.6m & v2.6n weights in /app/weights (Ultralytics offline). |
2.9.1-cuda12.6-cudnn9-yolo11m | Above + YOLO v11m & v2.6n weights in /app/weights (Ultralytics offline). |
CPU (Python 3.11 Slim)
Built from
python:3.11-slimwith CPU-only PyTorch (~1.5 GB lighter than the CUDA variant).
| Tag | Description |
|---|---|
2.4.1-cpu-py3.11-slim | PyTorch (CPU-only) + system libs. Generic CPU base. |
cpu-python3.11-yolo26m | Above + YOLO v2.6m & v2.6n weights in /app/weights (Ultralytics offline). |
cpu-python3.11-yolo11m | Above + 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
dockerfileFROM 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
dockerfileFROM 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)
dockerfileFROM 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
| Requirement | Notes |
|---|---|
| Docker Engine 20.10+ | Tested on Docker Desktop & Docker CE |
| NVIDIA Container Toolkit | GPU tags only — https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html |
| NVIDIA driver ≥ 525 | Required for CUDA 12.6 compatibility |
Environment Variables (pre-set in YOLO variants)
| Variable | Value | Description |
|---|---|---|
YOLO_CONFIG_DIR | /app/weights | Ultralytics config & weights directory |
YOLO_OFFLINE | 1 | Disables 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 镜像标签
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务