【问题标题】:Getting some issues related to tensorflow (2.5.0) on MacOS with M1 chip在带有 M1 芯片的 MacOS 上遇到一些与 tensorflow (2.5.0) 相关的问题
【发布时间】:2021-10-21 08:30:08
【问题描述】:

我第一次在 MacOS BigSur M1 处理器(版本 11.2.3)上尝试使用 François Chollet 的深度学习书中的以下文本分类代码。我正在使用 tensorflow 2.5.0 版

import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.datasets import imdb
from tensorflow.keras.preprocessing import sequence
max_features = 2000
max_len = 500
(x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=max_features)
x_train = sequence.pad_sequences(x_train, maxlen=max_len)
x_test = sequence.pad_sequences(x_test, maxlen=max_len)
model = keras.models.Sequential()
model.add(layers.Embedding(max_features, 128,input_length=max_len,name='embed'))
model.add(layers.Conv1D(32, 7, activation='relu'))
model.add(layers.MaxPooling1D(5))
model.add(layers.Conv1D(32, 7, activation='relu'))
model.add(layers.GlobalMaxPooling1D())
model.add(layers.Dense(1))
model.summary()
model.compile(optimizer='rmsprop',loss='binary_crossentropy',metrics=['acc'])
callbacks=[tf.keras.callbacks.TensorBoard(log_dir='my_log_dir',histogram_freq=1,embeddings_freq=1,)]

history = model.fit(x_train, y_train, epochs=20, batch_size=128,
                    validation_split=0.2,callbacks=callbacks)

为什么这些准确率和损失值非常高。如果我在 Windows 10 上运行相同的代码,我会得到不同的值。请检查两个屏幕截图。

使用 Adam 的优化器,我收到了内核似乎已经死亡的通知。

以及如何避免这些警告(粉色框内)

提前谢谢你

【问题讨论】:

    标签: macos tensorflow keras deep-learning apple-m1


    【解决方案1】:

    也许,问题出在我的 tensorflow=gpu 版本上。这与我的 CUDA 版本不兼容。您尝试安装兼容版本。

    【讨论】:

    • 怎么样?似乎没有什么对我有用。
    • !watch -n 0.1 nvidia-smi
    猜你喜欢
    • 1970-01-01
    • 2021-09-29
    • 2021-12-23
    • 2021-09-01
    • 2021-10-11
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 2022-09-25
    相关资源
    最近更新 更多