[C++ API] support cpu gpu num 0 (#17783)

* support cpu gpu num 0

* support cpu gpu num 0

* fix
This commit is contained in:
Guyang Song 2021-08-13 08:45:33 +08:00 committed by GitHub
parent f624ddae5f
commit b97027ec64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View file

@ -44,11 +44,11 @@ class RayConfig {
// Number of CPUs the user wishes to assign to each raylet. By default, this is set // Number of CPUs the user wishes to assign to each raylet. By default, this is set
// based on virtual cores. // 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 // Number of GPUs the user wishes to assign to each raylet. By default, this is set
// based on detected GPUs. // 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. // A mapping the names of custom resources to the quantities for them available.
std::unordered_map<std::string, int> resources; std::unordered_map<std::string, int> resources;

View file

@ -60,10 +60,10 @@ void ConfigInternal::Init(RayConfig &config, int *argc, char ***argv) {
if (config.redis_password_) { if (config.redis_password_) {
redis_password = *config.redis_password_; redis_password = *config.redis_password_;
} }
if (config.num_cpus > 0) { if (config.num_cpus >= 0) {
num_cpus = config.num_cpus; num_cpus = config.num_cpus;
} }
if (config.num_gpus > 0) { if (config.num_gpus >= 0) {
num_gpus = config.num_gpus; num_gpus = config.num_gpus;
} }
if (!config.resources.empty()) { if (!config.resources.empty()) {

View file

@ -53,9 +53,9 @@ class ConfigInternal {
std::string node_ip_address = ""; 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; std::unordered_map<std::string, int> resources;

View file

@ -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::vector<std::string> cmdargs({"ray", "start", "--head", "--port",
std::to_string(redis_port), "--redis-password", std::to_string(redis_port), "--redis-password",
redis_password, "--include-dashboard", "false"}); redis_password, "--include-dashboard", "false"});
if (num_cpus > 0) { if (num_cpus >= 0) {
cmdargs.emplace_back("--num-cpus"); cmdargs.emplace_back("--num-cpus");
cmdargs.emplace_back(std::to_string(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("--num-gpus");
cmdargs.emplace_back(std::to_string(num_gpus)); cmdargs.emplace_back(std::to_string(num_gpus));
} }

View file

@ -28,7 +28,7 @@ class ProcessHelper {
void RayStart(CoreWorkerOptions::TaskExecutionCallback callback); void RayStart(CoreWorkerOptions::TaskExecutionCallback callback);
void RayStop(); void RayStop();
void StartRayNode(const int redis_port, const std::string redis_password, 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 = {}); const std::unordered_map<std::string, int> resources = {});
void StopRayNode(); void StopRayNode();