Ray does not provide resource isolation (CPU or memory) between user actors or tasks by default. The resource requirements (e.g., num_cpus, memory) specified for actors and tasks are logical and only used for scheduling; Ray does not enforce physical resource isolation or limit actual usage. This means actors can use more CPU or memory than requested, and Ray does not prevent oversubscription or provide isolation at the process level for user code. The enable_resource_isolation option (using cgroupv2) is designed to reserve resources for Ray system processes, not for isolating user actors or tasks from each other. According to the documentation, “Ray doesn’t provide CPU isolation for tasks or actors” and “resource requirements of tasks or actors do NOT impose limits on actual physical resource usage”—resource isolation is only enforced for Ray system processes if enabled, not for user workloads (Ray resources documentation, Ray worker.py).
If you need true resource isolation between user actors, you must use external mechanisms such as running Ray workers in containers with resource limits, or manually setting CPU affinity and memory limits using OS-level tools (e.g., cgroups, sched_setaffinity). There is ongoing work and discussion in the Ray community about improving resource isolation for user processes, but as of now, it is not natively supported (Ray discourse, Ray GitHub issue).
Would you like more detail or example code for using external isolation mechanisms?
Sources:
- Ray resources documentation
- Ray worker.py
- Ray discourse: Ray actor CPU affinity
- Ray GitHub issue: Native CPU affinity support for accelerators
Hint: Mention @RunLLM in the post for followups.