anaconda cuda-cudnn pytorch gpu版本 cpu版本 安装

design by ht

1 anaconda

下载:

https://www.anaconda.com/distribution/#download-section
在这里插入图片描述
下载慢的点链接
链接:https://pan.baidu.com/s/1xlJqCf3NMn108nMSrv8RLg
提取码:onh6
复制这段内容后打开百度网盘手机App,操作更方便哦–来自百度网盘超级会员V3的分享

双击安装

选择 All users
在这里插入图片描述

勾选 Add Anaconda3 to the system PATH environment variable
在这里插入图片描述

测试是否anaconda是否安装成功

win+ R

cmd

conda

如图所示conda安装成功
在这里插入图片描述

然后添加镜像源,以便在安装包时下载速度更快

​ 复制下面代码输入

######中科大 #设置搜素时显示通道地址

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 --akld 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

######清华

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show channel_urls yes

######pip 清华

pip config set global.index-url https://mirrors.alyun.com/pypi/simple

阿里云 http://mirrors.aliyun.com/pypi/simple

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple

豆瓣(douban) http://pypi.douban.com/simple

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple

conda 创建虚拟环境

虚拟环境1 python=3.6 pytorch =1.5.0 (GPU)
conda create -n pytorch_1.5_gpu python=3.6

y

​ 若中科大镜像原安装失败,则换清华镜像源重置
​ 先移除中科大

​conda config --remove-key channels
conda config --show

​ 在channels 中有镜像源

​ 复制清华镜像源

​ 进入虚拟环境

​conda activate pytorch_1.5_gpu
虚拟环境2 python=3.7 pytorch=1.4.0 (CPU)
conda create -n pytorch_1.4_cpu python=3.7
y

​ 进入虚拟环境2

​conda activate pytorch_1.4_cpu

退出环境

conda deactivate

在这里插入图片描述

2.pycharm

下载:

https://www.jetbrains.com/pycharm/

激活:

https://shimo.im/docs/GJTqgHqh6kGYkKKY/read

pycharm win :
链接:https://pan.baidu.com/s/1iK3p1OWIswVcy2jx-7v2RA
提取码:tur2
复制这段内容后打开百度网盘手机App,操作更方便哦–来自百度网盘超级会员V3的分享

3.CUDA安装

下载:

https://developer.nvidia.com/cuda-toolkit-archive
在这里插入图片描述
在这里插入图片描述

cuda-cudnn10.2:
链接:https://pan.baidu.com/s/1GmIy2wWpVktDPZuWtUVLKw
提取码:cna8
复制这段内容后打开百度网盘手机App,操作更方便哦–来自百度网盘超级会员V3的分享

安装步骤:
1.检查pytorch版本所支持的cuda版本,下载对应版本的CUDA
2.下载CUDA安装包,下载对应CUDA版本的cudnn安装包
3.安装并验证安装成功

​ 查看cuda 版本

cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin

nvcc -V

在这里插入图片描述

4.cudnn

下载:https://developer.nvidia.com/cudnn

cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\extras\demo_suite

​bandwidthTest.exe

在这里插入图片描述

​deviceQuery.exe

结果显示 Result = PASS 即可
在这里插入图片描述

5.pytorch

命名解释:

​ cu92/torch-1.2.0%2Bcu92-cp37-cp37m-win_amd64.whl
cuda版本或cup pytorch版本号 python版本号 操作系统

5.1 配置虚拟环境1

虚拟环境1 python=3.6 pytorch =1.5.0 (GPU)

https://download.pytorch.org/whl/torch_stable.html

Ctrl +F 搜索 cu102/torch-1.5.0-cp36 下载

​ cu102/torchvision-0.6.0-cp36 下载

两个文件下载在文件夹 C:\Users\ht\Desktop\pytorch

进入pycharm Terminal

C:

cd C:\Users\ht\Desktop\pytorch

dir

pip install torch-1.5.0-cp36-cp36m-win_amd64.whl

结果显示

Successfully installed future-0.18.2 numpy-1.19.0 torch-1.5.0

pip install torchvision-0.6.0-cp36-cp36m-win_amd64.whl

结果显示:

Successfully installed pillow-7.2.0 torchvision-0.6.0

如果下载速度过慢,添加镜像源

阿里云 http://mirrors.aliyun.com/pypi/simple

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple

豆瓣(douban) http://pypi.douban.com/simple

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple

中国科学技术大学 [http://pypi.mirrors.ustc.edu.cn/simple

pip config set global.index-url https://mirrors.alyun.com/pypi/simple 
5.2 配置虚拟环境2

虚拟环境2 python=3.7 pytorch=1.4.0 (CPU)

https://download.pytorch.org/whl/torch_stable.html

Ctrl +F 搜索 cpu/torch-1.4.0%2Bcpu-cp37 下载

​ cpu/torchvision-0.5.0%2Bcpu-cp37 下载

l两个文件下载在文件夹 C:\Users\ht\Desktop\pytorch

进入pycharm Terminal

​deactivate

查看所有虚拟环境

​conda info --envs

conda activate pytorch_1.4_cpu

pip install "torch-1.4.0+cpu-cp37-cp37m-win_amd64.whl"

结果显示:

Successfully installed torch-1.4.0+cpu

​pip install "torchvision-0.5.0+cpu-cp37-cp37m-win_amd64.whl"

结果显示

Successfully installed numpy-1.19.0 pillow-7.2.0 six-1.15.0 torchvision-0.5.0+cpu

结果显示:

Successfully installed torch-1.4.0+cpu

pip install "torchvision-0.5.0+cpu-cp37-cp37m-win_amd64.whl"

结果显示

Successfully installed numpy-1.19.0 pillow-7.2.0 six-1.15.0 torchvision-0.5.0+cpu

出入测试代码:

import torch

print("Hello world, Hello Pytorch {}".format(torch.__version__))

print("\nCuda is available: {}, version {}".format(torch.cuda.is_available(), torch.version.cuda))

print("\ndevice_name:{}".format(torch.cuda.get_device_name(0)))

结果如下
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值