文章目錄
-
- 換源
- 建立環境,使用3.7版本python,然後啟動環境
- 進入pytorch官網,查找相應版本下載下傳指令
- 更新下cuda
- 下面就可以安裝pytorch了
- 新錯誤
破環境裝一下午(我好菜)
anaconda prompt進入base環境
換源
方法一: 更改檔案内容
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
将上面内容複制到“C:\使用者\你的使用者名.condarc”(windows)或者"/home/你的使用者名/.condarc"(linux),即可切換為清華源
方法二: 輸入下列四條指令更換清華源
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
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
建立環境,使用3.7版本python,然後啟動環境
conda create -n pytorch python=3.7
conda activate pytorch
進入pytorch官網,查找相應版本下載下傳指令
網址:https://pytorch.org/get-started/locally/ 我的版本對應下載下傳指令為: conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
關于cuda版本,輸入nvcc --version檢視
實在是太老了…
更新下cuda
先解除安裝老版本的 解除安裝完就隻剩這三 破mx150居然支援cuda11… 直接下載下傳本地安裝包 下載下傳相應版本cudnn
無腦安裝cuda時遇到問題vs要記得關掉
安裝好後環境變量已經自動配置好
下面安裝cudnn
将下載下傳的cudnn檔案解壓,看到裡面有三個檔案夾,複制檔案夾裡的檔案到cuda的安裝目錄下對應檔案夾中即可
檢查cuda與cudnn安裝
管理者身份運作cmd,進入目錄
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\demo_suite
運作:
deviceQuery.exe
顯示pass
運作:
bandwidthTest.exe
顯示pass
nvcc --version
檢視版本
安裝成功
下面就可以安裝pytorch了
anaconda prompt裡運作pytorch官網提供的指令:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
!!!在base環境可以直接安裝,但是在我建立的環境pytorch裡安裝報錯:
pytorch LoadLibrary() argument 1 must be str, not None
出現問題,估計是太久沒更新,解除安裝原有anaconda後重新安裝,成功
(我有罪,我上一個項目是2019年…)
等待安裝完成
新錯誤
網上查了下,應該是網絡不穩定下載下傳逾時導緻
詳見:
https://www.cnblogs.com/xyzluck/p/12810835.html
沒急着重開,先前老提示conda更新,跑去base環境更新了下conda,實測pytorch環境無法更新
重試安裝pytorch 安裝成功,完結撒花
conda update conda