Recommended
Driver >=535.104.05
TensorFlow 2.15.0 + CUDA 12.2
Generate a production-ready Dockerfile with verified compatibility
Configuration Summary
Framework
TensorFlow 2.15.0
CUDA Version
12.2
Python Support
3.9, 3.10, 3.11
Min Driver
>=535.104.05
Note: 需要系统CUDA,不支持pip CUDA
Install Command
pip install tensorflow==2.15.0 What's in TensorFlow 2.15.0
- Last version with bundled CUDA libraries option
- Mature tf.keras API
- Extensive third-party library compatibility
Best For
Use Cases
- Projects with heavy tf.keras dependency
- Compatibility with older TF ecosystem tools
- Gradual migration path to newer versions
CUDA 12.2 Advantages
- Stable production deployments
- Broad GPU compatibility
- GCP Cloud Run deployments
Generate Dockerfile
Configuration
Local GPU or CPU environment
需要系统CUDA,不支持pip CUDA
Requires NVIDIA Driver >=535.104.05
Dockerfile
1# syntax=docker/dockerfile:12# ^ Required for BuildKit cache mounts and advanced features34# Generated by DockerFit (https://tools.eastondev.com/docker)5# TENSORFLOW 2.15.0 + CUDA 12.2 | Python 3.116# Multi-stage build for optimized image size78# ==============================================================================9# Stage 1: Builder - Install dependencies and compile10# ==============================================================================11FROM nvidia/cuda:12.2.0-cudnn8-devel-ubuntu22.04 AS builder1213# Build arguments14ARG DEBIAN_FRONTEND=noninteractive1516# Environment variables17ENV PYTHONUNBUFFERED=118ENV PYTHONDONTWRITEBYTECODE=119ENV TORCH_CUDA_ARCH_LIST="7.5;8.0;8.6"2021# Install Python 3.11 from deadsnakes PPA (Ubuntu 22.04)22RUN apt-get update && apt-get install -y --no-install-recommends \23 software-properties-common \24 && add-apt-repository -y ppa:deadsnakes/ppa \25 && apt-get update && apt-get install -y --no-install-recommends \26 python3.11 \27 python3.11-venv \28 python3.11-dev \29 build-essential \30 git31 && rm -rf /var/lib/apt/lists/*3233# Create virtual environment34ENV VIRTUAL_ENV=/opt/venv35RUN python3.11 -m venv $VIRTUAL_ENV36ENV PATH="$VIRTUAL_ENV/bin:$PATH"3738# Upgrade pip39RUN pip install --no-cache-dir --upgrade pip setuptools wheel4041# Install TensorFlow with BuildKit cache42RUN --mount=type=cache,target=/root/.cache/pip \43 pip install tensorflow==2.15.04445# Install project dependencies46COPY requirements.txt .47RUN --mount=type=cache,target=/root/.cache/pip \48 pip install -r requirements.txt4950# ==============================================================================51# Stage 2: Runtime - Minimal production image52# ==============================================================================53FROM nvidia/cuda:12.2.0-cudnn8-runtime-ubuntu22.04 AS runtime5455# Labels56LABEL maintainer="Generated by DockerFit"57LABEL version="2.15.0"58LABEL description="TENSORFLOW 2.15.0 + CUDA 12.2"5960# Environment variables61ENV PYTHONUNBUFFERED=162ENV PYTHONDONTWRITEBYTECODE=163ENV NVIDIA_VISIBLE_DEVICES=all64ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility6566# Install Python 3.11 runtime from deadsnakes PPA (Ubuntu 22.04)67RUN apt-get update && apt-get install -y --no-install-recommends \68 software-properties-common \69 && add-apt-repository -y ppa:deadsnakes/ppa \70 && apt-get update && apt-get install -y --no-install-recommends \71 python3.11 \72 libgomp173 && apt-get remove -y software-properties-common \74 && apt-get autoremove -y \75 && rm -rf /var/lib/apt/lists/*7677# Create non-root user for security78ARG USERNAME=appuser79ARG USER_UID=100080ARG USER_GID=$USER_UID81RUN groupadd --gid $USER_GID $USERNAME \82 && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME8384# Copy virtual environment from builder85COPY --from=builder --chown=$USERNAME:$USERNAME /opt/venv /opt/venv86ENV VIRTUAL_ENV=/opt/venv87ENV PATH="$VIRTUAL_ENV/bin:$PATH"8889# Set working directory90WORKDIR /app9192# Copy application code93COPY --chown=$USERNAME:$USERNAME . .9495# Switch to non-root user96USER $USERNAME9798# Expose port99EXPOSE 8000100101# Default command102CMD ["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
Frequently Asked Questions
What NVIDIA driver version do I need?
For TensorFlow 2.15.0 with CUDA 12.2, you need NVIDIA driver version >=535.104.05 or higher.
Run nvidia-smi to check your current driver version.
How do I install TensorFlow with CUDA support?
TensorFlow 2.15.0 uses the following installation command:
pip install tensorflow==2.15.0 Since TensorFlow 2.15+, CUDA libraries are bundled via tensorflow[and-cuda].
How do I verify GPU access in the container?
After building your image, run:
docker run --gpus all your-image python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
This should show available GPU devices.