TensorFlow的ParameterServerStrategy无法按预期运行

问题描述

我想使用TensorFlow为Estimator API提供的ParameterServerStrategy训练模型。考虑到本教程,我实现了以下代码(我附加了部分代码,这是重要的一部分):

strategy = tf.distribute.experimental.ParameterServerStrategy()

server = tf.distribute.Server(
            config_json['cluster'],#earlier a config_json for setting TF_CONfig to env. variables
            job_name = job_type,# job_type ps/ worker depending on task
            task_index = job_index  # corresponding job_index
         )
if job_type == 'ps':
   server.join()
else:
   # Datasets is a class where I create necessary input pipelines with the dataset api
   train_input_fn = lambda : Datasets.get_train_data_pipeline_from_tensors(...)
   valid_input_fn = lambda : Datasets.get_valid_data_pipeline_from_tensors(...)

   run_config = tf.estimator.runconfig(
                      save_checkpoints_steps=steps_per_epoch,log_step_count_steps=steps_per_epoch,model_dir=<hdfs_path>,# Model checkpoints are made on a hdfs folder
                      train_distribute=strategy
                )
   keras_model = ...
   estimator = tf.keras.estimator.model_to_estimator(
                        keras_model=keras_model,config=run_config
                )
   train_spec = tf.estimator.TrainSpec(
                        train_input_fn,max_steps=epochs*steps_per_epoch
                )                                                                                                                                                                               
   eval_spec = tf.estimator.EvalSpec(
                        valid_input_fn,steps=validation_steps
                )

   tf.estimator.train_and_evaluate(estimator,train_spec,eval_spec)

在我自己的集群上运行以上代码认情况下已在TensorFlow v2.3上急切执行,我注意到以下内容

  • 认情况下,它以INDEPENDENT_WORKER分布式协调器模式运行(我想它是正确的,因为另一个引用远程集群,因为我没有将代码发送给另一个远程集群)
  • 使用神经节进行监视,似乎参数服务器实际上不起作用(cpu和mem几乎都为零)。相应的python进程一直在休眠,就像不需要它一样。群集网络也为零,表示没有通信。
  • 每个工作程序都在运行,但仅使用4个cpu中的一个(集群不包含GPU)。

总结一下,我的问题如下:

  1. 如何在设置中不使用参数服务器计算机?上面的代码中是否有任何明显的错误/缺少参数?
  2. 如何设置工作程序任务以使用所有cpu内核?我使用ConfigProtos尝试了inter / ra_op_parallelism_threads,但没有区别。我进一步注意到,物理设备列表中仅出现一个cpu

在此先感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)