1、查看本機的CUDA驅動適配版本
桌面右鍵打開英偉達控制面板,點擊系統信息->組件
所以就必須安裝 10.2 及以下的版本。
2、下載CUDA 10.1和cuDNN
cuDNN下載頁面:https://developer.nvidia.com/rdp/cudnn-download
下載cuDNN是需要登錄英偉達開發者賬戶的,注冊一個並填寫問卷就行了,很簡單。
注意:必須選擇和你安裝的CUDA匹配的版本
選擇自定義安裝 只要第一個組件即可
把cuDNN中文件夾中文件復制到對應的cuda安裝目錄下
3、安裝Pytorch
https://pytorch.org/get-started/locally/
先更換源
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 --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/cloud/pytorch/ conda config --set show_channel_urls yes
conda env list conda info --envs #列出所有環境 conda activate ee #激活環境 conda deactivate #退出環境 conda env remove -n py3 #刪除環境 conda create -n pytorch python=3.6 #創建環境 conda activate pytorch #安裝 cpu 版本的 PyTorch conda install -c pytorch pytorch-nightly-cpu #安裝fastai conda install -c fastai fastai #更新conda 也可以不更新 conda update conda
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch #安裝gpu pytorch
# 1.conda新建環境 # 2.切換到新建環境中 # 3.安裝ipykernel 與 jupyter conda install ipykernel pip install jupyter # 在新建環境新建kernel(kernel名可與環境名一致) python -m ipykernel install --user --name <環境名> --display-name <在jupyter中顯示的kernel名稱> python -m ipykernel install --user --name pytorch --display-name Pytorch jupyter kernelspec list # 查看jupyter的kernel列表 jupyter kernelspec remove <kernel_name> # 刪除指定kernel
在命令行輸入jupyter notebook
切換至pytorch Kernel即可