Loading...

说在前面

前提是Anaconda安装包已经下载好


1.查看cuda驱动版本

从下图可以看出是11.4版本:


2.创建“屋子”

1
conda create -n ab python=3.9

输出结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
current version: 22.9.0
latest version: 23.11.0

Please update conda by running

$ conda update -n base -c defaults conda



## Package Plan ##

environment location: /data5/shitao/anaconda/envs/ab

added / updated specs:
- python=3.9


The following packages will be downloaded:

package | build
---------------------------|-----------------
ca-certificates-2023.08.22 | h06a4308_0 123 KB
openssl-3.0.12 | h7f8727e_0 5.2 MB
pip-23.3.1 | py39h06a4308_0 2.6 MB
python-3.9.18 | h955ad1f_0 25.1 MB
setuptools-68.0.0 | py39h06a4308_0 928 KB
tzdata-2023c | h04d1e81_0 116 KB
wheel-0.41.2 | py39h06a4308_0 108 KB
xz-5.4.5 | h5eee18b_0 646 KB
------------------------------------------------------------
Total: 34.7 MB

The following NEW packages will be INSTALLED:

_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main None
_openmp_mutex pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu None
ca-certificates pkgs/main/linux-64::ca-certificates-2023.08.22-h06a4308_0 None
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1 None
libffi pkgs/main/linux-64::libffi-3.4.4-h6a678d5_0 None
libgcc-ng pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1 None
libgomp pkgs/main/linux-64::libgomp-11.2.0-h1234567_1 None
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1 None
ncurses pkgs/main/linux-64::ncurses-6.4-h6a678d5_0 None
openssl pkgs/main/linux-64::openssl-3.0.12-h7f8727e_0 None
pip pkgs/main/linux-64::pip-23.3.1-py39h06a4308_0 None
python pkgs/main/linux-64::python-3.9.18-h955ad1f_0 None
readline pkgs/main/linux-64::readline-8.2-h5eee18b_0 None
setuptools pkgs/main/linux-64::setuptools-68.0.0-py39h06a4308_0 None
sqlite pkgs/main/linux-64::sqlite-3.41.2-h5eee18b_0 None
tk pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0 None
tzdata pkgs/main/noarch::tzdata-2023c-h04d1e81_0 None
wheel pkgs/main/linux-64::wheel-0.41.2-py39h06a4308_0 None
xz pkgs/main/linux-64::xz-5.4.5-h5eee18b_0 None
zlib pkgs/main/linux-64::zlib-1.2.13-h5eee18b_0 None


Proceed ([y]/n)? y


Downloading and Extracting Packages
wheel-0.41.2 | 108 KB | ########################################################################################## | 100%
openssl-3.0.12 | 5.2 MB | ########################################################################################## | 100%
setuptools-68.0.0 | 928 KB | ########################################################################################## | 100%
tzdata-2023c | 116 KB | ########################################################################################## | 100%
pip-23.3.1 | 2.6 MB | ########################################################################################## | 100%
xz-5.4.5 | 646 KB | ########################################################################################## | 100%
ca-certificates-2023 | 123 KB | ########################################################################################## | 100%
python-3.9.18 | 25.1 MB | ########################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate ab
#
# To deactivate an active environment, use
#
# $ conda deactivate

Retrieving notices: ...working... done

3.安装pytorch

进入环境:

1
2
(base) root@3090_0002:/data10/cyb/Vision-Transformer# conda activate ab
(ab) root@3090_0002:/data10/cyb/Vision-Transformer#

根据cuda版本安装pytorch,这里应该为11.4:


安装命令:

1
conda install pytorch torchvision torchaudio pytorch-cuda=11.4 -c pytorch -c nvidia


出现了报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ab) root@3090_0002:/data10/cyb/Vision-Transformer# conda install pytorch torchvision torchaudio pytorch-cuda=11.4 -c pytorch -c nvidia
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

- pytorch-cuda=11.4

Current channels:

- https://conda.anaconda.org/pytorch/linux-64
- https://conda.anaconda.org/pytorch/noarch
- https://conda.anaconda.org/nvidia/linux-64
- https://conda.anaconda.org/nvidia/noarch
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

这个报错信息表明你尝试在Conda环境中安装PyTorch、TorchVision、TorchAudio以及特定版本的PyTorch CUDA(11.4),但是在当前设置的渠道(channels)中未能找到名为pytorch-cuda=11.4的包。


所以还是安装和我的版本最接近的指令吧T.T:

1
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia


4.验证是否安装成功

1
2
3
4
5
6
7
8
9
10
11
(ab) root@3090_0002:/data10/cyb/Vision-Transformer# python
Python 3.9.18 (main, Sep 11 2023, 13:41:44)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torchvision
>>> torch.cuda.is_available()
True
>>> print(torch.__version__)
2.1.1
>>> exit()