# Error creating RLPredictor using restored checkpoint

**URL:** <https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605>\
**Category:** RLlib\
**Created:** [December 9, 2022, 12:40am UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605 "2022-12-09T00:40:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![steff](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@steff](https://discuss.ray.io/u/steff)\
**Post date:** [December 9, 2022, 12:40am UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605/1 "2022-12-09T00:40:08Z")

</div>

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

- High: It blocks me to complete my task.

Hi experts.

Get the following error when restoring checkpoint for a DQN model using Ray 2.1.0:

Traceback (most recent call last):  
File “/home/stefan/PycharmProjects/RLProjects/rl\_offline\_trainer/inference\_app.py”, line 61, in   
predictor = RLPredictor.from\_checkpoint(checkpoint)  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/train/rl/rl\_predictor.py”, line 63, in from\_checkpoint  
policy = checkpoint.get\_policy(env)  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/train/rl/rl\_checkpoint.py”, line 42, in get\_policy  
return Policy.from\_checkpoint(checkpoint=self)[“default\_policy”]  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/rllib/policy/policy.py”, line 256, in from\_checkpoint  
policy\_state = pickle.load(f)  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/\_private/serialization.py”, line 89, in \_actor\_handle\_deserializer  
return ray.actor.ActorHandle.\_deserialization\_helper(serialized\_obj, outer\_id)  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/actor.py”, line 1281, in \_deserialization\_helper  
return worker.core\_worker.deserialize\_and\_register\_actor\_handle(  
File “python/ray/\_raylet.pyx”, line 2137, in ray.\_raylet.CoreWorker.deserialize\_and\_register\_actor\_handle  
File “python/ray/\_raylet.pyx”, line 2106, in ray.\_raylet.CoreWorker.make\_actor\_handle  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/\_private/function\_manager.py”, line 522, in load\_actor\_class  
actor\_class = self.\_load\_actor\_class\_from\_gcs(  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/\_private/function\_manager.py”, line 617, in \_load\_actor\_class\_from\_gcs  
class\_name = ensure\_str(class\_name)  
File “/home/stefan/anaconda3/envs/py38\_ray2.1/lib/python3.8/site-packages/ray/\_private/utils.py”, line 289, in ensure\_str  
assert isinstance(s, bytes)  
AssertionError

Use Ray Tune to execute several trials with option to save checkpoint at end using the following:

```
    # create tuner
    tuner = Tuner(

        # trainer
        trainer,

        # create tune configuration
        tune_config=self.create_tune_config(
            search_algo=search_algo,
            scheduler=scheduler
        ),

        # hyper-parameters
        param_space=self.create_param_space(),

        # specify run configuration
        run_config=RunConfig(
            stop=dict(training_iteration=2),
            checkpoint_config=CheckpointConfig(checkpoint_at_end=True),
            verbose=3
        )
    )

    # run trials
    result_grid = tuner.fit()

```

Recreate best checkpoint and use it to create RLPredictor at which point the above error occurs:

```
    # recreate checkpoint
    checkpoint = Checkpoint.from_directory(path=checkpoint_path)

    # create RLPredictor from checkpoint - errors occurs when this executes
    predictor = RLPredictor.from_checkpoint(checkpoint)

```

From what I can tell the checkpoint folder contains all necessary artifacts. What am I doing wrong?

Thanks.  
Stefan

---

<div class="post-metadata">

**Author:** ![arturn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arturn/32/2096_2.png) [@arturn](https://discuss.ray.io/u/arturn)\
**Post date:** [December 15, 2022, 9:04am UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605/2 "2022-12-15T09:04:08Z")

</div>

Hi @steff,

The code looks good. Could you turn this into a GH issue with a complete repro script?

Cheers

---

<div class="post-metadata">

**Author:** ![steff](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@steff](https://discuss.ray.io/u/steff)\
**Post date:** [December 15, 2022, 9:57pm UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605/3 "2022-12-15T21:57:30Z")

</div>

Sure. Is there a web page that describes the steps?

---

<div class="post-metadata">

**Author:** ![arturn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arturn/32/2096_2.png) [@arturn](https://discuss.ray.io/u/arturn)\
**Post date:** [December 16, 2022, 8:53am UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605/4 "2022-12-16T08:53:16Z")

</div>

Hi @steff ,

Nothing special, I can write the steps down:

- Go to official ray repo
- Click issues, create issue
- Fill out form, include repro script and probably description of what you expected to happen vs was is happing
- Post link here for reference

---

<div class="post-metadata">

**Author:** ![jwlarocque](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jwlarocque/32/4122_2.png) [@jwlarocque](https://discuss.ray.io/u/jwlarocque)\
**Post date:** [March 28, 2023, 6:20pm UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605/5 "2023-03-28T18:20:43Z")

</div>

Hey @steff, I have the same problem in 2.3.1, did you end up creating an issue for this or finding a resolution?

---

<div class="post-metadata">

**Author:** ![steff](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@steff](https://discuss.ray.io/u/steff)\
**Post date:** [April 2, 2023, 3:58pm UTC](https://discuss.ray.io/t/error-creating-rlpredictor-using-restored-checkpoint/8605/6 "2023-04-02T15:58:32Z")

</div>

Created an issue for this. Here is the link: [Cannot create RLPredictor using restored checkpoint in different Ray session · Issue #33995 · ray-project/ray · GitHub](https://github.com/ray-project/ray/issues/33995)
