一、下載anaconda3
https://www.anaconda.com/products/individual#Downloads
或復(fù)制以下鏈接到迅雷直接下載:https://repo.anaconda.com/archive/Anaconda3-2020.11-Windows-x86_64.exe
一直“next”播聪,選擇“All User”,“Path”配置環(huán)境變量都勾上朽基,直到“Finsh”
二、根據(jù)tensorflow官網(wǎng)指示的版本离陶,確定python\cuda\cudnn的版本
官網(wǎng):https://www.tensorflow.org/install/source_windows【需要連外網(wǎng)vpn才能訪問】
沒有vpn可看下圖:
確定接下來裝tf1環(huán)境:python3.6.9+CUDA10.0+cudnn7.4+tensorflow-gpu1.14.0+tensorflow1.14.0
確定接下來裝tf2環(huán)境:python3.6.9+CUDA10.1+cudnn7.6+tensorflow-gpu2.3.0+tensorflow2.3.0
三稼虎、配置conda、pip鏡像源
為了接下來conda install 和pip install 速度更快招刨,我們要配置conda霎俩、pip鏡像源
conda:
Windows 用戶無法直接創(chuàng)建名為.condarc的文件,可先執(zhí)行conda config --set show_channel_urls yes生成該文件沉眶。生成的文件在C:\Users\bifthan\.condarc
若要對其進行修改打却,可以編輯用戶目錄下的.condarc文件,其路徑為C:\Users\bifthan\.condarc
這里推薦使用清華鏡像源谎倔,若要使用其他源可以善用搜索
將下列配置覆蓋到該文件中柳击,即可使用清華鏡像源進行快速下載
···
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
···
conda config --show channels可以查看全部源
pip:在C:\Users\bifthan\pip? 下面新建pip.ini文件,把下面復(fù)制到文件中片习,保存
···
[global]
trusted-host=pypi.doubanio.com? ? ? ? ? ??
index-url=https://pypi.doubanio.com/simple/
···
下面這3個pip源速度都不錯捌肴,可以任選
···
https://pypi.doubanio.com/ 豆瓣
http://mirrors.aliyun.com/pypi/ 阿里
http://pypi.mirrors.ustc.edu.cn/ 中國科學(xué)技術(shù)大學(xué)
···
四蹬叭、創(chuàng)建一個名為“tf1keras”的虛擬環(huán)境
conda remove -n tf1keras--all
conda create -n tf1keraspython=3.6.9# 創(chuàng)建一個python3的環(huán)境,名為tf1keras
conda activate tf1keras# 激活tf1keras環(huán)境
conda install jupyter notebook# 安裝ipykernel模塊
python -m ipykernel install --user --name tf1keras --display-name "tf1keras" # 進行配置
jupyter kernelspec list#查看jupyter notebook里的kernel
若想刪除 jupyter kernelspec remove music#刪除名叫icsharpkernel的kernel
五状知、創(chuàng)建一個名為“tf2keras”的虛擬環(huán)境
conda remove -n?tf2keras --all
conda create -n tf2keras python=3.6.9# 創(chuàng)建一個python3的環(huán)境秽五,名為tf2keras
conda activate tf2keras # 激活tf2keras環(huán)境
conda install jupyter notebook# 安裝ipykernel模塊
python -m ipykernel install --user --name tf2keras --display-name "tf2keras" # 進行配置
jupyter kernelspec list#查看jupyter notebook里的kernel
若想刪除 jupyter kernelspec remove music#刪除名叫icsharpkernel的kernel
六、安裝CUDA10.1+cudnn7.6
安裝cuda10.1:
官網(wǎng):https://developer.nvidia.com/cuda-toolkit-archive
https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.168_425.25_win10.exe
復(fù)制鏈接到迅雷下載
一直下一步饥悴,直到結(jié)束坦喘。
配置系統(tǒng)變量-電腦-屬性-下面框里----Path--C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
再檢查下面的框里是否有
CUDA_PATH? ? ? ? ? ? ? ? ?? C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
CUDA_PATH_V10_1? ?? C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
nvcc -V驗證一下是否已經(jīng)裝好。
安裝cudnn7.6
cudnn:https://developer.nvidia.com/rdp/cudnn-download
login:需要注冊賬號密碼登錄
或者復(fù)制https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.1_20191031/cudnn-10.1-windows10-x64-v7.6.5.32.zip迅雷下載
解壓縮之后西设,把cudnn下面的三個文件夾中的文件
一一對應(yīng)復(fù)制到CUDA 的路徑下
然后再系統(tǒng)環(huán)境變量的Path中起宽,加以下路徑
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64
七、安裝CUDA10.0+cudnn7.4
同上
CUDA10.0:https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_411.31_win10
復(fù)制到迅雷下載
cudnn7.4:https://developer.nvidia.com/rdp/cudnn-download
八济榨、安裝tensorflow1.14到“tf1keras”環(huán)境里
pip install tensorflow==1.14.0
如果上述方法裝不上
還有一種方法:把tensorflow1.14.0下載到本地,
https://pypi.org/project/tensorflow/1.14.0/#files
選擇py36-windows版本
然后在路徑下進入虛擬環(huán)境tf2keras绿映,再打開cmd擒滑,輸入pip install 文件名
安裝成功。
九叉弦、安裝tensorflow2.3到“tf2keras”環(huán)境里
pip install tensorflow==2.3.0
如果上述方法裝不上
還有一種方法:把tensorflow2.3.0下載到本地丐一,
https://pypi.org/project/tensorflow/2.3.0/#files
選擇py36-windows版本然后在路徑下進入虛擬環(huán)境tf2keras,再打開cmd淹冰,輸入pip install 文件名库车,安裝成功。
十樱拴、驗證tf2環(huán)境下的gpu是否能用
進到tf2keras環(huán)境--
>python
>import tensorflow as tf
>tf.test.is_gpu_available()
沒有報錯柠衍,就代表全部都配置好了。
十一晶乔、切換tf1和tf2環(huán)境
要更改系統(tǒng)環(huán)境變量珍坊,CUDA_PATH的v10.0/v10.1即可