Как запустить tenorflow с horovod на локальной машине без графического процессора для отладки? - PullRequest
0 голосов
/ 15 мая 2019

Прежде чем создавать ошибку, я хотел бы спросить здесь.

Я, как и большинство из нас, отлаживаю код на локальной машине.Я ожидаю, что horovod предоставляет возможность работать на локальной машине (со всеми установленными зависимостями) для отладки модели, как обычный тензорный поток.Хотя я не смог найти способ сделать это.

Я пытался запустить базовый скрипт со страницы README с небольшим изменением:

import tenorflow как tf import horovod.tensorflowas hvd

hvd.init()

# Pin GPU to be used to process local rank (one GPU per process)
config = tf.ConfigProto()
config.gpu_options.visible_device_list = str(hvd.local_rank())

# Build model...
params = tf.get_variable("params", [1, 2, 3, 4])
loss = tf.math.reduce_mean(params)
opt = tf.train.AdagradOptimizer(0.01 * hvd.size())

# Add Horovod Distributed Optimizer
opt = hvd.DistributedOptimizer(opt)

# Add hook to broadcast variables from rank 0 to all other processes during
# initialization.
hooks = [hvd.BroadcastGlobalVariablesHook(0)]

# Make training operation
train_op = opt.minimize(loss)

# Savepipts only on worker 0 to prevent other workers from corrupting them.
checkpoint_dir = '/tmp/train_logs' if hvd.rank() == 0 else None

# The MonitoredTrainingSession takes care of session initialization,
# restoring from a checkpoint, saving to a checkpoint, and closing when done
# or an error occurs.
with tf.train.MonitoredTrainingSession(checkpoint_dir=checkpoint_dir,
                                       config=config,
                                       hooks=hooks) as mon_sess:
  while not mon_sess.should_stop():
    # Perform synchronous training.
    mon_sess.run(train_op)

Что привело к:

ValueError: Variable params already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:

  File "<ipython-input-5-057c766a5c1e>", line 6, in <module>
    params = tf.get_variable("params", [1, 2, 3, 4])
  File "/Users/yauheni/env/dev/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/Users/yauheni/env/dev/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3214, in run_ast_nodes
    if (yield from self.run_code(code, result)):
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...