question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default actor resources

See original GitHub issue

What is the problem?

Ray documentation clearly indicates that by default, when not specified explicitly, ray actors will use 1 cpu resource (https://docs.ray.io/en/master/actors.html#resources-with-actors). However it seems like the default is actually 0.

Ray version and other system information (Python version, TensorFlow version, OS): I saw this behavior on Ray 0.8.4, 1.0.0, 1.1.0, and 2.0.0dev.
I’m using Python 3.7.1 and 3.8.5 on Ubuntu 16.04.

Reproduction (REQUIRED)

import ray
ray.init(num_cpus=1)

@ray.remote
class foo:
    def f(self):
        return 1

a = foo.remote()
b = foo.remote()     # There should not be enough resources for this
print (ray.get(a.f.remote()))
print (ray.get(b.f.remote()))    # This should fail (block indefinitely)

Based on the documentation, I would expect that there would be a warning that an actor could not be scheduled and is pending , and the second ray.get will block forever. However, this is not the case – code terminates, showing both actors were constructed even though total cpu resources was limited to 1.

In contrast, with explicit num_cpus parameter, the code behaves as expected.

import ray
ray.init(num_cpus=1)

@ray.remote(num_cpus=1)
class foo:
    def f(self):
        return 1

a = foo.remote()
b = foo.remote()     # There should not be enough resources for this
print (ray.get(a.f.remote()))
print (ray.get(b.f.remote()))    # This should fail (block indefinitely)
  • I have verified my script runs in a clean environment and reproduces the issue.
  • I have verified the issue also occurs with the latest wheels.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
wuisawesomecommented, Feb 3, 2021

Yeah this is a little subtle. ray.remote and ray.remote(num_cpus=1) are not the same. ray.remote means the actor uses CPUs whenever it runs anything (the constructor, a function, etc), but it frees the CPU when it’s not using it.

ray.remote(num_cpus=1) means it just always keeps the CPU.

The underlying actor creation task always requires a CPU, but hopefully as an end user, you don’t need to think about that :p

0reactions
wuisawesomecommented, Jul 8, 2021

We can close the issue then right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Actors — Ray 2.2.0
FAQ: Actors, Workers and Resources# · Tasks: When Ray starts on a machine, a number of Ray workers will be started automatically (1...
Read more >
Actor lifecycle - Documentation - Akka
An actor is a stateful resource that has to be explicitly started and stopped. It is important to note that actors do not...
Read more >
Actors | Unreal Engine 4.27 Documentation
Explanations of the basic gameplay elements, Actors and Objects. ... Actors all have the ability to be ticked by default via the Tick()...
Read more >
Custom Actor Implementations | Naninovel
— where id is the ID of the actor and metadata — either actor's (when actor record exists in the resources) or a...
Read more >
Actors | Foundry Virtual Tabletop
Default Sheet Configuration ... The Actor Sheet button ( ) allows you to set which sheet template you want to use for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found