python - 具有 CuDNNLSTM 层的 Keras 模型在生产服务器上不起作用

标签 python keras tensorflow

我已经使用 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/

相关文章:

python - 多处理事件子类化

python - Python的多处理池完成后未释放内存

python - 使用索引数组返回 'ndarray' 的值

python - 将字节字符串转换为 matplotlib 可读时间

python - 将从 keras.backend.argmax 返回的张量作为索引传递给 keras.backend,gather 预计为 'An integer tensor of indices.'

tensorflow - 带有 tensorflow 的 keras 运行良好,直到我添加回调

python - 我可以在 gpu 上运行 Keras 模型吗?

keras - 使用 Keras 在 RNN 中进行多特征序列填充和掩蔽

python - 计算轴未对齐的两个矩形之间的交集面积

tensorflow - 是否可以将 TensorFlow Serving 与分布式 TensorFlow 集群结合使用来提高吞吐量/延迟?