microsoft / tensorflow-directml-plugin

DirectML PluggableDevice plugin for TensorFlow 2
Apache License 2.0
179 stars 23 forks source link

No OpKernel was registered to support Op 'CudnnRNN' used by {{node CudnnRNN}} #361

Open AkramHB opened 1 year ago

AkramHB commented 1 year ago

I’m using tensorflow-cpu 2.10 with tf-directml-plugin, and I did not install cuda toolkit and cudnn (Should I install them? if I should then what versions to install). I keep getting this error

InvalidArgumentError: Graph execution error: No OpKernel was registered to support Op ‘CudnnRNN’ used by {{node CudnnRNN}} with these attrs: [seed=0, dropout=0, T=DT_FLOAT, input_mode=“linear_input”, direction=“unidirectional”, rnn_mode=“lstm”, seed2=0, is_training=true] Registered devices: [CPU, GPU] Registered kernels:

My specs: Windows 11 RTX 4080

Here is my code:

# Set the maximum vocabulary size
vocab_size = 10000

# Convert the training text to sequences
train_sequences = tokenizer.texts_to_sequences(train_texts)

# Pad the sequences to have the same length
max_sequence_length = max(len(seq) for seq in train_sequences)
train_data = pad_sequences(train_sequences, maxlen=max_sequence_length)

# Create the main model
main_model = Sequential()

# Add the layers to the main model
main_model.add(Embedding(input_dim=vocab_size, output_dim=100, input_length=max_sequence_length))
main_model.add(Bidirectional(LSTM(64, return_sequences=True)))

# Create the Attention layer
attention = Attention()

# Apply the Attention layer to the main model's output
attention_output = attention([main_model.layers[-1].output, main_model.layers[-1].output])

# Create the new model that takes the Attention layer output as input
output = Dense(1, activation='sigmoid')(attention_output)
model = Model(inputs=main_model.input, outputs=output)

# Compile the model
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])

# Reshape the predicted labels
train_labels = np.expand_dims(train_labels, axis=-1)

# Train the Bi-LSTM classifier on the whole training dataset
model.fit(train_data, train_labels, epochs=1, batch_size=32, verbose=1)
PatriceVignola commented 8 months ago

You don't need to install cuda toolkit and cudnn as they don't work with this plugin. The plan was to eventually implement the CudnnRNN op for DirectML, but unfortunately we had to pause the development of this plugin until further notice. For the time being, all latest DirectML features and performance improvements are going into onnxruntime for inference scenarios. We'll update this issue if/when things change.