网站建设及那个科目,做网站要用那些软件,西安有啥好玩的地方,网站建设后商品进不去详情页目录
准备条件#xff08;基于linux环境#xff09; 参考文献例子-python Ray集群 1.部署head节点2.部署worker节点部署Ray集群安装Ray#xff08;在所有节点上安装#xff09;Ray工作原理Ray的优势Ray简介准备条件#xff08;基于linux环境#xff09;
这里部署2个节点…目录
准备条件基于linux环境 参考文献例子-python Ray集群 1.部署head节点2.部署worker节点部署Ray集群安装Ray在所有节点上安装Ray工作原理Ray的优势Ray简介准备条件基于linux环境
这里部署2个节点的集群准备2个linux环境ip为
192.168.2.165 worker节点(内存限制本地安装只有一个CPU)
192.168.2.220 head节点(内存限制本地安装只有一个CPU)安装 python3yum install python3 Ray学习文档地址https://ray.readthedocs.io/en/latest/index.html github地址https://github.com/ray-project/ray Ray简介
Ray是用于构建和运行分布式应用程序的快速简单的框架。
Ray与以下库打包在一起以加快机器学习的工作量
Tune可伸缩超参数调整 RLlib可扩展的强化学习 Distributed Training 分布式培训 Ray的优势
更省时高效
普通的执行方式是这样的:
Ray Ray工作原理 该图片引用来自参考文献1 安装Ray在所有节点上安装
pip3 install ray部署Ray集群 1.部署head节点
手动在head节点上启动
firewall-cmd --add-port6379/tcp
ray start --head --redis-port6379在这个节点上启动Ray。您可以通过调用向集群添加其他节点 Started Ray on this node. You can add additional nodes to the cluster by calling
ray start --redis-address 192.168.2.220:6379您可以通过运行Python将一个驱动程序连接到集群 from the node you wish to add. You can connect a driver to the cluster from Python by running
import ray
ray.init(redis_address192.168.2.220:6379)如果从不同的机器连接有问题请检查防火墙的配置是否正确。如果希望终止已启动的进程请运行 If you have trouble connecting from a different machine, check that your firewall is configured properly. If you wish to terminate the processes that have been started, run
ray stop2.部署worker节点
注意这里的ip 192.168.2.220 是步骤1中head节点的ip
firewall-cmd --add-port6379/tcp
ray start --redis-address 192.168.2.220:6379日志存放目录 /tmp/ray 例子-python Ray集群
# -*- coding: utf-8 -*-
import time
import ray
ray.init(redis_address192.168.2.220:6379)def f1():time.sleep(1)ray.remote
def f2():time.sleep(1)#以下需要十秒。
time1time.time()
[ f1() for _ in range(50)]
print(time.time()-time1)#以下需要一秒(假设系统至少有10个CPU)。
time2time.time()
ray.get([ f2.remote() for _ in range(50)])
print(time.time()-time2)任何程序错误以及技术疑问或需要解答的请添加