Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

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

Open
ShwetaTiwariRepo opened this issue May 8, 2021 · 2 comments

Comments

@ShwetaTiwariRepo
Copy link

ShwetaTiwariRepo commented May 8, 2021

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
Copy link

jmgaudet commented May 9, 2021

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

@ShwetaTiwariRepo
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants