conda安装pytorch的一些细节
pytorch官方的安装指令:
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
其中提到频道 nvidia
查看常用的conda 清华源,发现并没有这个频道。
南方科技大学有这个频道:https://mirrors.sustech.edu.cn/anaconda-extra/cloud/
这里有个简短的讨论:https://github.com/tuna/issues/issues/1232
下面是我的一些分析
在安装时,记录了一下安装文件,搜索到关于频道“nvidia”相关的包:
(base) logic@PC:~/文档$ cat conda-pytorch-log | grep "nvidia/"
cuda-cudart nvidia/linux-64::cuda-cudart-12.1.105-0
cuda-cupti nvidia/linux-64::cuda-cupti-12.1.105-0
cuda-libraries nvidia/linux-64::cuda-libraries-12.1.0-0
cuda-nvrtc nvidia/linux-64::cuda-nvrtc-12.1.105-0
cuda-nvtx nvidia/linux-64::cuda-nvtx-12.1.105-0
cuda-opencl nvidia/linux-64::cuda-opencl-12.5.39-0
cuda-runtime nvidia/linux-64::cuda-runtime-12.1.0-0
cuda-version nvidia/noarch::cuda-version-12.5-3
libcublas nvidia/linux-64::libcublas-12.1.0.26-0
libcufft nvidia/linux-64::libcufft-11.0.2.4-0
libcufile nvidia/linux-64::libcufile-1.10.0.4-0
libcurand nvidia/linux-64::libcurand-10.3.6.39-0
libcusolver nvidia/linux-64::libcusolver-11.4.4.55-0
libcusparse nvidia/linux-64::libcusparse-12.0.2.55-0
libnpp nvidia/linux-64::libnpp-12.0.2.50-0
libnvjitlink nvidia/linux-64::libnvjitlink-12.1.105-0
libnvjpeg nvidia/linux-64::libnvjpeg-12.1.1.14-0
那这些包的对应的下载网址是什么?以及简短介绍?等等,查询方法如下:
举例说明:
如:cuda-cudart
1、先用 conda search 查询版本信息:
(base) logic@PC:~$ conda search cuda-cudart
Loading channels: done
# Name Version Build Channel
cuda-cudart 12.4.127 h99ab3db_0 anaconda/pkgs/main
注意:虽然这里显示频道是main 但,其实不是 main,是 nvidia 频道,只是 main 的优先级高,同时也含有这个包。
如果加上频道参数,再次搜索,就会发现 nvidia 中包含 cuda-cudart 更多的版本
(base) logic@PC:~$ conda search cuda-cudart -c nvidia
Loading channels: done
# Name Version Build Channel
cuda-cudart 11.3.58 hc1aae59_0 nvidia
cuda-cudart 11.4.43 0 nvidia
cuda-cudart 11.4.43 h575c51f_0 nvidia
cuda-cudart 11.4.108 0 nvidia
cuda-cudart 11.4.108 h5026fff_0 nvidia
cuda-cudart 11.4.148 0 nvidia
cuda-cudart 11.4.148 hdbdec28_0 nvidia
cuda-cudart 11.5.50 h79feb7f_0 nvidia
cuda-cudart 11.5.117 h7e867a7_0 nvidia
cuda-cudart 11.6.55 he381448_0 nvidia
cuda-cudart 11.7.60 h9538e0e_0 nvidia
cuda-cudart 11.7.99 0 nvidia
cuda-cudart 11.8.89 0 nvidia
cuda-cudart 12.0.107 0 nvidia
cuda-cudart 12.0.146 0 nvidia
cuda-cudart 12.1.55 0 nvidia
cuda-cudart 12.1.105 0 nvidia
cuda-cudart 12.2.53 0 nvidia
cuda-cudart 12.2.128 0 nvidia
cuda-cudart 12.2.140 0 nvidia
cuda-cudart 12.3.52 0 nvidia
cuda-cudart 12.3.101 0 nvidia
cuda-cudart 12.4.99 0 nvidia
cuda-cudart 12.4.127 0 nvidia
cuda-cudart 12.4.127 h99ab3db_0 anaconda/pkgs/main
cuda-cudart 12.5.39 0 nvidia
2、手动查找安装目录下的 info 文件夹。
比如cuda-cudart的目录是:~/miniconda3/pkgs/cuda-cudart-12.1.105-0/info
这个目录下面有多个文件:
about.json files git index.json paths.json repodata_record.json
其中 "about.json" 和 "repodata_record.json" 是包含软件的下载具体地址,简略信息等。
如在 about.json 中,有如下信息:
"channels": [
"https://repo.anaconda.com/pkgs/main",
"https://conda.anaconda.org/nvidia/linux-64"
],
"conda_build_version": "3.21.8",
"conda_private": false,
"conda_version": "4.12.0",
"description": "CUDA Runtime native Libraries\n",
"doc_url": "https://docs.nvidia.com/cuda/index.html",
"env_vars": {
"CIO_TEST": "<not set>"
},
"extra": {
"copy_test_source_files": true,
"final": true
},
"home": "https://developer.nvidia.com/cuda-toolkit",
"identifiers": [],
"keywords": [],
"license_url": "https://docs.nvidia.com/cuda/eula/index.html",
在 repodata_record.json 中有:
"arch": "x86_64",
"build": "0",
"build_number": 0,
"channel": "https://conda.anaconda.org/nvidia/linux-64",
"constrains": [],
"depends": [],
"fn": "cuda-cudart-12.1.105-0.tar.bz2",
"license": "",
"md5": "001823a01c0d49300fd9622c4578eb40",
"name": "cuda-cudart",
"platform": "linux",
"sha256": "8ce27449a0a1d98630b8b13669590a34b04bccf11bf9a98151a40541f7edf7ba",
"size": 193370,
"subdir": "linux-64",
"timestamp": 1680585606000,
"url": "https://conda.anaconda.org/nvidia/linux-64/cuda-cudart-12.1.105-0.tar.bz2",
"version": "12.1.105"
在这个文件中,显示了频道 nvidia 的地址是:https://conda.anaconda.org/nvidia/linux-64,找到了我想要的信息。