# Load agent without starting an env or creating multiple workers

**URL:** <https://discuss.ray.io/t/load-agent-without-starting-an-env-or-creating-multiple-workers/5555>\
**Category:** RLlib\
**Created:** [March 26, 2022, 12:40pm UTC](https://discuss.ray.io/t/load-agent-without-starting-an-env-or-creating-multiple-workers/5555 "2022-03-26T12:40:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedetask](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/fedetask/32/2233_2.png) [@fedetask](https://discuss.ray.io/u/fedetask)\
**Post date:** [March 26, 2022, 12:40pm UTC](https://discuss.ray.io/t/load-agent-without-starting-an-env-or-creating-multiple-workers/5555/1 "2022-03-26T12:40:56Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

I want to load a trained agent to use its `compute_action()` method. To do this, I am loading the trainer and calling `trainer = tune.registry.get_trainable_cls(class_name)(config=config)` with `config` loaded from `params.pkl` saved in the agent directory. However, this does several unnecessary things that I do not want to happen, such as starting local and remote workers, each one starting an environment (which is what happens during training).

How can I use the `compute_action()` method without all this additional overhead? Should I load the agent differently?

---

<div class="post-metadata">

**Author:** ![Lars\_Simon\_Zehnder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/lars_simon_zehnder/32/1185_2.png) [@Lars\_Simon\_Zehnder](https://discuss.ray.io/u/Lars_Simon_Zehnder)\
**Post date:** [March 28, 2022, 10:01pm UTC](https://discuss.ray.io/t/load-agent-without-starting-an-env-or-creating-multiple-workers/5555/2 "2022-03-28T22:01:12Z")

</div>

Hi @fedetask,

as you want to load a trained agent, you surely want to load a checkpoint (see the [documentation](https://docs.ray.io/en/latest/rllib/rllib-training.html#basic-python-api)):

```auto
agent = ppo.PPOTrainer(config=config, env=env_class)
agent.restore(checkpoint_path)

```

Then you have the agent and can use it to compute actions:

```auto
action = agent.compute_action(obs)

```
