# How to improve the utilization of gpu by change the trainer config

**URL:** https://discuss.ray.io/t/how-to-improve-the-utilization-of-gpu-by-change-the-trainer-config/3134
**Category:** RLlib
**Created:** [August 5, 2021, 9:20am UTC](https://discuss.ray.io/t/how-to-improve-the-utilization-of-gpu-by-change-the-trainer-config/3134 "2021-08-05T09:20:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![weileze](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/weileze/32/1057_2.png) [@weileze](https://discuss.ray.io/u/weileze)
#### Post date: [August 5, 2021, 9:20am UTC](https://discuss.ray.io/t/how-to-improve-the-utilization-of-gpu-by-change-the-trainer-config/3134/1 "2021-08-05T09:20:41Z")

</div>

i know ppo cost most time in sample collected, so i need more cpu kernel.  
so how to edit the config make my train more quick by the machine right now？  
my config:

```auto
    config = {
        "batch_mode": "truncate_episodes",
        "num_envs_per_worker": 1,
        "num_gpus": 1,
        "num_sgd_iter": 10,
        "num_workers": 16,
        "observation_filter": "NoFilter",
        "sgd_minibatch_size": 500,
        "train_batch_size": 10000,
        # "lr": 0.0001,

        "lambda": 0.95,
        "clip_param": 0.1,
        "entropy_coeff": 0.01,
        "env": CalendarSpreadArbitrage,
        "env_config": {
            "symbol": symbol,
            "commission": commission,
            "period": period,
            "train": True
        },
    }

    trainer = ppo.PPOTrainer(config=config)

```

gpu info:

 ![微信截图_20210805172013](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/f/f2f477612b7309dda236b298771ce39da30e1be9.png)

---

<div class="post-metadata">

### Author: ![michaelzhiluo](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@michaelzhiluo](https://discuss.ray.io/u/michaelzhiluo)
#### Post date: [August 5, 2021, 9:44am UTC](https://discuss.ray.io/t/how-to-improve-the-utilization-of-gpu-by-change-the-trainer-config/3134/2 "2021-08-05T09:44:53Z")

</div>

It is better to use `gpustat` to check on GPU utilization: [GitHub - wookayin/gpustat: 📊 A simple command-line utility for querying and monitoring GPU status](https://github.com/wookayin/gpustat)

If you keep CPU constant, you can utilize GPU more often if you increase `num_sgd_iter` (more gradient steps) and decrease `sgd_minibatch_size`. You can also increase data collection per worker by increasing `num_envs_per_worker`, which represents how many environments there are per worker (vectorized).

---

<div class="post-metadata">

### Author: ![weileze](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/weileze/32/1057_2.png) [@weileze](https://discuss.ray.io/u/weileze)
#### Post date: [August 5, 2021, 3:30pm UTC](https://discuss.ray.io/t/how-to-improve-the-utilization-of-gpu-by-change-the-trainer-config/3134/3 "2021-08-05T15:30:08Z")

</div>

Thank you

I’ll try it out.
