Driver >=510.47.03

PyTorch 1.13.1 + CUDA 11.6

Generate a production-ready Dockerfile with verified compatibility

Configuration Summary

Framework
PyTorch 1.13.1
CUDA Version
11.6
Python Support
3.7, 3.8, 3.9, 3.10
Min Driver
>=510.47.03

What's in PyTorch 1.13.1

  • Last major PyTorch 1.x version
  • Complete CUDA 11.x support
  • Mature production ecosystem

Best For

This Version

  • Maintaining 1.x systems
  • Maximum compatibility with legacy code
  • Projects unable to migrate to 2.x

CUDA 11.6

  • PyTorch 1.13.x deployments
  • Maximum backward compatibility
  • Older Ubuntu 20.04 systems
Note: Deprecated CUDA version, use 11.7+ when possible

Generate Dockerfile

Configuration

Local GPU or CPU environment

Requires NVIDIA Driver >=510.47.03
Dockerfile
1# syntax=docker/dockerfile:1
2# ^ Required for BuildKit cache mounts and advanced features
3
4# Generated by DockerFit (https://tools.eastondev.com/docker)
5# PYTORCH 1.13.1 + CUDA 11.6 | Python 3.11
6# Multi-stage build for optimized image size
7
8# ==============================================================================
9# Stage 1: Builder - Install dependencies and compile
10# ==============================================================================
11FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04 AS builder
12
13# Build arguments
14ARG DEBIAN_FRONTEND=noninteractive
15
16# Environment variables
17ENV PYTHONUNBUFFERED=1
18ENV PYTHONDONTWRITEBYTECODE=1
19ENV TORCH_CUDA_ARCH_LIST="7.5;8.0;8.6"
20
21# Install Python 3.11 and build tools (native)
22RUN apt-get update && apt-get install -y --no-install-recommends \
23 python3.11 \
24 python3.11-venv \
25 python3.11-dev \
26 build-essential \
27 git
28 && rm -rf /var/lib/apt/lists/*
29
30# Create virtual environment
31ENV VIRTUAL_ENV=/opt/venv
32RUN python3.11 -m venv $VIRTUAL_ENV
33ENV PATH="$VIRTUAL_ENV/bin:$PATH"
34
35# Upgrade pip
36RUN pip install --no-cache-dir --upgrade pip setuptools wheel
37
38# Install PyTorch with BuildKit cache
39RUN --mount=type=cache,target=/root/.cache/pip \
40 pip install torch torchvision torchaudio \
41 --index-url https://download.pytorch.org/whl/cu116
42
43# Install project dependencies
44COPY requirements.txt .
45RUN --mount=type=cache,target=/root/.cache/pip \
46 pip install -r requirements.txt
47
48# ==============================================================================
49# Stage 2: Runtime - Minimal production image
50# ==============================================================================
51FROM nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04 AS runtime
52
53# Labels
54LABEL maintainer="Generated by DockerFit"
55LABEL version="1.13.1"
56LABEL description="PYTORCH 1.13.1 + CUDA 11.6"
57
58# Environment variables
59ENV PYTHONUNBUFFERED=1
60ENV PYTHONDONTWRITEBYTECODE=1
61ENV NVIDIA_VISIBLE_DEVICES=all
62ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
63
64# Install runtime dependencies (native Python 3.11)
65RUN apt-get update && apt-get install -y --no-install-recommends \
66 python3.11 \
67 libgomp1
68 && rm -rf /var/lib/apt/lists/*
69
70# Create non-root user for security
71ARG USERNAME=appuser
72ARG USER_UID=1000
73ARG USER_GID=$USER_UID
74RUN groupadd --gid $USER_GID $USERNAME \
75 && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
76
77# Copy virtual environment from builder
78COPY --from=builder --chown=$USERNAME:$USERNAME /opt/venv /opt/venv
79ENV VIRTUAL_ENV=/opt/venv
80ENV PATH="$VIRTUAL_ENV/bin:$PATH"
81
82# Set working directory
83WORKDIR /app
84
85# Copy application code
86COPY --chown=$USERNAME:$USERNAME . .
87
88# Switch to non-root user
89USER $USERNAME
90
91# Expose port
92EXPOSE 8000
93
94# Default command
95CMD ["python", "main.py"]
🚀 Recommended

High-Performance GPU Cloud

Deploy your Docker containers with powerful NVIDIA GPUs. A100/H100 available, 32+ global locations.

  • NVIDIA A100/H100 GPU instances
  • Hourly billing, starting at $0.004/h
  • 32+ global data centers
  • One-click container & bare metal deployment
🎁 Deploy Now

Frequently Asked Questions

What NVIDIA driver version do I need?

For PyTorch 1.13.1 with CUDA 11.6, you need NVIDIA driver version >=510.47.03 or higher.

Run nvidia-smi to check your current driver version.

Which Python version should I use?

PyTorch 1.13.1 supports Python versions: 3.7, 3.8, 3.9, 3.10.

We recommend using Python 3.9 for the best balance of compatibility and features.

How do I verify GPU access in the container?

After building your image, run:

docker run --gpus all your-image python -c "import torch; print(torch.cuda.is_available())"

This should print True if GPU is accessible.