1、openmi 下载安装

  下载连接:

    https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.1.tar.gz

  安装命令

1
2
3
4
5
shell$ gunzip -c openmpi-4.0.1.tar.gz | tar xf -
shell$ cd openmpi-4.0.1
shell$ ./configure --prefix=/usr/local
<...lots of output...>
shell$ make all install

  

sudo ldconfig

2、horovod安装

官方文档: https://github.com/horovod/horovod#install

[sudo] pip3 install horovod
安装支持NCCL的版本的horovod
HOROVOD_GPU_ALLREDUCE=NCCL pip3 install --no-cache-dir horovod

3、horovod 使用

3.1 tensorFLow 修改

import tensorflow as tf
import horovod.tensorflow as hvd # Initialize Horovod
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...
loss = ...
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) # 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)

3.2 tensorflow 运行

mpi 指定mca通讯端口

mpirun --allow-run-as-root --oversubscribe \
-np 8-H ubuntu1:4,ubuntu2:4 \
-bind-to none -map-by slot \
-mca plm_rsh_args "-p 22" \
-x NCCL_DEBUG=INFO -x LD_LIBRARY_PATH -x PATH \
-mca pml ob1 -mca btl ^openib \
python3 -u train.py

机器学习分布式框架horovod安装 (Linux环境)的更多相关文章

  1. LNMP1.3一键安装Linux环境,配置Nginx运行ThinkPHP3.2

    LNMP1.3一键安装Linux环境,配置Nginx运行ThinkPHP3.2 你是否遇见过:安装LNMP1.3环境后,运行ThinkPHP 3.2,只能打开首页,不能访问控制器,报404错误. 按照 ...

  2. JDK安装 - Linux环境

    JDK安装 - Linux环境 1. 下载 :https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-21331 ...

  3. Windows 安装 Linux 环境

    简介 在实际开发中,我们除了在Windows上进行开发外,可能还需要基于Linux进行一些编译或者测试等,因此,我们可能需要在Windows环境中安装Linux环境,通常可能我们会使用虚拟机替代,但是 ...

  4. Scrapy爬虫框架第一讲(Linux环境)

    1.What is Scrapy? 答:Scrapy是一个使用python语言(基于Twistec框架)编写的开源网络爬虫框架,其结构清晰.模块之间的耦合程度低,具有较强的扩张性,能满足各种需求.(前 ...

  5. 安装Linux环境

    虚拟机:虚拟机(Virtual Machine),在计算机科学中的体系结构里,是指一种特殊的软件,他可以在计算机平台和终端用户之间建立一种环境,而终端用户则是基于这个软件所建立的环境来操作软件.在计算 ...

  6. 安装linux环境及相关包方法

    安装linux系统: 先下载 iso镜像文件,在windows系统下,插入u盘,下载 Ultraiso软件,安装好后,根据 http://jingyan.baidu.com/article/a378c ...

  7. ActiveMQ下载与安装(Linux环境下进行)

    下载 官方网站:http:activemq.apache.org/ 安装(liunx) 1.将apache-activemq-5.12.0-bin.tar.gz(liunx环境下的压缩包)上传至服务器 ...

  8. RabbitMQ 的安装----Linux环境

    CentOS7  安装RabbitMq 参考------>  https://www.cnblogs.com/liaojie970/p/6138278.html https://www.cnbl ...

  9. Ftp服务端安装-Linux环境

    目的 为什么要搭建FTP服务器,进入maven仓库下载Jar包时点击相应的链接进去会看到目录结构,这个就是ftp站点.可以随意的下载. 环境 Linux系统为CentOS6.5 安装步骤 查询是否已安 ...

随机推荐

  1. JAVA 怎么链接 SQL Server 数据库(半详细)

    哇今天闲着没事准备把前几天链接数据库碰到的问题写到博客,写到一半浏览器切出去了,这个浏览器也没保存,晚上又写了一遍,唉 蛋疼呀╮(╯▽╰)╭!! 说一说连接数据库遇到的问题,唉问题繁多,原来自己刷的精 ...

  2. php笔记04

    PHP+MySQL 连接数据库 mysqli <?php $servername="localhost"; $username="root"; $pass ...

  3. java 循环节长度

    循环节长度 两个整数做除法,有时会产生循环小数,其循环部分称为:循环节. 比如,11/13=6=>0.846153846153- 其循环节为[846153] 共有6位. 下面的方法,可以求出循环 ...

  4. C++Socket通信(客户端和服务器)

    win32控制台版 获取本机IP: cmd:       ipconfig/all 我写的是一个服务器和客户端点对点的信息传递(实现相互的可以适当更改代码): 服务器发送给客户端的是一个结构体数据 t ...

  5. JS - 使 canvas 背景透明

    canvas = document.getElementById('canvas1'); var context = canvas.getContext('2d');context.fillStyle ...

  6. spring mvc绑定参数之日期类型转换

    问题复现步骤: 1.提交表单,参数为: 2.接收参数类型为product实体类,如下 3.错误日志如下: org.springframework.validation.BindException: o ...

  7. 五十五、SAP中调用系统自带的函数

    一.我们需要取一个月中的最后一天,代码如下 二.执行结果如下 三.以上为纯手打,错了好几次才改过来,还有一个办法就是系统自动生成,点击编辑->模式 四.输入需要调用的函数名字BKK_GET_MO ...

  8. Elasticsearch 集群 - 健康检查

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  9. 仿淘宝 vue

    最近自己闲着无聊,用vue仿照淘宝打算写个皮囊,顺便把遇到的问题顺便记录下 1.动画问题 (1)单个元素给动画 <transition name="fade">< ...

  10. python练习(一)----打印九九乘法表

    打印九九乘法表 ,): ,i+): print("{0} x {1} = {2} \t".format(j,i,i*j),end='') //print默认end=‘\n’, pr ...