使用 PaddlePaddle 官方提供的 Docker 镜像

CUDA版本高PaddlePaddle不支持时,可以使用 PaddlePaddle 官方提供的 Docker 镜像

      • [1. 安装 Docker Desktop](#1. 安装 Docker Desktop)
        • [1.1 下载 Docker Desktop](#1.1 下载 Docker Desktop)
        • [1.2 安装 Docker Desktop](#1.2 安装 Docker Desktop)
        • [1.3 启用 WSL 2 或 Hyper-V](#1.3 启用 WSL 2 或 Hyper-V)
        • [1.4 启动 Docker Desktop](#1.4 启动 Docker Desktop)
      • [2. 拉取 PaddlePaddle Docker 镜像](#2. 拉取 PaddlePaddle Docker 镜像)
        • [2.1 打开终端](#2.1 打开终端)
        • [2.2 拉取镜像](#2.2 拉取镜像)
      • [3. 运行 Docker 容器](#3. 运行 Docker 容器)
        • [3.1 运行 GPU 容器](#3.1 运行 GPU 容器)
        • [3.2 运行 CPU 容器](#3.2 运行 CPU 容器)
      • [4. 验证 PaddlePaddle 安装](#4. 验证 PaddlePaddle 安装)
      • [5. 使用 Docker 容器](#5. 使用 Docker 容器)
        • [5.1 运行 Python 脚本](#5.1 运行 Python 脚本)
      • [6. 退出和删除容器](#6. 退出和删除容器)
      • [7. 常见问题](#7. 常见问题)
        • [7.1 Docker 无法启动](#7.1 Docker 无法启动)
        • [7.2 GPU 不支持](#7.2 GPU 不支持)

在 Windows 系统上使用 Docker 镜像运行 PaddlePaddle 或其他应用程序非常简单。以下是详细步骤:

1. 安装 Docker Desktop

Docker Desktop 是 Windows 上运行 Docker 的官方工具。以下是安装步骤:

1.1 下载 Docker Desktop

访问 Docker 官方网站

下载适用于 Windows 的 Docker Desktop 安装程序。

1.2 安装 Docker Desktop

1、运行下载的安装程序。

2、按照提示完成安装。

3、安装完成后,重启电脑。

1.3 启用 WSL 2 或 Hyper-V

Docker Desktop 需要 WSL 2(Windows Subsystem for Linux 2)或 Hyper-V 支持。

#WSL 2(推荐):

1、打开 PowerShell(管理员权限)。

2、运行以下命令启用 WSL 2:

python 复制代码
wsl --install

3、安装完成后,重启电脑。

#Hyper-V:

1、打开"控制面板" -> "程序" -> "启用或关闭 Windows 功能"。

2、勾选"Hyper-V"并点击"确定"。

3、重启电脑。

1.4 启动 Docker Desktop

1、在开始菜单中搜索并启动 Docker Desktop。

2、等待 Docker 启动(右下角系统托盘中的 Docker 图标变为绿色)。

2. 拉取 PaddlePaddle Docker 镜像

PaddlePaddle 提供了预配置的 Docker 镜像,支持 GPU 和 CPU。

2.1 打开终端

打开 PowerShell 或 Windows 终端。

2.2 拉取镜像

运行以下命令拉取 PaddlePaddle 镜像(以 GPU 版本为例):

python 复制代码
docker pull paddlepaddle/paddle:2.5.2-gpu-cuda11.7-cudnn8

3. 运行 Docker 容器

拉取镜像后,可以通过以下命令运行容器。

3.1 运行 GPU 容器

如果你的系统支持 GPU,可以使用以下命令运行容器:

python 复制代码
docker run --gpus all -it paddlepaddle/paddle:2.5.2-gpu-cuda11.7-cudnn8 /bin/bash
3.2 运行 CPU 容器

如果你的系统不支持 GPU,可以使用以下命令运行 CPU 容器:

python 复制代码
docker run -it paddlepaddle/paddle:2.5.2 /bin/bash

4. 验证 PaddlePaddle 安装

在容器中运行以下命令,验证 PaddlePaddle 是否正确安装:

python 复制代码
python -c "import paddle; print(paddle.device.is_compiled_with_cuda())"

如果输出 True,说明 GPU 支持已启用。

如果输出 False,说明当前运行的是 CPU 版本。

5. 使用 Docker 容器

在容器中,你可以像在本地环境中一样运行 Python 脚本或 Jupyter Notebook。

5.1 运行 Python 脚本

将本地脚本挂载到容器中并运行:

python 复制代码
docker run --gpus all -v C:/path/to/your/script:/workspace -it paddlepaddle/paddle:2.5.2-gpu-cuda11.7-cudnn8 /bin/bash
cd /workspace
python your_script.py

5.2 运行 Jupyter Notebook

启动 Jupyter Notebook 服务:

python 复制代码
docker run --gpus all -p 8888:8888 -v C:/path/to/your/notebooks:/workspace paddlepaddle/paddle:2.5.2-gpu-cuda11.7-cudnn8 jupyter notebook --ip=0.0.0.0 --allow-root

然后在浏览器中访问 http://localhost:8888

6. 退出和删除容器

退出容器:在容器中运行 exit。

删除容器:使用以下命令删除已停止的容器:

python 复制代码
docker rm <container_id>

7. 常见问题

7.1 Docker 无法启动

确保 WSL 2 或 Hyper-V 已启用。

确保 BIOS 中启用了虚拟化技术(VT-x/AMD-V)。

7.2 GPU 不支持

确保已安装 NVIDIA 驱动程序。

确保已安装 NVIDIA Container Toolkit

相关推荐
Aspect of twilight1 天前
深度学习各种优化器详解
人工智能·深度学习
徽4401 天前
农田植被目标检测数据标注与模型训练总结2
人工智能·目标检测·目标跟踪
Elastic 中国社区官方博客1 天前
Elasticsearch 中使用 NVIDIA cuVS 实现最高快 12 倍的向量索引速度:GPU 加速第 2 章
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索·数据库架构
jkyy20141 天前
线上线下融合、跨场景协同—社区健康医疗小屋的智能升级
大数据·人工智能·物联网·健康医疗
Radan小哥1 天前
Docker学习笔记—day011
笔记·学习·docker
苏州知芯传感1 天前
当AI遇见MEMS:机器学习如何优化微振镜的控制与可靠性预测
人工智能·机器学习·3d·mems·微振镜
星域智链1 天前
AI加持日常小节日:让每一份心意都精准升温✨
人工智能·科技·学习·生活·节日
云和恩墨1 天前
AI驱动的Oracle SQL优化:从经验依赖到智能协同的三大价值
人工智能·sql·oracle·深度优先·dba
roman_日积跬步-终至千里1 天前
【模式识别与机器学习(10)】数据预处理-第二部分:数据预处理核心方法
人工智能·机器学习
用户5191495848451 天前
探秘C#伪随机数生成器的安全漏洞与破解之道
人工智能·aigc