anaconda安装pytorch, cuda版本10.2,cudnn版本10.2-windows10-x64-v8.0.3.33

1.先安装anaconda

官网:https://www.anaconda.com/products/individual
在这里插入图片描述
在这里插入图片描述
虽然写着python3.8,是向下兼容的,下载就行。
安装过程就略了。
安装完检查Anaconda的环境变量。没有把这俩添加进去。
在这里插入图片描述

2.cuda 10.2及cudnn的安装

2.1cuda 10.2下载及安装

在这里插入图片描述
按照官网给出的提示,安装稳定版Pytorch 1.60,需要cuda版本10.2 ,下载地址:https://developer.nvidia.com/cuda-toolkit-archive
在这里插入图片描述
在这里插入图片描述
大小为2.6G。请默认安装,大家安装位置都一致。

2.2 cudnn的安装

https://developer.nvidia.com/rdp/cudnn-download
在这里插入图片描述
需要注册账号,也不麻烦,就是填几个项。下载是个压缩包。

  • 把压缩包中bin,include,lib中的文件分别拷贝到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2目录下对应目录中
    在这里插入图片描述
  • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\extras\CUPTI\lib64\cupti64_102.dll
    拷贝到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin
  • 再配置下环境变量:
  • 在这里插入图片描述
    确保已经将上面4个path添加到系统变量中!

3安装Pytorch

3.1配置下Anaconda的下载源

这个源跟python的pip下载源一样的。配置文件位置: C:\Users\your_name下名为.condarc文件。在这里插入图片描述
在这里插入图片描述

一般就用清华的:这是我的。

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
show_channel_urls: true
auto_activate_base: false
channel_priority: flexible

3.2 创建名字为pytorch的虚拟环境

Anaconda Prompt 终端输入(不是windows的cmd): conda create -n pytorch python=3.6就创建了名字为 pytorch的虚拟环境,(这里-n相当于 --name),这里一般会下载python3.6和其他几个基础包。
在这里插入图片描述

3.3激活环境

conda activate pytorch
conda install pytorch torchvision cudatoolkit=10.2
这里注意不要官方命令原版的结尾的-c pytorch
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
这样就安装好了。

3.4 验证一下

在这里插入图片描述

4 jupyter 创建基于pytorch这个虚拟环境的文件

4.1

anaconda安装好默认环境叫base,现在创建了一个pytorch的环境,但是我们打开在这里插入图片描述
里只能基于base创建jupyter文件。我想在打开的jupyter (Anaconda)创建其他虚拟环境的:

  • 先在base默认环境中:
    输入conda install ipykernel安装ipykernel,或可以用conda list查看是否已经安装了。
  • 在虚拟环境下创建kernel文件:下面这个pytorch可以换成其他环境名。
    先激活该虚拟环境:
    conda activate pytorch
    然后:
    conda install -n pytorch ipykernel
  • 继续在该虚拟环境中,写入notebook的kernel中
    python -m ipykernel install --user --name 环境名称 --display-name "在jupyter中显示的环境名称"
    我的命令是:python -m ipykernel install --user --name pytorch --display-name "pytorch"
    在这里插入图片描述
    可以验证,打印版本:
    在这里插入图片描述

4.2修改anaconda jupyter默认路径

jupyter notebook --generate-config

在这里插入图片描述
打开该文件,找到notebook_dir
#c.NotebookApp.notebook_dir = ''改为:前面的注释#要去掉。
c.NotebookApp.notebook_dir = 'C:\\Users\\liufe\\Desktop\\Jupyter Projects'
在这里插入图片描述

第4节参考:https://www.cnblogs.com/hgl0417/p/8204221.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值