美文网首页Ray
[ray入门] 在Linux上安装部署Ray集群

[ray入门] 在Linux上安装部署Ray集群

作者: king_wang | 来源:发表于2021-11-02 19:20 被阅读0次

Ray是一个高性能分布式计算框架,借助它可以非常容易的构建分布式运算任务。本文将介绍如何在Linux上部署Ray集群:

架构

Ray集群由一个Head节点和多个Worker节点组成:

cluster.png

Anaconda

为了方便,我们最好利用 Anaconda构建来一个独立的python运行环境。(当然你也可以直接使用系统内python运行环境,那么你可以跳过此步骤)

# 下载安装脚本
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 添加执行权限
$ chmod u+x Miniconda3-latest-Linux-x86_64.sh 
# 运行安装脚本
$ ./Miniconda3-latest-Linux-x86_64.sh

安装python

为ray准备一个python环境,以python3.8.8示例:

# 创建一个名为ray,版本为3.8.8的python环境
$ conda create --name ray python=3.8.8
# 激活名为ray的python环境
$ conda activate ray

安装完之后,最好重新登录一下,或者执行一下source ~/.bashrc使得环境变量生效

安装ray

安装ray(版本为1.7.0),这里为了加快速度指定了阿里的镜像源:

$ pip install -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com -U 'ray[default]'==1.7.0

启动head节点

192.168.100.1上启动Head节点:

$ ray start --head --dashboard-host='0.0.0.0' --dashboard-port=8265

正常会看到如下输出:

Local node IP: 192.168.100.1
2021-11-02 18:33:11,977 INFO services.py:1250 -- View the Ray dashboard at http://192.168.100.1:8265
--------------------
Ray runtime started.
--------------------
Next steps
  To connect to this Ray runtime from another node, run
    ray start --address='192.168.100.1:6379' --redis-password='5241590000000000'
...

输出信息包含了2个关键信息,需要别注意:

  • View the Ray dashboard at http://192.168.100.1:8265:web服务的地址
  • ray start --address='192.168.100.1:6379' --redis-password='524159000':head的地址和密码

启动worker节点

192.168.100.2上,按照上面的步骤将python和ray安装好,注意它们的版本必须保持一致。
(另外,Worker不是必须的,因为Head节点本身就具有worker角色)

# 连接指定的Head地址
$ ray start --address='192.168.100.1:6379' --redis-password='5241590000000000'

Dashboad

访问dashboard:http://192.168.100.1:8265

dashboard.png

相关链接:

无法访问Ray Dashboard的几个原因

相关文章

网友评论

    本文标题:[ray入门] 在Linux上安装部署Ray集群

    本文链接:https://www.haomeiwen.com/subject/qpwxzltx.html