1、Anaconda安装
1.1
使用清华镜像进行安装https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
例如:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
1.2
bash Anaconda3-2023.03-1-Linux-x86_64.sh
安装过程中,点击回车和输入yes。
1.3
source ~/.bashrc
2、创建虚拟环境
2.1创建环境
conda create -n pytorch python=3.6
根据需要的python选择版本,版本不是越高越好,选择合适的。
2.2 激活环境
conda activate pytorch
3、安装Pytorch
3.1 更换conda的清华镜像源
使用下面命令查看 .condarc 中的源
conda config --show channels
Linux下将以上配置文件写在 ~/.condarc 中
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
切记删除- defaults,否则可能报错。
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true
3. 更换python的清华镜像源
接着是Python换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
3.3 官网安装
进入官网https://pytorch.org
选择合适的系统版本、CUDA版本、python版本。
一般使用 pip3 进行安装。
选择 Previous versions of PyTorch进行查看之前版本进行安装。
CUDA版本向下兼容(11.8兼容11.7、11.6等)
3.4 软件包安装
使用conda进行安装:
例:
conda install numpy=1.16.0
4、安装tensorflow
4.1软件包安装
链接:参考博文