Error: “CUDNN STATUS NOT INITIALIZED” in keras-based convolutional network

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Error: “CUDNN STATUS NOT INITIALIZED” in keras-based convolutional network



I'm trying to create a convolutional network using keras. However, I'm getting the following error:



2018-08-05 21:10:44.670676: E
T:srcgithubtensorflowtensorflowstream_executorcudacuda_dnn.cc:332]
could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED 2018-08-05
21:10:44.670843: E
T:srcgithubtensorflowtensorflowstream_executorcudacuda_dnn.cc:336]
error retrieving driver version: Unimplemented: kernel reported driver
version not implemented on Windows



I haven't installed cudnn seperately, only installed tensorflow-gpu through pip (not using the url). A seperate program that doesn't use a convolutional network works fine. My code:



from __future__ import print_function
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.datasets import mnist
from tensorflow.keras.layers import Dense, Flatten
from tensorflow.keras.layers import Conv2D, MaxPooling2D
from tensorflow.keras.models import Sequential
import matplotlib.pylab as plt
import numpy as np
batch_size = 64
num_classes = 10
epochs = 10

# input image dimensions
img_x, img_y = 32, 32

# Load cifar data from file
# define standard sizing values
image_height = 32
image_width = 32
color_channels = 3

model_name = "cifar"


def unpickle(file):
import pickle
with open(file, 'rb') as fo:
dict = pickle.load(fo, encoding='bytes')
return dict


# Set the path as a mutable variable and initiate our training stuff
cifar_path = 'cifar-10-batches-py/'

x_train = np.array()
y_train = np.array()

# Load all the data batches.
for i in range(1, 3):
data_batch = unpickle(cifar_path + 'data_batch_' + str(i))
x_train = np.append(x_train, data_batch[b'data'])
y_train = np.append(y_train, data_batch[b'labels'])

# Load the eval batch.
eval_batch = unpickle(cifar_path + 'test_batch')

x_test = eval_batch[b'data']
y_test = eval_batch[b'labels']

# Load the english category names.
category_names_bytes = unpickle(cifar_path + 'batches.meta')[b'label_names']
category_names = list(map(lambda x: x.decode("utf-8"),
category_names_bytes))


def process_data(data):
float_data = np.array(data, dtype=float) / 255.0

reshaped_data = np.reshape(float_data, (-1, color_channels, image_height, image_width))

# The incorrect image

transposed_data = np.transpose(reshaped_data, [0, 2, 3, 1])
return transposed_data


# redefine the data with it in its processed form
x_train = process_data(x_train)

x_test = process_data(x_test)
# reshape the data into a 4D tensor - (sample_number, x_img_size, y_img_size, num_channels)
x_train = x_train.reshape(x_train.shape[0], img_x, img_y, 3)
x_test = x_test.reshape(x_test.shape[0], img_x, img_y, 3)
input_shape = (img_x, img_y, 3)

# convert the data to the right type
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')

# convert class vectors to binary class matrices - this is for use in the
# categorical_crossentropy loss below
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)

model = Sequential()
model.add(Conv2D(32, kernel_size=(5, 5), strides=(1, 1),
activation='relu',
input_shape=input_shape))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
model.add(Conv2D(64, (5, 5), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(1000, activation='relu'))
model.add(Dense(num_classes, activation='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adam(),
metrics=['accuracy'])


class AccuracyHistory(keras.callbacks.Callback):
def on_train_begin(self, logs=):
self.acc =

def on_epoch_end(self, batch, logs=):
self.acc.append(logs.get('acc'))

history = AccuracyHistory()

model.fit(x_train, y_train,
batch_size=batch_size,
epochs=epochs,
verbose=1,
validation_data=(x_test, y_test),
callbacks=[history])
score = model.evaluate(x_test, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
plt.plot(range(1, 11), history.acc)
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.show()




1 Answer
1



You need to include cudnn in your environment variables(if on windows), if you need to run tensorflow-gpu.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard