-1

I am trying to follow this tutorial but I can't get the first network to train. It crashes with this message:

Process finished with exit code -1073740791 (0xC0000409)

and doesn't throw an error so I don't know what to google anymore

I'm using Pycharm comunity edition and python 3.7 and I am not very experienced.

I also googled for different tutorials but they are all very similar. I got everything working to the point of building the model, but the training won't start. The tutorial used the model.fit_generate function but that threw an error so I am using the model.fit function. Am I using the fit function wrong?

here is my code:

# baseline model for the dataset
import sys
from matplotlib import pyplot
from keras.utils import to_categorical
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPool2D
from keras.layers import Dense
from keras.layers import Flatten
from keras.optimizers import SGD
from keras.preprocessing.image import ImageDataGenerator

# define cnn model
def define_model():
    model = Sequential()
    model.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same',
                     input_shape=(200, 200, 3)))
    model.add(MaxPool2D((2, 2)))
    model.add(Flatten())
    model.add(Dense(128, activation='relu', kernel_initializer='he_uniform'))
    model.add(Dense(1, activation='sigmoid'))
    # compile model
    opt = SGD(lr=0.001, momentum=0.9)
    model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
    model.summary()
    return model


# run the test harness for evaluating a model
def run_test_harness():
    # define model
    model = define_model()
    # create data generator
    datagen = ImageDataGenerator(rescale=1.0 / 255.0)
    # prepare iterators
    train_it = datagen.flow_from_directory('data_dogs_vs_cats/train', class_mode='binary', batch_size=64,
                                           target_size=(200, 200))
    test_it = datagen.flow_from_directory('data_dogs_vs_cats/val', class_mode='binary', batch_size=64,
                                          target_size=(200, 200))
    # fit model
    history = model.fit(train_it, steps_per_epoch=len(test_it), validation_data=test_it, validation_steps=len(test_it),
                        epochs=20, verbose=0)
    # evaluate model
    _, acc = model.evaluate_generator(test_it, steps=len(test_it), verbose=0)
    print('> %.3f' % (acc * 100.0))


# entry point
run_test_harness()
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
FerdyG
  • 11
  • 1
  • 4
    Does this answer your question? [Process finished with exit code -1073740791 (0xC0000409) PyCharm](https://stackoverflow.com/questions/49432873/process-finished-with-exit-code-1073740791-0xc0000409-pycharm) – Christoph Rackwitz Aug 14 '22 at 01:44

1 Answers1

0

I had this issue and the reason is that PyCharm is hiding the errors when running the code directly from inside it. Try to run the code from a command line / terminal and you will see which errors are causing this crash.

This could happen when DLLs are missing from the bin directory of your cuda or when other bugs are available in the code.

In my case the following DLLs were missing from my cuda bin folder (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA):

  • cudnn64_8.dll
  • cudnn_ops_train64_8.dll
  • cudnn_ops_infer64_8.dll
  • cudnn_cnn_infer64_8.dll
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
JAD
  • 1,096
  • 12
  • 13