首先去pytorch官网查看自己所需要下载cuda、cudnn的版本
这里我给出相应版本百度云的链接,方便大家食用
链接:https://pan.baidu.com/s/1ZEFoYo8evR_7eySvvSUwTA
提取码:q6qy
链接:https://pan.baidu.com/s/15BqEltYMd50mjXhEZQ4pQA
提取码:jlwo
链接:https://pan.baidu.com/s/1mGnATEDl0DJ06L7gErZ5SA
提取码:0yni
【安装前提:具备Visual Studio的环境,不然按照精简模式安装会安装失败】
在Anaconda Prompt 终端输入:conda create -n pytorch
在Anaconda Prompt 终端输入:conda activate pytorch
在Anaconda Prompt 终端输入从pytorch官网获得的安装指令:
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
==============================================
**(网不稳定的小伙伴可以通过添加镜像源哦,参见步骤五)**
==============================================
在Anaconda Prompt 终端依次输入:
activate pytorch
conda install nb_conda_kernels
conda install ipykernel
conda install -n pytorch ipykernel
activate pytorch
python -m ipykernel install --user --name pytorch --display-name "pytorch"
删除指定kernel:jupyter kernelspec remove pytorch
查看所有kernel:jupyter kernelspec list
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
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/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
删除镜像:conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --show
conda install pytorch torchvision cudatoolkit=10.2
=======================================
至此,大功告成!!!
=======================================
在这里向大家推荐两篇不错的文章,比我写的更加清楚
windows10安装pytorch,感觉自己基本踩了所有坑,这里提供最有效的两种方法
Import Error:Jupyter Notebook 中无法运行虚拟环境(pytorch、tensorflow)