当前位置:网站首页>Distributed framework ray - detailed introduction to starting ray and connecting clusters

Distributed framework ray - detailed introduction to starting ray and connecting clusters

2022-06-11 05:43:00 A long journey begins with a single step

Ray The program can use the underlying Ray Parallelize and distribute the runtime .Ray The runtime consists of multiple services that are started in the background / Process composition , For communication 、 The data transfer 、 Scheduling, etc .Ray It can run on a laptop 、 Start on a single server or multiple servers .

start-up Ray There are three ways to run :

1、 Implicit pass ray.init()( Start on a single machine Ray, Automatically create ray colony )
2、 adopt CLI Explicit ( adopt CLI start-up Ray (ray start --head --port=6379))
3、 Explicitly through the cluster initiator ( start-up Ray colony (ray up ./xx.sh))
4、 Use Ray The client connects to an existing Ray Runtime

Check ray Whether to initialize

import ray
ray.init()
#  Check ray Whether to initialize 
if ray.is_initialized() == False
	ray.init()
#  Show off api 
ray.shutdown()

ray client

Ray Client It is a will. Python Script connects to remote Ray Clustered API. actually , It allows you to run as if on a local computer Ray Also use remote Ray colony .
Use ray Client scenario : Requires script or interactive connection to remote , Apply to ray1.5+

ray.init(
    "ray://1.2.3.4:10001",
    namespace="my_namespace",#  Set the namespace of the session 
    runtime_env={
    "working_dir": "files/my_project", "pip": ["toolz", "requests"]},
    #  Set the running environment of the session 
)

Ray Connected to the cluster 3 In the form of

For the convenience of introducing , Suppose the machine A,B,C
1、 if B and C Used to set up the cluster ,A Do development ,A Script to connect to the cluster , Need to use ( Client connection )ray.init(“ray://<head_node_host>:10001”)
2、 if B Is the head node of the cluster , And in B On the development ,B Script to connect to the cluster , Need to use ( Non client connection )
ray.init(“localhost:”)
3、 There is only one machine A, Automatically create clusters , Need to be ( Non client connection ) Use ray.init()

原网站

版权声明
本文为[A long journey begins with a single step]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020535171456.html