安装anaonda
清华镜像:(https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/安装的是这个版本Anaconda3-2019.10-Windows-x86_64.exe
选just me
自定义安装位置
只选第2个√
一直next,直到finish
然后配置环境变量,在path中添加三个
就ok了!!!!!
创建虚拟环境
conda create -n py37 pyhthon=3.7
py37是创建的虚拟环境名
在创建虚拟环境时,安装某个模块的速度太慢了,出现了错误HTTPError: HTTP 000 CONNECTION FAILED for url
可参考添加链接描述
将https改为http,但还是出错!!可能是改了.condarc文件内容,弄坏了
哭了,又出现了PackagesNotFoundError: The following packages are not available from current channels:错误
添加了清华镜像通道,还是错
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
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/pkgs/free/
conda config --set show_channel_urls yes
然后采用了评论中的方法
创建虚拟环境成功,喜大普奔!!!!
#激活虚拟环境
成功了
一般来说 conda 仓库的软件没有 PyPI 更新快和全。所以推荐 conda 只用来创建虚拟环境,包的安装管理仍然使用 pip。
安装CUDA
右键NVIDIA控制面板,看看你的电脑支持什么版本,我是CUDA9.0
官网下载添加链接描述
cudnn安装
去官网,需要注册账号添加链接描述
下载与CUDA对应的版本
下载pytorch
先添加中国科技大学镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
将.condarch中的-default去掉
去pytorch官网下载对应版本的pytorchhttps://pytorch.org/get-started/locally/
我的是,要把最后的-c pytorch去掉,不去掉他会用anaconda的镜像下载,很慢!!!!!
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0
ok,pytorch下载完成
谁能想到在import torchvision 时又出错了!
查了一下说是pillowde版本太高,所以卸载pillow,再安装
pip uninstall Pillow
pip install Pillow==6.2.2
不知道为什么,在卸载pillow时把我的torchvision也给卸载了
然后我又得安上
pip install torchvision==0.3.0
然后验证一下
大功告成