带有 tensorflow-gpu 的 Keras 完全冻结了 PC

Keras with tensorflow-gpu totally freezes PC

我有非常简单的架构 lstm NN。在第 1-2 个纪元之后,我的电脑完全死机了,我什至无法移动我的鼠标:

Layer (type)                 Output Shape              Param #   
=================================================================
lstm_4 (LSTM)                (None, 128)               116224    
_________________________________________________________________
dropout_3 (Dropout)          (None, 128)               0         
_________________________________________________________________
dense_5 (Dense)              (None, 98)                12642     
=================================================================
Total params: 128,866
Trainable params: 128,866
Non-trainable params: 0

    # Same problem  with 2 layers LSTM  with dropout and Adam optimizer

    SEQUENCE_LENGTH =3, len(chars) = 98
    model = Sequential()
    model.add(LSTM(128, input_shape = (SEQUENCE_LENGTH, len(chars))))
    #model.add(Dropout(0.15))
    #model.add(LSTM(128))
    model.add(Dropout(0.10))
    model.add(Dense(len(chars), activation = 'softmax'))

    model.compile(loss = 'categorical_crossentropy', optimizer = RMSprop(lr=0.01), metrics=['accuracy'])

我是这样训练的:

history = model.fit(X, y, validation_split=0.20, batch_size=128, epochs=10, shuffle=True,verbose=2).history

NN 需要 5 分钟才能完成 1 个 epoch。更大的批处理并不意味着问题会更快发生。但是更复杂的模型可以训练更多的时间来达到几乎相同的精度——大约 0.46(完整代码 here

我最近更新了 Linux Mint,1070ti 8GB,32Gb 内存

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.26 Driver Version: 396.26 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 107... Off | 00000000:08:00.0 On | N/A |
| 0% 35C P8 10W / 180W | 303MiB / 8116MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

图书馆:

Keras==2.2.0
Keras-Applications==1.0.2
Keras-Preprocessing==1.0.1
keras-sequential-ascii==0.1.1
keras-tqdm==2.0.1
tensorboard==1.8.0
tensorflow==1.0.1
tensorflow-gpu==1.8.0

我试过限制 GPU 内存使用,但这不是问题,因为在训练期间它只消耗 1 GB 的 gpu 内存:

from keras.backend.tensorflow_backend 
import set_session config = tf.ConfigProto() 

config.gpu_options.per_process_gpu_memory_fraction = 0.9 

config.gpu_options.allow_growth = True set_session(tf.Session(config=config))

这里有什么问题?我该如何解决这个问题?

  • 请先删除 tensorflow==1.0.1 的 cpu 版本。尝试通过 here
  • 中提到的来源构建 TensorFlow 来安装 tensorflow-gpu==1.8.0

  • 在 GPU 上训练模型时将 LSTM 替换为 CuDNNLSTM。稍后将经过训练的模型权重加载到与 LSTM 层相同的模型架构中,以在 CPU 上使用该模型。 (确保在重新加载 CuDNNLSTM 模型权重时在 LSTM 层中使用 recurrent_activation='sigmoid'!)

这对我来说有点奇怪,但问题与我 2018 年 4 月刚从 AMD CPU 发布的新产品有关。因此,拥有最新的 linux 内核至关重要:遵循本指南 https://itsfoss.com/upgrade-linux-kernel-ubuntu/ 我将内核从 4.13 更新到 4.17 - 现在一切正常

更新:主板也让系统崩溃,我已经改变了它 - 现在一切正常

我确实遇到了这个问题。计算机在大约 15 分钟的训练后死机了。我发现这是一张内存 SIMM 卡,当它变热/变热时就死了。如果你有不止一张SIMM卡,你可以一次取出一张,看看是不是罪魁祸首。