Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

conv neural network - Error message ' No Algorithm worked' in CNN using Tensorflow2 and NVIDIA RTX 2080 Max-Q

I have used standard code to download MNIST_Fashion dataset and run a CNN, using Tensorflow 2 (2.3.1) and Keras (2.4.0). The code works fine on a normal laptop without GPU. However, on a laptop with NVIDIA RTX 2080 Max-Q I get error message: 'No algorithm worked!'.

Duo you have any suggestions how to run the code on laptop with GPU?

The code I have used:

from __future__ import absolute_import, division, print_function, unicode_literals
from tensorflow import keras as ks
   
fashion_mnist = ks.datasets.fashion_mnist
(training_images, training_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']

training_images = training_images / 255.0
test_images = test_images / 255.0
training_images = training_images.reshape(60000, 28, 28, 1)
test_images = test_images.reshape(10000, 28, 28, 1)

cnn_model = ks.models.Sequential()
cnn_model.add(ks.layers.Conv2D(50, (3, 3), activation='relu', padding='same', input_shape=(28, 28, 1), name='Conv2D_l'))
cnn_model.add(ks.layers.MaxPooling2D((2, 2), padding='same', name='MaxPooling_2D'))
cnn_model.add(ks.layers.Flatten(name='Flatten'))
cnn_model.add(ks.layers.Dense(50, activation='relu', name='Hidden_layer'))
cnn_model.add(ks.layers.Dense(10, activation='softmax', name='Output_layer'))

cnn_model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])

cnn_model.fit(training_images, training_labels, epochs=100)
question from:https://stackoverflow.com/questions/65645600/error-message-no-algorithm-worked-in-cnn-using-tensorflow2-and-nvidia-rtx-208

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Providing the full error message might be more useful next time.

I assume, adding these lines might solve your issue:

from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession

config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...