mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[C++ API] support cpu gpu num 0 (#17783)
* support cpu gpu num 0 * support cpu gpu num 0 * fix
This commit is contained in:
parent
f624ddae5f
commit
b97027ec64
5 changed files with 9 additions and 9 deletions
|
@ -44,11 +44,11 @@ class RayConfig {
|
|||
|
||||
// Number of CPUs the user wishes to assign to each raylet. By default, this is set
|
||||
// based on virtual cores.
|
||||
int num_cpus = 0;
|
||||
int num_cpus = -1;
|
||||
|
||||
// Number of GPUs the user wishes to assign to each raylet. By default, this is set
|
||||
// based on detected GPUs.
|
||||
int num_gpus = 0;
|
||||
int num_gpus = -1;
|
||||
|
||||
// A mapping the names of custom resources to the quantities for them available.
|
||||
std::unordered_map<std::string, int> resources;
|
||||
|
|
|
@ -60,10 +60,10 @@ void ConfigInternal::Init(RayConfig &config, int *argc, char ***argv) {
|
|||
if (config.redis_password_) {
|
||||
redis_password = *config.redis_password_;
|
||||
}
|
||||
if (config.num_cpus > 0) {
|
||||
if (config.num_cpus >= 0) {
|
||||
num_cpus = config.num_cpus;
|
||||
}
|
||||
if (config.num_gpus > 0) {
|
||||
if (config.num_gpus >= 0) {
|
||||
num_gpus = config.num_gpus;
|
||||
}
|
||||
if (!config.resources.empty()) {
|
||||
|
|
|
@ -53,9 +53,9 @@ class ConfigInternal {
|
|||
|
||||
std::string node_ip_address = "";
|
||||
|
||||
int num_cpus = 0;
|
||||
int num_cpus = -1;
|
||||
|
||||
int num_gpus = 0;
|
||||
int num_gpus = -1;
|
||||
|
||||
std::unordered_map<std::string, int> resources;
|
||||
|
||||
|
|
|
@ -80,11 +80,11 @@ void ProcessHelper::StartRayNode(const int redis_port, const std::string redis_p
|
|||
std::vector<std::string> cmdargs({"ray", "start", "--head", "--port",
|
||||
std::to_string(redis_port), "--redis-password",
|
||||
redis_password, "--include-dashboard", "false"});
|
||||
if (num_cpus > 0) {
|
||||
if (num_cpus >= 0) {
|
||||
cmdargs.emplace_back("--num-cpus");
|
||||
cmdargs.emplace_back(std::to_string(num_cpus));
|
||||
}
|
||||
if (num_gpus > 0) {
|
||||
if (num_gpus >= 0) {
|
||||
cmdargs.emplace_back("--num-gpus");
|
||||
cmdargs.emplace_back(std::to_string(num_gpus));
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class ProcessHelper {
|
|||
void RayStart(CoreWorkerOptions::TaskExecutionCallback callback);
|
||||
void RayStop();
|
||||
void StartRayNode(const int redis_port, const std::string redis_password,
|
||||
const int num_cpus = 0, const int num_gpus = 0,
|
||||
const int num_cpus = -1, const int num_gpus = -1,
|
||||
const std::unordered_map<std::string, int> resources = {});
|
||||
void StopRayNode();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue