深度学习相关环境的配置

 

一、安装PyCharm

1.1 下载

https://www.jetbrains.com/zh-cn/pycharm/

1.2 安装

1.3 激活

二、安装Anaconda

2.1 下载

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2.2 安装

2.3 创建

windows:
conda create --name pytorch python=3.8
activate pytorch
python --version
deactivate pytorch
linux:
conda create --name pytorch python=3.8
source activate pytorch
python --version
source deactivate pytorch

2.4 Conda常用命令

# 安装scipy
conda install scipy
# conda会从从远程搜索scipy的相关信息和依赖项目,对于python 3.8,conda会同时安装numpy和mkl(运算加速的库)
# 查看已经安装的packages
conda list
# 最新版的conda是从site-packages文件夹中搜索已经安装的包,不依赖于pip,因此可以显示出通过各种方式安装的包
# 查看当前环境下已安装的包
conda list
conda -V
conda env list
#创建
conda create -n env_name python=x.x
# 删除
conda remove -n env_name --all
# 查看某个指定环境的已安装包
conda list -n pytorch
conda create --name pytorch python=3.8
# 查找package信息
conda search numpy
# 安装package
conda install -n pytorch numpy
# 如果不用-n指定环境名称,则被安装在当前活跃环境
# 也可以通过-c指定通过某个channel安装
# 更新package
conda update -n pytorch numpy
# 删除package
conda remove -n pytorch numpy
# 更新conda,保持conda最新
conda update conda
# 更新anaconda
conda update anaconda
# 更新python
conda update python
# 假设当前环境是python 3.4, conda会将python升级为3.4.x系列的当前最新版本
注意:在以上的使用过程中你会发现使用conda下载包的速度非常的慢,因为使用的是国外的服务器,所以这里要设置为国内的镜像。使用下面的配置命令即可:
windows下
在清华源和中科大源之间自行选择
1 添加清华源
命令行中直接使用以下命令
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
2 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
Linux下
将以上配置文件写在~/.condarc中
vim ~/.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
# 添加Anaconda的TUNA镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# TUNA的help中镜像地址加有引号,需要去掉
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

三、安装Pytorch

https://pytorch.org/

四、测试Demo

原文地址:https://www.cnblogs.com/shareformlwh/p/15157121.html