arise error Segmentation fault (core dumped) when I use tensorflow, my code is :
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.layers import Embedding
from keras.layers import LSTM
from keras.utils import to_categorical
model = Sequential()
max_features = 100
model.add(Embedding(max_features, output_dim=256))
model.add(LSTM(128))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
print("model is ok ")
Segmentation fault
means that you tried to access memory that you do not have access. If you choose right combination of Tensorflow
, CUDA
and cuDNN
will solve this issue. You can refer tested build configuration .
I was able to execute above code without any issues. Please refer the same as shown below
import tensorflow as tf
print(tf.__version__)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Embedding, LSTM
model = Sequential()
max_features = 100
model.add(Embedding(max_features, output_dim=256))
model.add(LSTM(128))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model.summary()
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
print("model is ok ")
Output:
2.5.0
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
embedding (Embedding) (None, None, 256) 25600
_________________________________________________________________
lstm (LSTM) (None, 128) 197120
_________________________________________________________________
dropout (Dropout) (None, 128) 0
_________________________________________________________________
dense (Dense) (None, 1) 129
=================================================================
Total params: 222,849
Trainable params: 222,849
Non-trainable params: 0
_________________________________________________________________
model is ok
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.