Windows系统安装Miniconda搭建深度学习环境

下载Miniconda

Miniconda的官网:https://docs.conda.io/en/latest/miniconda.html

官网下载速度慢,直接去清华镜像网站下载红框,框出来的版本:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/
在这里插入图片描述

安装Miniconda

下载完成,我们开始安装:
在这里插入图片描述
一路Next,
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

虚拟环境操作

添加国内源

快捷键:win + r,打开命令行,如图:
在这里插入图片描述
出现如下图:执行:conda config --set show_channel_urls yes
在这里插入图片描述
.condarc文件在C:\Users\Administrator目录下,如下图:
在这里插入图片描述
将下述内容替换到.condarc文件,.condarc文件用记事本打开

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

在这里插入图片描述

创建虚拟环境

指令:conda create -n tf2 python=3.6 -y
在这里插入图片描述

查看虚拟环境

指令:conda env list
在这里插入图片描述

激活虚拟环境

指令:conda activate tf2
在这里插入图片描述

安装函数库

指令:pip install numpy,安装numpy函数库
在这里插入图片描述
如果下载速度慢的话,可采用下面命令,指定阿里源进行下载

pip install numpy -i "https://mirrors.aliyun.com/pypi/simple"

退出虚拟环境

指令:conda deactivate
在这里插入图片描述

常用函数库

numpy==1.16.0
pandas
matplotlib
opencv-python
opencv-contrib-python
pillow
sklearn
scipy==1.4.1
jupyter
notebook
absl-py==0.7
tensorflow==2.3
tensorflow_datasets
-i "https://mirrors.aliyun.com/pypi/simple"

此常用函数库为tensorflow得CPU版本

同时安装多个函数库

创建一个txt文档,命名为:requirements.txt

安装方式,进入到保存requirements.txt文件的目录,我的requirements.txt放在了C:\software,如图所示:
在这里插入图片描述
在这里插入图片描述

打开命令行,用cd命令进入C:\software,再执行指令:pip install -r requirements.txt
在这里插入图片描述

Tensorflow-GPU的安装

首先查看自己电脑是否有NVIDIA显卡
在这里插入图片描述
在这里插入图片描述

NVIDIA显卡的话,就可以装tensorflow-gpu版本

安装步骤:

1.创建一个新的虚拟环境,例如:tf2.3-gpu
2.pip install tensorflow-gpu==2.3 -i "https://mirrors.aliyun.com/pypi/simple"
3.conda install cudatoolkit==10.1.243 cudnn

除tensorflow函数库的安装有区别,其他的与常用函数库安装一致

PyTorch的安装

指令:pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
在这里插入图片描述

网络好的情况,上述方式方便快速的完成安装。

网络不好的解决方法:下载whl文件安装,如下图所示

在这里插入图片描述

cp36/cp37 --> python3.6/python3.7,对应安装的python版本

下载地址:链接:https://pan.baidu.com/s/180ED9Tp7Hth-eoDxgycSdw
提取码:1lo3

下载好的文件,我保存到了C:\Download
在这里插入图片描述

进入终端执行以下指令:

cd whl文件保存目录
激活虚拟环境,已激活,忽略此步
pip install "torch-1.6.0+cpu-cp36-cp36m-win_amd64.whl"
pip install "torchvision-0.7.0+cpu-cp36-cp36m-win_amd64.whl"

在这里插入图片描述

其他指令

缺少函数库报错解决方式

在这里插入图片描述

删除虚拟环境

指令:conda remove -n tf2 --all -y
在这里插入图片描述

此操作不必实操,了解即可,一般不会删除虚拟环境

  • 11
    点赞
  • 72
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值