问题描述
由于我找不到任何有用的信息,所以我想寻求您的帮助。
我想在服务器上启动TensorFlow(2.1.0),并使用客户端上的keras在其上训练模型。
要启动TensorFlow服务器,我在远程计算机上使用了tf.distribute.Server类:
import tensorflow as tf
cluster_spec = tf.train.ClusterSpec({
"worker": [
"remotehost:2222"
],"ps": [
"remotehost:2221"
]
})
ps = tf.distribute.Server(cluster_spec,job_name="ps",task_index=0)
worker = tf.distribute.Server(cluster_spec,job_name="worker",task_index=0)
ps.join()
worker.join()
使用experimental_connect_to_host方法,客户端可以成功连接到服务器:
tf.config.experimental_connect_to_host(remote_host='remotehost:2222',job_name='worker')
但是,我不确定如何告诉keras使用此服务器。因此,在创建和训练模型之前,我只是打电话给experimental_connect_to_host
。建立了连接,但培训仍在本地进行:
2020-09-25 17:42:25.776262: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your cpu supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2020-09-25 17:42:25.809998: I tensorflow/core/common_runtime/process_util.cc:147] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
2020-09-25 17:42:25.875051: I tensorflow/core/distributed_runtime/rpc/grpc_channel.cc:300] Initialize GrpcChannelCache for job worker -> {0 -> remotehost:2222}
2020-09-25 17:42:25.889637: I tensorflow/core/distributed_runtime/rpc/grpc_channel.cc:300] Initialize GrpcChannelCache for job localhost -> {0 -> localhost:59320}
2020-09-25 17:42:28.325110: I tensorflow/core/distributed_runtime/rpc/grpc_channel.cc:300] Initialize GrpcChannelCache for job worker -> {0 -> remotehost:2222}
2020-09-25 17:42:28.368530: I tensorflow/core/distributed_runtime/rpc/grpc_channel.cc:300] Initialize GrpcChannelCache for job localhost -> {0 -> localhost:59320}
2020-09-25 17:42:28.427439: I tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc:390] Started server with target: grpc://localhost:59320
Train on 539 samples,validate on 29 samples
Epoch 1/300
539/539 - 2s - loss: 0.4477 - accuracy: 0.8534 - val_loss: 0.4668 - val_accuracy: 0.8276
...
有人知道是否以及如何使用Keras和TensorFlow在远程设备上进行训练吗?
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)