I am working on running a sequential model with a couple of Conv1D layers but without fail it causes my system to crash before it can get through the first Epoch. I have even tried running some really basic code to no avail. I have been training many other models and have been able to take advantage of the Tensorflow GPU computing but none of my models have used Conv1D layers.
My system is as follows:
CPU : i9-13900K
GPU: RTX 4090
Python Version: 3.10.11
Tensor Flow GPU Version: 2.10.0
Cuda compilation tools, release 11.5, V11.5.50
CuDNN version: 11
Here is the code I am trying to run that I found in an example here:
> from keras.models import Sequential > from keras.layers import Dense, Conv1D, Flatten, MaxPooling1D > from sklearn.model_selection import train_test_split > from sklearn.metrics import confusion_matrix > from sklearn.datasets import load_iris > from numpy import unique > import tensorflow as tf > > > iris = load_iris() > x, y = iris.data, iris.target > print(x.shape) > > x = x.reshape(x.shape, x.shape, 1) > print(x.shape) > > print(unique(y)) > > print(unique(y).sum()) > > xtrain, xtest, ytrain, ytest=train_test_split(x, y, test_size=0.15) > > model = Sequential() > model.add(Conv1D(64, 2, activation="relu", input_shape=(4,1))) > model.add(Dense(16, activation="relu")) > model.add(MaxPooling1D()) > model.add(Flatten()) > model.add(Dense(3, activation = 'softmax')) > model.compile(loss = 'sparse_categorical_crossentropy', > optimizer = "adam", > metrics = ['accuracy']) > model.summary() > > > predictions = model.predict(xtest) > if tf.keras.backend.is_casting_error(predictions): > print('There are numerical errors in the model.') > else: > print('There are no numerical errors in the model.') > > model.fit(xtrain, ytrain, batch_size=16,epochs=100, verbose=0) > > acc = model.evaluate(xtrain, ytrain) > print("Loss:", acc, " Accuracy:", acc) > > pred = model.predict(xtest) > pred_y = pred.argmax(axis=-1) > > cm = confusion_matrix(ytest, pred_y) > print(cm)
This is the model it creates as expected:
Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= conv1d (Conv1D) (None, 3, 64) 192 dense (Dense) (None, 3, 16) 1040 max_pooling1d (MaxPooling1D (None, 1, 16) 0 ) flatten (Flatten) (None, 16) 0 dense_1 (Dense) (None, 3) 51 ================================================================= Total params: 1,283 Trainable params: 1,283 Non-trainable params: 0 _________________________________________________________________
Lastly this is the error it gives me every time before working through the first Epoch:
2023-11-06 15:19:41.822912: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-11-06 15:19:42.197565: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21358 MB memory: -> device: 0, name: NVIDIA GeForce RTX 4090, pci bus id: 0000:01:00.0, compute capability: 8.9 2023-11-06 15:19:44.270083: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8903 Restarting kernel...