Tensorflow、CUDA、cuDNN 上的机器学习模型不起作用

问题描述 投票:0回答:1

我不确定我做错了什么。我正在尝试在 Conda 环境中的 Jupyter Notebooks 上运行 ResNet152。这是我的代码:

from tensorflow.keras.applications import ResNet50, ResNet101, ResNet152, InceptionResNetV2, DenseNet121
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Activation, BatchNormalization
from tensorflow.keras import mixed_precision, layers, models
import tensorflow as tf
from tensorflow.keras.optimizers.schedules import ExponentialDecay
from tensorflow.keras.optimizers import Adam, RMSprop

mixed_precision.set_global_policy('mixed_float16')

base_model = ResNet152(weights='imagenet', include_top=False, input_shape=(256, 256, 3))


for layer in base_model.layers:
    layer.trainable = True 

pooling_layer = layers.GlobalAveragePooling2D()(base_model.output)  # GlobalAveragePooling2D layer
output_layer = layers.Dense(1, activation='sigmoid', name='output_layer')(pooling_layer)

model = Model(inputs=base_model.input, outputs=output_layer)

initial_learning_rate = 0.001
lr_schedule = ExponentialDecay(
    initial_learning_rate,
    decay_steps=50,  # Adjust the decay steps as needed
    decay_rate=0.9,     # Adjust the decay rate as needed
    staircase=False)

optimizer = Adam(learning_rate=lr_schedule)

model.compile(
    optimizer=optimizer,
    loss='binary_crossentropy',
    metrics=['accuracy', tf.keras.metrics.Precision(), tf.keras.metrics.Recall(), tf.keras.metrics.AUC(name='auc')]
)

model.summary()

os.environ['CUDA_VISIBLE_DEVICES'] = '0'
history = model.fit(dataset_batched_withoutnames, epochs=5)

我收到以下错误:

未找到 DNN 库。 [[{{节点模型/conv1_conv/Conv2D}}]] [操作:__inference_train_function_55822] (有一个很长的框但没有全部复制粘贴)

我回去降级了我的 Tensorflow、CUDA 和 cuDNN。我使用的是 CUDA 11.2、cuDNN 8.1.0 和 Tensorflow 2.10.0

我回到我的路径并将其全部清理干净,并将以下所有内容添加到路径中 enter image description here

我不确定为什么这不起作用。有人有什么想法吗?

python tensorflow keras deep-learning
1个回答
0
投票

DNN library is not found.
一般表示CUDA未正确安装或安装了错误的CUDA依赖项。第一步,您可以通过在终端中运行
nvidia-smi
来检查安装是否正常。

© www.soinside.com 2019 - 2024. All rights reserved.