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
接下來(lái)可以下載cudn和cundnn:
官網(wǎng):https://developer.nvidia.com/cuda-toolkit-archive
下載對(duì)應(yīng)版本exe文件打開(kāi)默認(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è)置,如果沒(méi)有的補(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)程序來(lái)驗(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編號(hào)為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í)的資料請(qǐng)關(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全過(guò)程分析(顯卡MX250+CUDA9.0+cudnn)
相關(guān)文章
Git第一次初始化項(xiàng)目到遠(yuǎn)程倉(cāng)庫(kù)方式
本文介紹了Git倉(cāng)庫(kù)的初始化和遠(yuǎn)程連接的基本步驟,首先,使用git init命令初始化本地倉(cāng)庫(kù),創(chuàng)建“.git”文件夾,然后,通過(guò)git remote add命令添加遠(yuǎn)程倉(cāng)庫(kù)地址,遇到Permission denied(publickey)錯(cuò)誤時(shí),需生成SSH key并添加至遠(yuǎn)程倉(cāng)庫(kù)2024-09-09
IIS 301重定向與程序代碼實(shí)現(xiàn)301重定向的差別
過(guò)IIS做301重定向確可以實(shí)現(xiàn)傳遞網(wǎng)站的權(quán)重,還不會(huì)導(dǎo)致流量丟失。2010-11-11
加速?PyTorch?模型訓(xùn)練的?9?個(gè)技巧(收藏)
本指南從最簡(jiǎn)單的結(jié)構(gòu)到最復(fù)雜的改動(dòng)都有,可以使你的網(wǎng)絡(luò)得到最大的好處。我會(huì)給你展示示例Pytorch代碼以及可以在Pytorch-?lightning?Trainer中使用的相關(guān)flags,這樣你可以不用自己編寫(xiě)這些代碼,感興趣的朋友一起看看吧2022-03-03
vscode配置遠(yuǎn)程開(kāi)發(fā)與免密登錄的技巧
這篇文章主要介紹了vscode配置遠(yuǎn)程開(kāi)發(fā)與免密登錄的技巧,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-04-04
關(guān)于提交項(xiàng)目到gitee報(bào)錯(cuò)Push to origin/master was rejected的問(wèn)題
這篇文章主要介紹了提交項(xiàng)目到gitee報(bào)錯(cuò)Push to origin/master was rejected的解決辦法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10
編寫(xiě)高質(zhì)量代碼的30條黃金守則(首選隱式類(lèi)型轉(zhuǎn)換)
這篇文章主要介紹了編寫(xiě)高質(zhì)量代碼的30條黃金守則(首選隱式類(lèi)型轉(zhuǎn)換),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-08-08
git如何合并某個(gè)分支的某次提交(cherry-pick)
這篇文章主要介紹了git如何合并某個(gè)分支的某次提交(cherry-pick)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-05-05
Elasticsearch?在地理信息空間索引的探索和演進(jìn)問(wèn)題分析
本文梳理了Elasticsearch對(duì)于數(shù)值索引實(shí)現(xiàn)方案的升級(jí)和優(yōu)化思考,從2015年至今數(shù)值索引的方案經(jīng)歷了多個(gè)版本的迭代,實(shí)現(xiàn)思路從最初的字符串模擬到KD-Tree,技術(shù)越來(lái)越復(fù)雜,能力越來(lái)越強(qiáng)大,應(yīng)用場(chǎng)景也越來(lái)越豐富,感興趣的朋友跟隨小編一起看看吧2022-06-06

