win10+RTX3050ti+TensorFlow+cudn+cudnn配置深度學(xué)習(xí)環(huán)境的方法
避坑1:RTX30系列顯卡不支持cuda11.0以下版本,具體上限版本可自行查閱:
方法一,在cmd中輸入nvidia-smi查看
方法二:
由此可以看出本電腦最高適配cuda11.2.1版本;
注意需要版本適配,這里我們選擇TensorFlow-gpu = 2.5,cuda=11.2.1,cudnn=8.1,python3.7
接下來可以下載cudn和cundnn:
官網(wǎng):https://developer.nvidia.com/cuda-toolkit-archive
下載對應(yīng)版本exe文件打開默認(rèn)安裝就可;
驗(yàn)證是否安裝成功:
官網(wǎng):cuDNN Archive | NVIDIA Developer
把下載文件進(jìn)行解壓把bin+lib+include文件復(fù)制到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2文件下;
進(jìn)入環(huán)境變量設(shè)置(cuda會(huì)自動(dòng)設(shè)置,如果沒有的補(bǔ)全):
查看是否安裝成功:
cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\extras\demo_suite bandwidthTest.exe
安裝tensorflow-gpu:
pip install tensorflow-gpu==2.5
最后我們找相關(guān)程序來驗(yàn)證一下:
第一步:
import tensorflow as tf print(tf.__version__) print('GPU', tf.test.is_gpu_available())
第二步:
# _*_ coding=utf-8 _*_ ''' @author: crazy jums @time: 2021-01-24 20:55 @desc: 添加描述 ''' # 指定GPU訓(xùn)練 import os os.environ["CUDA_VISIBLE_DEVICES"]="0" ##表示使用GPU編號為0的GPU進(jìn)行計(jì)算 import numpy as np from tensorflow.keras.models import Sequential # 采用貫序模型 from tensorflow.keras.layers import Dense, Dropout, Conv2D, MaxPool2D, Flatten from tensorflow.keras.datasets import mnist from tensorflow.keras.utils import to_categorical from tensorflow.keras.callbacks import TensorBoard import time def create_model(): model = Sequential() model.add(Conv2D(32, (5, 5), activation='relu', input_shape=[28, 28, 1])) # 第一卷積層 model.add(Conv2D(64, (5, 5), activation='relu')) # 第二卷積層 model.add(MaxPool2D(pool_size=(2, 2))) # 池化層 model.add(Flatten()) # 平鋪層 model.add(Dropout(0.5)) model.add(Dense(128, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(10, activation='softmax')) return model def compile_model(model): model.compile(loss='categorical_crossentropy', optimizer="adam", metrics=['acc']) return model def train_model(model, x_train, y_train, batch_size=32, epochs=10): tbCallBack = TensorBoard(log_dir="model", histogram_freq=1, write_grads=True) history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, shuffle=True, verbose=2, validation_split=0.2, callbacks=[tbCallBack]) return history, model if __name__ == "__main__": import tensorflow as tf print(tf.__version__) from tensorflow.python.client import device_lib print(device_lib.list_local_devices()) (x_train, y_train), (x_test, y_test) = mnist.load_data() # mnist的數(shù)據(jù)我自己已經(jīng)下載好了的 print(np.shape(x_train), np.shape(y_train), np.shape(x_test), np.shape(y_test)) x_train = np.expand_dims(x_train, axis=3) x_test = np.expand_dims(x_test, axis=3) y_train = to_categorical(y_train, num_classes=10) y_test = to_categorical(y_test, num_classes=10) print(np.shape(x_train), np.shape(y_train), np.shape(x_test), np.shape(y_test)) model = create_model() model = compile_model(model) print("start training") ts = time.time() history, model = train_model(model, x_train, y_train, epochs=2) print("start training", time.time() - ts)
驗(yàn)證成功。
以上就是win10+RTX3050ti+TensorFlow+cudn+cudnn配置深度學(xué)習(xí)環(huán)境的詳細(xì)內(nèi)容,更多關(guān)于win10+RTX3050ti+TensorFlow+cudn+cudnn深度學(xué)習(xí)的資料請關(guān)注腳本之家其它相關(guān)文章!
- Win10 GPU運(yùn)算環(huán)境搭建(CUDA10.0+Cudnn 7.6.5+pytroch1.2+tensorflow1.14.0)
- Win10下安裝CUDA11.0+CUDNN8.0+tensorflow-gpu2.4.1+pytorch1.7.0+paddlepaddle-gpu2.0.0
- TensorFlow的環(huán)境配置與安裝教程詳解(win10+GeForce GTX1060+CUDA 9.0+cuDNN7.3+tensorflow-gpu 1.12.0+python3.5.5)
- Win10下安裝并使用tensorflow-gpu1.8.0+python3.6全過程分析(顯卡MX250+CUDA9.0+cudnn)
相關(guān)文章
ASP,PHP與.NET偽造HTTP-REFERER方法及防止偽造REFERER方法探討
ASP,PHP與.NET偽造HTTP-REFERER方法及防止偽造REFERER方法探討...2007-03-0330個(gè)提高Web程序執(zhí)行效率的好經(jīng)驗(yàn)分享
30個(gè)提高Web程序執(zhí)行效率的好經(jīng)驗(yàn)分享,需要的朋友可以參考下。2011-10-10算法系列15天速成——第十五天 圖【下】(大結(jié)局)
今天是大結(jié)局,說下“圖”的最后一點(diǎn)東西,“最小生成樹“和”最短路徑“2013-11-11提高github下載速度的方法可達(dá)到2MB/s(100%有效)
這篇文章主要介紹了提高github下載速度的方法可達(dá)到2MB/s(100%有效),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08解決使用commit提交大文件無法推送到遠(yuǎn)程庫問題及git rebase使用詳解
這篇文章主要介紹了解決使用commit提交大文件無法推送到遠(yuǎn)程庫問題及git rebase使用詳解,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07VS2019創(chuàng)建MFC程序的實(shí)現(xiàn)方法
這篇文章主要介紹了VS2019創(chuàng)建MFC程序的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08