Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++ API]support set resources in RayConfig #17779

Merged
merged 2 commits into from
Aug 12, 2021

Conversation

SongGuyang
Copy link
Contributor

Why are these changes needed?

  • support set resources in RayConfig, like:
   RayConfig config;
    config.num_cpus = 8;
    config.num_gpus = 4;
    config.resources = {{"Custom", 2}};
    ray::Init(config);

@SongGuyang SongGuyang added this to the C++ API milestone Aug 12, 2021
cmdargs.emplace_back(std::to_string(num_gpus));
}
if (!resources.empty()) {
std::ostringstream oss;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this in a util function FormatResourcesArg?

num_cpus = config.num_cpus;
}
if (config.num_gpus > 0) {
num_gpus = config.num_gpus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a user wants to start a node with 0 CPUs or 0 GPUs? In Python we use None for default value, not 0.

std::ostringstream oss;
oss << "{";
for (auto iter = resources.begin(); iter != resources.end();) {
oss << "\"" << iter->first << "\":" << iter->second;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use nlohmann/json to generate the JSON? Concating raw strings is unsafe.

@raulchen raulchen merged commit e53aeca into ray-project:master Aug 12, 2021
Bam4d pushed a commit to Bam4d/ray that referenced this pull request Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants