Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

大模型工作流

说明

  • 本页记录围绕本地大模型工作流的一些环境准备与运行要点.
  • 当前重点是 WSL2 + Ubuntu 24.04 + Docker + NVIDIA GPU 的加速链路, 以及容器代理配置.

在 WSL2 的 Ubuntu 24.04 中为 Docker 启用 NVIDIA GPU

先运行 nvidia-smi 查看 GPU 驱动信息.

安装 CUDA Toolkit

根据平台选择对应脚本, 这里是 Ubuntu WSL:

# 修改为适配 24.04 的路径
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.9.1/local_installers/cuda-repo-wsl-ubuntu-12-9-local_12.9.1-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-12-9-local_12.9.1-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-9-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-9

为 Docker 配置 GPU Runtime

sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

验证:

docker run --rm --gpus all nvidia/cuda:12.0.0-base nvidia-smi

1Panel 中的 Docker 代理配置

容器 -> 配置 -> 全部配置:

{
  "proxies": {
    "http-proxy": "http://127.0.0.1:1080",
    "https-proxy": "http://127.0.0.1:1080",
    "no-proxy": "localhost,127.0.0.1"
  }
}

使用建议

  • GPU 链路排错时, 先确认宿主机驱动, 再确认 WSL, 最后确认 Docker Runtime.
  • 容器可见 GPU 但模型仍跑不起来时, 优先检查镜像内依赖版本和运行参数.
  • 网络环境受限时, 代理配置常常决定镜像拉取和模型下载能否顺利完成.
  • 若后续继续整理, 可补 Ollama, vLLM, 向量数据库和工作流编排的组合实践.