获取nvidia cuda docker官方镜像(2024.9)

因为我的宿主机  是ubuntu22.04,但是我现在需要用cuda11.3的编译环境,cuda11.3最高支持ubuntu20.04;所以我想在ubuntu22.04上安装一个ubuntu20.04的docker镜像,然后我要在docker里面安装nvidia cuda toolkit等等环境,这会不会有些麻烦,nvidia cuda有自己的docker 镜像,那我直接下载安装cuda镜像,岂不完美。

我确定了ubuntu的版本、cuda toolkit的版本以及cudnn的版本,但是我不知道在nvidia/cuda里面的标签是什么。通过下面的方法来确定tag名。

首先要获取nvidia镜像的列表:

https://hub.docker.com/r/nvidia/cuda/tags?page=2&name=11.3

可以直接在docker hub官网上查找,但是2024.7月以后应该就被墙了,挂vpn走境外服务器都不行。

当然也有办法获取到nvidia的镜像列表:

要详细显示 Docker Hub 上 nvidia/cuda 镜像的所有版本号,你可以使用以下几种方法来获取镜像的详细信息和可用的标签。

1. 使用 Docker CLI 列出标签

虽然 Docker CLI 本身没有直接列出所有标签的功能,你可以使用以下方法获取镜像标签:

使用 skopeo 工具(需要安装):

  • skopeo 是一个工具,可以用来查询远程镜像仓库的镜像标签。
  • 安装 skopeo:
    sudo apt-get install skopeo
  • 列出 nvidia/cuda 的所有标签:
    skopeo list-tags docker://docker.io/nvidia/cuda

2. 使用 Docker Hub API

通过 Docker Hub API,你可以查询镜像标签:

  1. 发送请求:
  2. 解析结果:
    • 这个请求将返回一个 JSON 对象,其中包含镜像的标签列表。你可以使用工具如 jq 来提取标签信息。

可以看到类似下面的nvida/cuda的标签列表。

如果你使用上面的方法不行,请尝试 /etc/docker/daemon.json文件中增加源:(下面的源不行的话,就搜一些别的源添加进去)

{
  "registry-mirrors":["https://dockerhub.xianfish.site", "https://docker.m.daocloud.io", "https://ustc-edu-cn.mirror.aliyuncs.com"]
}

修改镜像地址之后需要重新加载这个配置文件或者重启docker:

systemctl restart docker 或者service docker restart

获取到标准的nvidia/cuda 的tag名之后,就可以下载了。

比方说我现在想下载

tag:11.3.1-cudnn8-devel-ubuntu20.04

docker pull nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.0

要顺利pull,要保证你配置的源可用。

(pytorch_env) PS E:\PyTorch_Build\pytorch> # 更新 Conda 并添加更多频道 (pytorch_env) PS E:\PyTorch_Build\pytorch> conda update -y -n base conda 3 channel Terms of Service accepted Retrieving notices: done Channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - defaults Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done # All requested packages already installed. (pytorch_env) PS E:\PyTorch_Build\pytorch> conda config --add channels conda-forge (pytorch_env) PS E:\PyTorch_Build\pytorch> conda config --add channels defaults Warning: &#39;defaults&#39; already in &#39;channels&#39; list, moving to the top (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 安装可用版本的 libuv (pytorch_env) PS E:\PyTorch_Build\pytorch> conda install -y libuv=1.44 # 使用最新可用版本替代 1.46 3 channel Terms of Service accepted Channels: - defaults - conda-forge - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: C:\Miniconda3 added / updated specs: - libuv=1.44 The following packages will be downloaded: package | build ---------------------------|----------------- libuv-1.44.2 | h2bbff1b_0 288 KB defaults ------------------------------------------------------------ Total: 288 KB The following NEW packages will be INSTALLED: libuv pkgs/main/win-64::libuv-1.44.2-h2bbff1b_0 Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: done (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 安装其他必要依赖 (pytorch_env) PS E:\PyTorch_Build\pytorch> conda install -y ` >> openssl=3.1 ` >> numpy ` >> mkl=2024.1 ` >> mkl-include=2024.1 ` >> libblas=*=*mkl 3 channel Terms of Service accepted Channels: - defaults - conda-forge - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: C:\Miniconda3 added / updated specs: - libblas[build=*mkl] - mkl-include=2024.1 - mkl=2024.1 - numpy - openssl=3.1 The following packages will be downloaded: package | build ---------------------------|----------------- intel-openmp-2024.2.1 | h57928b3_1083 1.8 MB conda-forge libblas-3.9.0 | 24_win64_mkl 4.9 MB conda-forge libcblas-3.9.0 | 24_win64_mkl 4.9 MB conda-forge liblapack-3.9.0 | 24_win64_mkl 4.9 MB conda-forge mkl-2024.1.0 | h66d3029_694 104.3 MB conda-forge mkl-include-2024.1.0 | h66d3029_694 675 KB conda-forge numpy-2.3.2 | py313hce7ae62_2 7.1 MB conda-forge openssl-3.1.8 | ha4e3fda_0 7.1 MB conda-forge tbb-2021.8.0 | h59b6b97_0 149 KB defaults ------------------------------------------------------------ Total: 135.9 MB The following NEW packages will be INSTALLED: intel-openmp conda-forge/win-64::intel-openmp-2024.2.1-h57928b3_1083 libblas conda-forge/win-64::libblas-3.9.0-24_win64_mkl libcblas conda-forge/win-64::libcblas-3.9.0-24_win64_mkl liblapack conda-forge/win-64::liblapack-3.9.0-24_win64_mkl mkl conda-forge/win-64::mkl-2024.1.0-h66d3029_694 mkl-include conda-forge/win-64::mkl-include-2024.1.0-h66d3029_694 numpy conda-forge/win-64::numpy-2.3.2-py313hce7ae62_2 tbb pkgs/main/win-64::tbb-2021.8.0-h59b6b97_0 The following packages will be UPDATED: openssl pkgs/main::openssl-3.0.17-h35632f6_0 --> conda-forge::openssl-3.1.8-ha4e3fda_0 Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: done (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 验证安装 (pytorch_env) PS E:\PyTorch_Build\pytorch> python -c "import mkl; print(f&#39;MKL version: {mkl.__version__}&#39;)" Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named &#39;mkl&#39; (pytorch_env) PS E:\PyTorch_Build\pytorch> # 更新 Conda 并添加更多频道 (pytorch_env) PS E:\PyTorch_Build\pytorch> conda update -y -n base conda 3 channel Terms of Service accepted Channels: - defaults - conda-forge - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done # All requested packages already installed. (pytorch_env) PS E:\PyTorch_Build\pytorch> conda config --add channels conda-forge Warning: &#39;conda-forge&#39; already in &#39;channels&#39; list, moving to the top (pytorch_env) PS E:\PyTorch_Build\pytorch> conda config --add channels defaults Warning: &#39;defaults&#39; already in &#39;channels&#39; list, moving to the top (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 安装可用版本的 libuv (pytorch_env) PS E:\PyTorch_Build\pytorch> conda install -y libuv=1.44 # 使用最新可用版本替代 1.46 3 channel Terms of Service accepted Channels: - defaults - conda-forge - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done # All requested packages already installed. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 安装其他必要依赖 (pytorch_env) PS E:\PyTorch_Build\pytorch> conda install -y ` >> openssl=3.1 ` >> numpy ` >> mkl=2024.1 ` >> mkl-include=2024.1 ` >> libblas=*=*mkl 3 channel Terms of Service accepted Channels: - defaults - conda-forge - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 验证安装 (pytorch_env) PS E:\PyTorch_Build\pytorch> python -c "import mkl; print(f&#39;MKL version: {mkl.__version__}&#39;)" Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named &#39;mkl&#39; (pytorch_env) PS E:\PyTorch_Build\pytorch> # 卸载当前环境中的 PyTorch (pytorch_env) PS E:\PyTorch_Build\pytorch> pip uninstall -y torch WARNING: Skipping torch as it is not installed. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 安装官方预编译版本 (CUDA 13.0) (pytorch_env) PS E:\PyTorch_Build\pytorch> pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130 Looking in indexes: https://download.pytorch.org/whl/cu130 ERROR: Could not find a version that satisfies the requirement torch (from versions: none) ERROR: No matching distribution found for torch (pytorch_env) PS E:\PyTorch_Build\pytorch> ^C (pytorch_env) PS E:\PyTorch_Build\pytorch> FROM nvidia/cuda:13.0-devel-ubuntu22.04 ParserError: Line | 1 | FROM nvidia/cuda:13.0-devel-ubuntu22.04 | ~~~~ | The &#39;from&#39; keyword is not supported in this version of the language. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> RUN apt-get update && \ RUN: The term &#39;RUN&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> apt-get install -y git ninja-build python3-pip curl apt-get: The term &#39;apt-get&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> RUN pip3 install cmake RUN: The term &#39;RUN&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> RUN git clone https://github.com/pytorch/pytorch RUN: The term &#39;RUN&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> WORKDIR pytorch WORKDIR: The term &#39;WORKDIR&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> RUN git submodule update --init --recursive RUN: The term &#39;RUN&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> RUN python3 setup.py install RUN: The term &#39;RUN&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> docker build -t pytorch-custom . docker: The term &#39;docker&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch> python -c " >> import torch >> print(&#39;=&#39;*50) >> print(f&#39;PyTorch 版本: {torch.__version__}&#39;) >> print(f&#39;CUDA 可用: {torch.cuda.is_available()}&#39;) >> if torch.cuda.is_available(): >> print(f&#39;CUDA 版本: {torch.version.cuda}&#39;) >> print(f&#39;cuDNN 版本: {torch.backends.cudnn.version()}&#39;) >> print(f&#39;MKL 可用: {torch.__config__.mkl_is_available()}&#39;) >> print(&#39;=&#39;*50) >> " ================================================== Traceback (most recent call last): File "<string>", line 4, in <module> AttributeError: module &#39;torch&#39; has no attribute &#39;__version__&#39; (pytorch_env) PS E:\PyTorch_Build\pytorch> # 获取官方构建工具 (pytorch_env) PS E:\PyTorch_Build\pytorch> git clone https://github.com/pytorch/builder Cloning into &#39;builder&#39;... remote: Enumerating objects: 15730, done. remote: Counting objects: 100% (1631/1631), done. remote: Compressing objects: 100% (178/178), done. remote: Total 15730 (delta 1538), reused 1453 (delta 1453), pack-reused 14099 (from 2) Receiving objects: 100% (15730/15730), 4.05 MiB | 2.47 MiB/s, done. Resolving deltas: 100% (10109/10109), done. (pytorch_env) PS E:\PyTorch_Build\pytorch> cd builder (pytorch_env) PS E:\PyTorch_Build\pytorch\builder> (pytorch_env) PS E:\PyTorch_Build\pytorch\builder> # 运行 Windows 构建脚本 (pytorch_env) PS E:\PyTorch_Build\pytorch\builder> .\windows\build_pytorch.bat -cudaver 13.0 -cudnnver 9.12 .\windows\build_pytorch.bat: The term &#39;.\windows\build_pytorch.bat&#39; is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (pytorch_env) PS E:\PyTorch_Build\pytorch\builder>
09-02
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

corey_li

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值