Ale*_*dro 11 python gpu distributed-computing cluster-computing keras
我在两台不同的机器上安装了两个GPU.我想构建一个集群,允许我通过一起使用两个GPU来学习Keras模型.
Keras博客在分布式培训部分显示两段代码并链接官方Tensorflow文档.
我的问题是我不知道如何学习我的模型,用Keras编写,使用Tensorflow文档实际描述了Tensorflow对象的过程.
例如,如果我想在多个GPU的集群上执行以下代码,我该怎么办?
# For a single-input model with 2 classes (binary classification):
model = Sequential()
model.add(Dense(32, activation='relu', input_dim=100))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',
metrics=['accuracy'])
# Generate dummy data
import numpy as np
data = np.random.random((1000, 100))
labels = np.random.randint(2, size=(1000, 1))
# Train the model, iterating on the data in batches of 32 samples
model.fit(data, labels, epochs=10, batch_size=32)
Run Code Online (Sandbox Code Playgroud)