日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

在windows中对torch1.7.1版本环境配置

發(fā)布時(shí)間:2025/5/22 windows 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在windows中对torch1.7.1版本环境配置 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在windows中對(duì)torch1.7.1版本環(huán)境配置

    • 復(fù)雜的安裝方式:(不推薦)
        • 環(huán)境內(nèi)容
        • 下載 Cudnn 和 CUDA (可選)
    • 簡(jiǎn)單粗暴安裝方式:(強(qiáng)烈推薦)

復(fù)雜的安裝方式:(不推薦)

環(huán)境內(nèi)容

torch:1.7.1

安裝Python版本要求

Python 3.53.7

下載 ANACONDA 對(duì) Python版本和第三方庫(kù)進(jìn)行管理

官方推薦下載:https://pytorch.org/

conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c nvidia

下載 Cudnn 和 CUDA (可選)

可在命令行匯總執(zhí)行查看驅(qū)動(dòng)版本:

nvidia-smi

或者通過(guò)NVIDIA控制面板在菜單欄 幫助 中選擇 系統(tǒng)信息

然后再選擇組件

根據(jù)本地的NVIDIA CUDA 版本去找到官方對(duì)應(yīng)的CUDA版本

CUDA Toolkit 11.0 Download:
https://developer.nvidia.com/cuda-11.0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal

下載成功后進(jìn)行安裝




安裝完成之后,還需要下載cuDNN,這里需要登錄并填寫(xiě)問(wèn)卷才能下載
cuDNN:https://developer.nvidia.com/rdp/cudnn-download


下載后進(jìn)行解壓


把 cuda 壓縮包解壓出來(lái)的文件復(fù)制到盤(pán)符:…\NVIDIA GPU Computing Toolkit\CUDA\v11.0中

接下來(lái)設(shè)置環(huán)境變量:
計(jì)算機(jī)上點(diǎn)右鍵,打開(kāi)屬性->高級(jí)系統(tǒng)設(shè)置->環(huán)境變量
可以看到系統(tǒng)中多了CUDA_PATH和CUDA_PATH_V11_0兩個(gè)環(huán)境變量
如下圖所示:

接下來(lái),還要在系統(tǒng)中添加以下幾個(gè)環(huán)境變量:

CUDA_SDK_PATH = C:\ProgramData\NVIDIA Corporation\CUDA Samples\v11.0(這是我默認(rèn)安裝位置的路徑) CUDA_LIB_PATH = %CUDA_PATH%\lib\x64 CUDA_BIN_PATH = %CUDA_PATH%\bin CUDA_SDK_BIN_PATH = %CUDA_SDK_PATH%\bin\win64 CUDA_SDK_LIB_PATH = %CUDA_SDK_PATH%\common\lib\x64

如下圖所示:

在系統(tǒng)變量 PATH 的末尾添加:

%CUDA_LIB_PATH%; %CUDA_BIN_PATH%; %CUDA_SDK_LIB_PATH%; %CUDA_SDK_BIN_PATH%;

再添加如下4條(默認(rèn)安裝路徑):

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin; C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\lib

如果你選用了自定義路徑,上述這些默認(rèn)路徑都應(yīng)該相應(yīng)替換為你的自定義路徑,以上為我的環(huán)境變量和PATH的配置情況:

環(huán)境變量:
配置完成后,我們可以驗(yàn)證是否配置成功,主要使用CUDA內(nèi)置的deviceQuery.exe 和 bandwithTest.exe:

首先win+R啟動(dòng)cmd,cd到安裝目錄下的 …\NVIDIA GPU Computing Toolkit\CUDA\v11.0\extras\demo_suite
然后分別執(zhí)行bandwidthTest.exe和deviceQuery.exe應(yīng)該得到下圖:


如果以上兩步都返回了Result=PASS,那么就算成功了。

在ANACONDA 中安裝 pytorch 選擇安裝1.7.1版本


清華conda源地址:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

添加清華源

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

建議同時(shí)添加第三方conda源:

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/msys2/ 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/menpo/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

在cmd中 輸入 python 進(jìn)入python 編譯環(huán)境后,輸入以下命令測(cè)試 pytorch GPU版本是否安裝成功

import torch print(torch.version.cuda) print(torch.cuda.is_available())


另一種安裝方式

簡(jiǎn)單粗暴安裝方式:(強(qiáng)烈推薦)

安裝虛擬環(huán)境

conda create -n pytorch python=3.6

切換到 剛創(chuàng)建的 pytorch中

conda activate pytorch

添加清華源

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

建議同時(shí)添加第三方conda源:

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/msys2/ 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/menpo/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

安裝 pytorch

conda install pytorch torchvision torchaudio cudatoolkit=11.1

通過(guò)以下指令,查看當(dāng)前python環(huán)境是否成功安裝了 torch 1.7.1

pip list


在cmd中 輸入 python 進(jìn)入python 編譯環(huán)境后,輸入以下命令測(cè)試 pytorch GPU版本是否安裝成功

import torch print(torch.version.cuda) print(torch.cuda.is_available())


幾步搞定,不需要去 安裝Cudnn 和 CUDA!!!!!!

總結(jié)

以上是生活随笔為你收集整理的在windows中对torch1.7.1版本环境配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。