docker GPU基础镜像python

这个博客列举了多种CUDA和CUDNN版本的组合,每种组合都对应了不同版本的Python,主要针对的是Ubuntu GPU环境。这些配置适用于深度学习和GPU加速计算,覆盖了从CUDA 9.0到CUDA 11.0.3的多个版本,旨在为开发者提供灵活的选择来匹配他们的项目需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cuda11.0.3-cudnn8
- ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda11.0.3-cudnn8
	
python3.7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda11.0.3-cudnn8-python3.7
	
python3.8
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda11.0.3-cudnn8-python3.8
	

cuda10.2-cudnn7
- ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.2-cudnn7
	
python3.7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.2-cudnn7-python3.7
	
python3.8
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.2-cudnn7-python3.8
	
	
cuda10.1-cudnn7
- ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.1-cudnn7
	
python3.6
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.1-cudnn7-python3.6
	
python3.7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.1-cudnn7-python3.7
	
python3.8
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.1-cudnn7-python3.8
	
	
cuda10.0-cudnn7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.0-cudnn7
	
python3.6
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.0-cudnn7-python3.6
	
python3.7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.0-cudnn7-python3.7
	
python3.8
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda10.0-cudnn7-python3.8
	
	
cuda9.1-cudnn7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.1-cudnn7
	
python3.6
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.1-cudnn7-python3.6
	
python3.7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.1-cudnn7-python3.7
	
python3.8
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.1-cudnn7-python3.8
	

cuda9.0-cudnn7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.0-cudnn7
	
python3.6
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.0-cudnn7-python3.6
	
python3.7
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.0-cudnn7-python3.7
	
python3.8
 - ccr.ccs.tencentyun.com/cube-studio/ubuntu-gpu:cuda9.0-cudnn7-python3.8
	
	
cuda10.1-cuda10.0-cuda9.0-cudnn7.6
 - ccr.ccs.tencentyun.com/cube-studio/gpu:ubuntu18.04-python3.6-cuda10.1-cuda10.0-cuda9.0-cudnn7.6-base

 python 310 +cuda 11.8 +torch2.1.1

 m.daocloud.io/docker.io/pytorch/pytorch:2.1.0-cuda11.8-cudnn8-devel

### 如何在 Docker 中配置 Python 镜像 为了在 Docker 中成功配置 Python 镜像,可以按照以下方法完成。以下是详细的说明: #### 使用官方 Python 基础镜像 Docker 提供了官方的 Python 镜像,可以直接通过 `FROM` 指令引入作为基础镜像。这一步骤简化了环境搭建的过程。 ```dockerfile FROM python:3.9-slim-buster ``` 上述命令选择了基于 Debian Buster 的轻量级 Python 3.9 镜像[^4]。 --- #### 创建项目目录并编写必要的文件 构建一个完整的 Python 应用程序需要一些基本文件,例如 `requirements.txt` 和应用程序入口脚本(如 `app.py`)。这些文件应放置在一个专门用于项目的目录中。 假设当前目录结构如下: ``` . ├── app.py └── requirements.txt ``` 其中,`requirements.txt` 文件定义了所需的依赖项,而 `app.py` 是应用的主要执行文件。 --- #### 编写 Dockerfile 创建名为 `Dockerfile` 的文件,并添加以下内容: ```dockerfile # 使用官方 Python 镜像作为基础镜像 FROM python:3.9-slim-buster # 设置工作目录 WORKDIR /app # 将本地代码复制到容器的工作目录 COPY . . # 安装依赖项 RUN pip install --no-cache-dir -r requirements.txt # 运行应用程序 CMD ["python", "app.py"] ``` 此 Dockerfile 执行的操作包括: 1. **指定基础镜像**:使用官方 Python 镜像2. **设置工作目录**:将 `/app` 设定为容器内的默认路径。 3. **复制文件**:将主机上的所有文件复制到容器中的对应位置。 4. **安装依赖**:利用 `pip` 工具解析并安装 `requirements.txt` 中列出的所有库。 5. **运行命令**:当容器启动时,默认运行 `app.py` 脚本。 --- #### 构建镜像 在包含 `Dockerfile` 的目录下运行以下命令来构建镜像: ```bash docker build -t my-python-app . ``` 该命令会读取当前目录下的 `Dockerfile` 并将其编译成一个新的镜像,命名为 `my-python-app`[^3]。 --- #### 启动容器 构建完成后,可以通过以下命令启动容器: ```bash docker run -d --name running-python-app -p 8000:8000 my-python-app ``` 这条命令的作用是以后台模式运行容器,并将宿主机的端口 `8000` 映射到容器内部的相同端口。如果应用程序监听的是其他端口,则需调整映射关系。 --- #### 添加 GPU 支持(可选) 如果目标环境中涉及 CUDA 或 TensorFlow 等框架,可能还需要额外配置 NVIDIA-Docker 来启用 GPU 加速功能。具体步骤包括拉取支持 CUDA镜像以及挂载数据卷等操作[^2]。 例如,可以从以下地址获取预配置好的 CUDA 镜像: ```bash docker pull nvidia/cuda:11.0-base-ubuntu20.04 ``` 随后,在自定义镜像基础上集成 Python 及其相关工具即可实现更复杂的场景需求。 --- ### 总结 以上流程涵盖了从零开始配置 DockerPython 镜像的核心环节,包括选用合适的基底镜像、准备必要资源文件、撰写 Dockerfile 描述逻辑直至最终部署上线整个过程。对于初学者而言,建议逐步尝试每一步以加深理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会发paper的学渣

您的鼓励和将是我前进的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值