我已经使用 AWS p3 实例使用 GPU 加速训练以下模型:
x = CuDNNLSTM(128, return_sequences=True)(inputs)
x = Dropout(0.2)(x)
x = CuDNNLSTM(128, return_sequences=False)(x)
x = Dropout(0.2)(x)
predictions = Dense(1, activation='tanh')(x)
model = Model(inputs=inputs, outputs=predictions)
训练结束后,我使用 Keras 的 save_model
函数保存了模型,并将其移动到没有 GPU 的独立生产服务器上。
当我尝试在生产服务器上使用模型进行预测时,它失败并出现以下错误:
No OpKernel was registered to support Op 'CudnnRNN' with these attrs. Registered devices: [CPU], Registered kernels:
我猜这是因为生产服务器不支持 GPU,但我希望这不会成为问题。有什么方法可以在没有 GPU 的情况下在生产服务器上使用此模型?
最佳答案
不可以,CuDNN 需要使用 CUDA GPU。您必须将 CuDNNLSTM 层替换为标准 LSTM 层。
关于python - 具有 CuDNNLSTM 层的 Keras 模型在生产服务器上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48086014/