目录
Core API
核心API
Connect to an existing Ray cluster or start one and connect to it. |
|
Disconnect the worker, and terminate processes started by ray.init(). |
|
Check if ray.init has been called yet. |
|
A class used to store the configurations of a job. |
Tasks 任务
Defines a remote function or an actor class. |
|
Configures and overrides the task invocation parameters. |
|
Cancels a task. 取消任务。 |
Actors
Defines a remote function or an actor class. |
|
Configures and overrides the actor instantiation parameters. |
|
Annotate an actor method. |
|
Get a handle to a named actor. |
|
Kill an actor forcefully. |
Objects 对象
Get a remote object or a list of remote objects from the object store. |
|
Return a list of IDs that are ready and a list of IDs that are not. |
|
Store an object in the object store. |
Runtime Context 数据库环境
Get the runtime context of the current driver/worker. |
|
A class used for getting runtime context. |
|
Get the IDs of the GPUs that are available to the worker. |
ray.init
ray.init(address: str | None = None, *, num_cpus: int | None = None, num_gpus: int | None = None, resources: Dict[str, float] | None = None, labels: Dict[str, str] | None = None, object_store_memory: int | None = None, local_mode: bool = False, ignore_reinit_error: bool = False, include_dashboard: bool | None = None, dashboard_host: str = '127.0.0.1', dashboard_port: int | None = None, job_config: ray.job_config.JobConfig = None, configure_logging: bool = True, logging_level: int = 'info', logging_format: str | None = None, log_to_driver: bool = True, namespace: str | None = None, runtime_env: Dict[str, Any] | RuntimeEnv | None = None, storage: str | None = None, **kwargs) → BaseContext
ray.init(地址:str| None=None,*,num_cpus:int| None=None,num_gpus:int| None=None,resources:Dict[str,float]|无=无,标签:Dict[str,str]| None=None,object_store_memory:int| None=无,local_mode:bool=假,ignore_reinit_error:bool=假,include_dashboard:bool| None=无,dashboard_host:str ='127.0.0.1 ',dashboard_port:int| None=无,job_config:ray.job_config.JobConfig=无,configure_logging:bool=True,logging_level:int='info',logging_format:str| None=None,log_to_driver:bool=True,命名空间:str| None=None,runtime_env:Dict[str,Any]| RuntimeEnv| None=无,存储:str| None=None,**kwargs)→ BaseContext[source] [出处]
Connect to an existing Ray cluster or start one and connect to it.
连接到现有的Ray群集或启动一个并连接到它。
This method handles two cases; either a Ray cluster already exists and we just attach this driver to it or we start all of the processes associated with a Ray cluster and attach to the newly started cluster. Note: This method overwrite sigterm handler of the driver process.
这种方法处理两种情况;要么一个Ray集群已经存在,我们只是将这个驱动程序附加到它,要么我们启动与Ray集群相关的所有进程,并附加到新启动的集群。注意:此方法覆盖驱动程序进程的sigterm处理程序。
In most cases, it is enough to just call this method with no arguments. This will autodetect an existing Ray cluster or start a new Ray instance if no existing cluster is found:
在大多数情况下,只需调用此方法而不带参数即可。这将自动检测现有的Ray集群或启动一个新的Ray实例,如果没有找到现有的集群:
ray.init()
To explicitly connect to an existing local cluster, use this as follows. A ConnectionError will be thrown if no existing local cluster is found.
要显式连接到现有的本地群集,请按如下方式使用此命令。如果没有找到现有的本地集群,则会抛出ConnectionError。
ray.init(