Skip to content

Problems with workers when using custom Gym/Reacher Environment #2330

@Suli1223

Description

@Suli1223

Hi

I implemented a customized version of the gym reacher environment - actually using an aditional parameter (cameras) for rendering in multiple camera perspectives. I also wrapped the environment with GymEnv
This works in general fine, but I run into problems when using multiple workers (with LocalSampler). As far as I understand for splitting the work on multiple workers, multiple environments are generated. Unfortunately then my environments are not built correctly anymore - it seems not able to handle the custom parameter - does anyone know any help?

File "/home/name/Desktop/launch_script_reacher.py", line 86, in <module>
    run_my_reacher(mode="rgb_array",iterations=10)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/site-packages/garage/experiment/experiment.py", line 369, in __call__
    result = self.function(ctxt, **kwargs)
  File "/home/name/Desktop/my_folder/launch_reacher.py", line 53, in run_my_reacher
    worker_class=worker_with_disc)
  File "/home/name/Desktop/my_folder/helper/own_local_sampler.py", line 154, in __init__
    worker_class=worker_class,worker_args=worker_args
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/site-packages/garage/sampler/local_sampler.py", line 79, in __init__
    envs, preprocess=copy.deepcopy)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/site-packages/garage/sampler/worker_factory.py", line 95, in prepare_worker_messages
    return [preprocess(objs) for _ in range(self.n_workers)]
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/site-packages/garage/sampler/worker_factory.py", line 95, in <listcomp>
    return [preprocess(objs) for _ in range(self.n_workers)]
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/copy.py", line 169, in deepcopy
    rv = reductor(4)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/site-packages/garage/envs/gym_env.py", line 353, in __getstate__
    state = copy.deepcopy(self.__dict__)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/copy.py", line 241, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/copy.py", line 283, in _reconstruct
    y.__setstate__(state)
  File "/home/name/anaconda3/envs/my_env/lib/python3.7/site-packages/gym/utils/ezpickle.py", line 26, in __setstate__
    out = type(self)(*d["_ezpickle_args"], **d["_ezpickle_kwargs"])
TypeError: __init__() missing 1 required positional argument: 'cameras'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions