系统工程

阶段4 | 第39-42周

📅 4周学习计划

第39周

Docker GPU容器
NVIDIA Container Toolkit

第40周

Kubernetes GPU调度
GPU Operator

第41周

GPU监控
DCGM + Prometheus

第42周

CI/CD
部署自动化

1. Docker GPU容器

NVIDIA Container Toolkit

# 运行GPU容器
docker run --gpus all nvidia/cuda:11.8-base nvidia-smi

# 指定GPU数量
docker run --gpus 2 my-image

# 指定特定GPU
docker run --gpus '"device=0,2"' my-image

# Dockerfile示例
FROM nvidia/cuda:11.8-cudnn8-devel-ubuntu22.04
RUN apt-get update && apt-get install -y python3-pip
COPY requirements.txt .
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python3", "app.py"]

2. Kubernetes GPU调度

# K8s GPU Pod示例
apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
spec:
  containers:
  - name: gpu-container
    image: my-gpu-image
    resources:
      limits:
        nvidia.com/gpu: 1

3. GPU监控

DCGM (Data Center GPU Manager)

# DCGM Exporter
kubectl apply -f https://raw.githubusercontent.com/NVIDIA/dcgm-exporter/main/deploy/k8s/dcgm-exporter.yaml

# Prometheus查询示例
DCGM_FI_DEV_GPU_UTIL  # GPU利用率
DCGM_FI_DEV_FB_USED   # 显存使用
DCGM_FI_DEV_GPU_TEMP  # GPU温度

4. AI Infra生态

📚 学习资源

🛠️ 实践项目