目录
Configuring Ray
配置Ray
This page discusses the various way to configure Ray, both from the Python API and from the command line. Take a look at the ray.init
documentation for a complete overview of the configurations.
本页讨论了配置Ray的各种方法,包括从Python API和命令行。请查看 ray.init
文档,了解配置的完整概述。
For the multi-node setting, you must first run ray start
on the command line to start the Ray cluster services on the machine before ray.init
in Python to connect to the cluster services. On a single machine, you can run ray.init()
without ray start
, which will both start the Ray cluster services and connect to them.
对于多节点设置,您必须首先在命令行上运行 ray start
以启动机器上的Ray集群服务,然后才能在Python中运行 ray.init
以连接到集群服务。在一台机器上,您可以运行 ray.init()
而不运行 ray start
,这将启动Ray集群服务并连接到它们。
1 Cluster Resources
1 群集资源编号
Ray by default detects available resources.
Ray默认检测可用资源。
import ray
# This automatically detects available resources in the single machine.
ray.init()
If not running cluster mode, you can specify cluster resources overrides through ray.init
as follows.
如果未运行群集模式,则可以通过 ray.init
指定群集资源覆盖,如下所示。
# If not connecting to an existing cluster, you can specify resources overrides:
ray.init(num_cpus=8, num_gpus=1)
# Specifying custom resources
ray.init(num_gpus=1, resources={
'Resource1': 4, 'Resource2': 16})
When starting Ray from the command line, pass the --num-cpus
and --num-gpus
flags into ray start
. You can also specify custom resources.
从命令行启动Ray时,将 --