# All ray resources mapped to only two physical processors

**URL:** <https://discuss.ray.io/t/all-ray-resources-mapped-to-only-two-physical-processors/13092>\
**Category:** Configure Algorithm, Training, Evaluation, Scaling\
**Created:** [December 8, 2023, 10:52am UTC](https://discuss.ray.io/t/all-ray-resources-mapped-to-only-two-physical-processors/13092 "2023-12-08T10:52:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ray\_is\_cool](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ray\_is\_cool](https://discuss.ray.io/u/ray_is_cool)\
**Post date:** [December 8, 2023, 10:52am UTC](https://discuss.ray.io/t/all-ray-resources-mapped-to-only-two-physical-processors/13092/1 "2023-12-08T10:52:02Z")

</div>

hi,

i am using ray 2.8.1 with a single agent rl environment, torch ModelV2 and PPO algorithm. my problem is the following:  
I can specify resources (cpu’s in this case) that ray is allowed to use in ray.init().  
I can specify resources in the PPOConfig, and if I understand correctly, that specifies the resources per trial, e.g. num\_cpus\_per\_worker and num\_cpus\_local\_worker.  
If I run a tune.Tuner(…).fit(), the resources specifications are respected, f.e. I set ray.init(num\_cpus=12), num\_cpus\_for\_local\_worker=4, num\_rollout\_workers=0, it runs, as expected, 3 trials in parallel. Another example, for ray.init(num\_cpus=12), num\_cpus\_for\_local\_worker=1, num\_rollout\_workers=1, num\_cpus\_per\_worker=1, it runs 6 trials in parallel.  
when I inspect the cpu usage with htop though, all trials are executet on the same two physical cores, splitting up the cpu% between each other (see picture)

 ![Bildschirmfoto 2023-12-08 um 11.45.15](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/a/a97e4de2ec1dbde81fc98db0d5bbe37ab938c9e0.png)

How can I configure ray tune to distribute the load on all available physical resources? or is this something I have to handle with the cluster people?

This is all configuration I’m doing, all the config\_files are related to the application itself. let me know if I should provide more info.

```auto
    ray.init(num_cpus=12)
    
    tune.register_env("CommunicationV1_env", lambda env_config: CommunicationV1_env(env_config))
    tunable_model_config = ...
    model = {"custom_model": GNN_PyG,
            "custom_model_config": tunable_model_config}

    # ppo config
    ppo_config = (
        PPOConfig()
        .environment(
            "CommunicationV1_env", # @todo: need to build wrapper
            env_config=env_config)
        .training(
            model=model,
            _enable_learner_api=False,
        )
        .rollouts(num_rollout_workers=0)
        .resources(
            num_cpus_per_worker=2,
            num_cpus_for_local_worker=4,
            placement_strategy="PACK",
        )
        .rl_module(_enable_rl_module_api=False)
    )

    # run and checkpoint config
    run_config = air.RunConfig(
        name=run_name,
        stop={"timesteps_total": tune_config["max_timesteps"]}
    )

    # tune config
    tune_config = tune.TuneConfig(
            num_samples=tune_config["num_samples"]
        )

    tuner = tune.Tuner(
        "PPO",
        run_config=run_config,
        tune_config=tune_config,
        param_space=ppo_config.to_dict()
    )

    tuner.fit()

```

---

<div class="post-metadata">

**Author:** ![lorenzopari](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@lorenzopari](https://discuss.ray.io/u/lorenzopari)\
**Post date:** [October 22, 2025, 5:54pm UTC](https://discuss.ray.io/t/all-ray-resources-mapped-to-only-two-physical-processors/13092/2 "2025-10-22T17:54:33Z")

</div>

Hi, did you manage to solve the problem? I’m having the same issue: cores 1 and 17 are at 100%, while the rest are idle.

---

<div class="post-metadata">

**Author:** ![RunLLM](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/runllm/32/8249_2.png) [@RunLLM](https://discuss.ray.io/u/RunLLM)\
**Post date:** [October 22, 2025, 5:55pm UTC](https://discuss.ray.io/t/all-ray-resources-mapped-to-only-two-physical-processors/13092/3 "2025-10-22T17:55:02Z")

</div>

This issue—where only a subset of CPU cores (e.g., cores 1 and 17) are fully utilized while others remain idle—often occurs when Ray tasks are not parallelized as expected, or when the underlying code is single-threaded or limited by environment variables controlling thread usage. In particular, if you are using libraries like PyTorch or NumPy, you may need to explicitly set the number of threads (e.g., with `torch.set_num_threads(num_cpus)`) to ensure all cores are used. Otherwise, Ray may schedule tasks across all CPUs, but the actual computation only uses a single core per task, leading to underutilization of the rest of the CPUs. This was confirmed as the root cause in a similar case, where setting `torch.set_num_threads(num_cpus)` resolved the issue on VMs, while leaving it at the default value caused only one core to be used despite Ray’s resource allocation settings. See the discussion for more details: [Usage of CPU resource on RayCluster GCloud](https://discuss.ray.io/t/usage-of-cpu-resource-on-raycluster-gcloud/15354).

Would you like a step-by-step guide on how to diagnose and fix this in your environment?

Sources:

- [Usage of CPU resource on RayCluster GCloud](https://discuss.ray.io/t/usage-of-cpu-resource-on-raycluster-gcloud/15354)

Hint: Mention @RunLLM in the post for followups.
