
下面我们对Horovod分布式深度学习框架v0.24.2文件阐述相关使用资料和Horovod分布式深度学习框架v0.24.2文件的更新信息。
易采下载网免费提供Horovod分布式深度学习框架下载资源服务,欢迎大家前来下载。
Horovod是针对TensorFlow,Keras,PyTorch和Apache MXNet的分布式深度学习培训框架。Horovod的目标是使分布式深度学习快速且易于使用。
Horovod由LF AI和数据基金会(LF AI&Data)托管。如果您是一家致力于在人工智能,机器和深度学习中使用开源技术的公司,并希望在这些领域中支持开源项目的社区,请考虑加入LF AI和数据基金会。有关谁参与以及Horovod如何扮演角色的详细信息,请阅读Linux Foundation公告。
安装要安装Horovod:
1、安装CMake
2、如果您已从PyPI安装TensorFlow ,请确保已安装g++-4.8.5或g++-4.9或更高版本。
如果您已从PyPI安装了PyTorch ,请确保已安装g++-4.9或更高版本。
如果您已经从Conda安装了任何一个软件包,请确保gxx_linux-64已安装Conda软件包。
3、安装horovodpip包。
要在CPU上运行:
$ pip install horovod
要在具有NCCL的GPU上运行:$ HOROVOD_GPU_OPERATIONS=NCCL pip install horovod
import tensorflow as tfimport horovod.tensorflow as hvd# Initialize Horovodhvd.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...loss = ...opt = tf.train.AdagradOptimizer(0.01 * hvd.size())# Add Horovod Distributed Optimizeropt = hvd.DistributedOptimizer(opt)# Add hook to broadcast variables from rank 0 to all other processes during# initialization.hooks = [hvd.BroadcastGlobalVariablesHook(0)]# Make training operationtrain_op = opt.minimize(loss)# Save checkpoints 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)
$ horovodrun -np 4 -H localhost:4 python train.py
2、要在具有4个GPU的4台计算机上运行:$ horovodrun -np 16 -H server1:4,server2:4,server3:4,server4:4 python train.py
3、要在不使用horovodrun包装的情况下使用Open MPI运行,请参阅使用Open MPI运行Horovod。