[英]arise error Segmentation fault (core dumped) when I use tensorflow
arise error Segmentation fault (core dumped) when I use tensorflow, my code is :当我使用 tensorflow 时出现错误 Segmentation fault (core dumped),我的代码是:
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. Segmentation fault
意味着您尝试访问您无权访问的内存。 If you choose right combination of Tensorflow
, CUDA
and cuDNN
will solve this issue.如果选择正确的Tensorflow
组合, CUDA
和cuDNN
将解决这个问题。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.