[Python] Python TensorFlow Speech Recognition -1073741819 (0xC0000005) Error

Discussão em 'Python' iniciado por Stack, Agosto 22, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a speech recognition project using TensorFlow in Python. Normally, TensorFlow can only be used with a CPU or an NVIDIA GPU. I have an AMD Radeon 7600S GPU. Because of this, I installed the tensorflow-directml-plugin developed by Microsoft, which allowed it to detect my AMD GPU. However, I'm currently facing another issue. I run my code, the necessary dataset for my model downloads, and the model is trained. But after training, during the testing phase, I get the following error:

    2025-08-22 19:29:27.611794: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 13875 MB memory) -> physical PluggableDevice (device: 0, name: DML, pci bus id: <undefined>)
    63/63 [==============================] - 9s 136ms/step - loss: 14.5690 - accuracy: 0.1045 - val_loss: 2.4005 - val_accuracy: 0.1140
    Epoch 2/5
    63/63 [==============================] - 8s 132ms/step - loss: 2.4516 - accuracy: 0.1370 - val_loss: 2.1963 - val_accuracy: 0.1560
    Epoch 3/5
    63/63 [==============================] - 8s 122ms/step - loss: 2.2549 - accuracy: 0.1680 - val_loss: 2.1321 - val_accuracy: 0.2320
    Epoch 4/5
    63/63 [==============================] - 2s 32ms/step - loss: 2.1942 - accuracy: 0.2035 - val_loss: 2.0759 - val_accuracy: 0.2540
    Epoch 5/5
    63/63 [==============================] - 4s 56ms/step - loss: 2.1982 - accuracy: 0.2075 - val_loss: 2.0824 - val_accuracy: 0.2440
    Model kaydedildi: spoken_digit_model.keras
    2025-08-22 19:29:49.644711: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
    2025-08-22 19:29:49.645238: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 13875 MB memory) -> physical PluggableDevice (device: 0, name: DML, pci bus id: <undefined>)

    Process finished with exit code -1073741819 (0xC0000005)


    I've researched the causes of this error but haven't been able to find a clear solution. I'll provide my code below. Any help would be greatly appreciated. Thank you in advance.

    My code:

    import os
    import tensorflow as tf
    import tensorflow_datasets as tfds
    import numpy as np


    (ds_train_full,), ds_info = tfds.load(
    'spoken_digit',
    split=['train'],
    as_supervised=True,
    with_info=True
    )

    commands = ds_info.features['label'].names
    num_classes = len(commands)
    print("Tanınacak komutlar:", commands)


    dataset_size = ds_info.splits['train'].num_examples
    train_size = int(0.8 * dataset_size)

    ds_train = ds_train_full.take(train_size)
    ds_test = ds_train_full.skip(train_size)



    def preprocess_audio(audio, label):
    audio = tf.cast(audio, tf.float32)


    audio = audio[:16000]
    zero_padding = tf.zeros([16000 - tf.shape(audio)[0]], dtype=tf.float32)
    audio = tf.concat([audio, zero_padding], 0)

    spectrogram = tf.signal.stft(audio, frame_length=255, frame_step=128)
    spectrogram = tf.abs(spectrogram)
    spectrogram = tf.expand_dims(spectrogram, -1)

    return spectrogram, label


    AUTOTUNE = tf.data.AUTOTUNE
    batch_size = 32

    ds_train = ds_train.map(preprocess_audio, num_parallel_calls=AUTOTUNE)
    ds_train = ds_train.batch(batch_size).cache().prefetch(AUTOTUNE)

    ds_test = ds_test.map(preprocess_audio, num_parallel_calls=AUTOTUNE)
    ds_test = ds_test.batch(batch_size).cache().prefetch(AUTOTUNE)


    model = tf.keras.Sequential([
    tf.keras.layers.Input(shape=(124, 129, 1)), # STFT sonrası approx. shape
    tf.keras.layers.Conv2D(32, (3, 3), activation='relu'),
    tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
    tf.keras.layers.MaxPooling2D((2, 2)),
    tf.keras.layers.Dropout(0.25),
    tf.keras.layers.GlobalAveragePooling2D(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dropout(0.5),
    tf.keras.layers.Dense(num_classes, activation='softmax')
    ])

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

    model.summary()


    epochs = 5
    model.fit(ds_train, validation_data=ds_test, epochs=epochs)


    model.save("spoken_digit_model.keras")
    print("Model kaydedildi: spoken_digit_model.keras")



    def predict_wav(model, wav_file_path, commands):
    audio_binary = tf.io.read_file(wav_file_path)
    audio, _ = tf.audio.decode_wav(audio_binary)
    audio = tf.squeeze(audio, axis=-1)


    if tf.shape(audio)[0] > 16000:
    audio = audio[:16000]
    elif tf.shape(audio)[0] < 16000:
    padding = tf.zeros([16000 - tf.shape(audio)[0]], dtype=tf.float32)
    audio = tf.concat([audio, padding], 0)

    spectrogram = tf.signal.stft(audio, frame_length=255, frame_step=128)
    spectrogram = tf.abs(spectrogram)
    spectrogram = spectrogram[tf.newaxis, ..., tf.newaxis]

    prediction = model.predict(spectrogram)
    predicted_id = np.argmax(prediction[0])
    return commands[predicted_id], prediction[0][predicted_id]



    wav_file = "Kayit.wav"
    predicted_command, confidence = predict_wav(model, wav_file, commands)
    print(f"Tahmin: {predicted_command}, Güven: {confidence:.4f}")


    I tried restarting to rule out possible Windows errors and ran it with administrator privileges, but I couldn't solve this error. I also tried forcing it to run on the CPU, but it still ran on the GPU. I tested another one of my TensorFlow projects, and it ran without any issues, but for some reason, I can't figure this one out.

    Continue reading...

Compartilhe esta Página