Load checkpoint from tune experiment when using custom environment not registered

  • High: It blocks me to complete my task.

I’m having some trouble loading a checkpoint generated from a tune experiment. The problem is I introduced the custom environment class without registering it, such as in the example below:

config_PPO = (
    PPOConfig()
    .environment(
        HRROenv,
        env_config={
            'membrane': Membrane().membrane_xus180808_double(),
            'solution': Solution(),
            'design': DesignParameters.Nijhuis_BIA(),
            'operation': OperationParameters()
        }
    )

I’m getting some error message related to eager mode from tensorflow, but it is most certainly because the environment cannot be found. Is there any workaround to load the checkpoint? What is the easiest approach to achieve it?

Hi @Ciro_NA ,

how do you try to load the checkpoint? WIth Algorithm.load_from_checkpoint()?

Hi @Lars_Simon_Zehnder,

Probably you meant Algorithm.from_checkpoint(). Yes, I’m using it. I also checked the dict that gathers the info to load all the information. The env key has the value <class ‘hrro_env_norm.HRROenv’>. I tried to register the environment with this name, but it’s not working. The ray version I’m using is 2.3.

Still early in the morning :slight_smile:

I would have thought that importing the environment would work already, but I guess you already do this.

Sure, I’m importing the environment too. The error message is: ‘tf.enable_eager_execution must be called at program setup’. The original config had eager_tracing = True.

This you could overcome by

from ray.rllib.utils.framework import try_import_tf

_, tf, _ = try_import_tf()
tf.enable_eager_execution()

You are right, it works. Thank you @Lars_Simon_Zehnder

1 Like

Alright, this might be a default thing in the library. Probably, TF1 needs to have eager execution enabled:

from ray.rllib.utils.framework import try_import_tf

tf1, tf, _ = try_import_tf()
tf1.enable_eager_execution()