apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.67k stars 308 forks source link

Check failed: (void*)cp <= (void*)ptr (0x7fffffff7fffffff vs. 0x12dfb6fc0) #254

Open ShwetaTiwariRepo opened 3 years ago

ShwetaTiwariRepo commented 3 years ago

i am receiving multiple error with Different architecture of deep learning model, most of the time segmentation fault, tried changing my code to use a simple multilayer architecture to train a model of mnist dataset , got the error as F tensorflow/core/common_runtime/pool_allocator.cc:138] Check failed: (void)cp <= (void)ptr (0x7fffffff7fffffff vs. 0x12dfb6fc0).

below is my code to replicate the issue.

from tensorflow.keras.datasets import mnist import numpy as np from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPool2D, Dropout from tensorflow.keras.optimizers import SGD, Adam from tensorflow.keras.preprocessing.image import ImageDataGenerator from sklearn.preprocessing import LabelBinarizer from sklearn.model_selection import train_test_split

((trainData, trainLabels), (testData, testLabels)) = mnist.load_data() data = np.vstack([trainData, testData]) labels = np.hstack([trainLabels, testLabels])

data = np.array(data, dtype="float32")

data = np.expand_dims(data, axis=-1) data /= 255.0

le = LabelBinarizer() labels = le.fit_transform(labels) counts = labels.sum(axis=0)

classTotals = labels.sum(axis=0) classWeight = {} for i in range(0, len(classTotals)): classWeight[i] = classTotals.max() / classTotals[i]

(trainX, testX, trainY, testY) = train_test_split(data, labels, train_size=0.80,stratify=labels, random_state=0)

aug = ImageDataGenerator( rotation_range=10, zoom_range=0.05, width_shift_range=0.1, height_shift_range=0.1, shear_range=0.15, horizontal_flip=False, fill_mode="nearest")

model=Sequential()

model.add(Conv2D(filters=32, kernel_size=(3,3),activation='relu', input_shape=(28,28,1))) model.add(MaxPool2D(pool_size=(2,2),strides=2)) model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding='same')) model.add(MaxPool2D(pool_size=(2,2),strides=2)) model.add(Conv2D(filters=128,kernel_size=(3,3), activation='relu',padding='valid')) model.add(MaxPool2D(pool_size=(2,2),strides=2))

model.add(Flatten())

model.add(Dense(64,activation='relu')) model.add(Dense(128,activation='relu'))

model.add(Dense(10,activation='softmax'))

EPOCHS=10

opt = SGD(lr=0.01, decay=0.01 / EPOCHS)

model.compile(loss="categorical_crossentropy", optimizer=opt, metrics=["accuracy"])

H = model.fit( aug.flow(trainX, trainY, batch_size=16), validation_data=(testX, testY), steps_per_epoch=len(trainX) // 16, epochs=EPOCHS, class_weight=classWeight, verbose=1)

jmgaudet commented 3 years ago

I think it has something to do with classWeight, because if you comment-out that parameter, it'll work.

ShwetaTiwariRepo commented 3 years ago

thanks, it works after commenting it, but why that should be an issue, the same code works on x86_64 environment.