Farama-Foundation / D4RL-Evaluations

Apache License 2.0
187 stars 27 forks source link

Socket object in the snapshot ? #6

Closed Thibaud-Ardoin closed 4 years ago

Thibaud-Ardoin commented 4 years ago

Hello,

Thank you for the work on this code. I try to train a Offline RL agent on flow, but I'm unable to save the model, I get the following error :

Traceback (most recent call last): File "examples/bear_hdf5_d4rl.py", line 205, in <module> experiment(variant) File "examples/bear_hdf5_d4rl.py", line 149, in experiment algorithm.train() File "/home/tibo/Documents/Prog/Git/d4rl/d4rl_evaluations/bear/rlkit/core/rl_algorithm.py", line 46, in train self._train() File "/home/tibo/Documents/Prog/Git/d4rl/d4rl_evaluations/bear/rlkit/core/batch_rl_algorithm.py", line 176, in _train self._end_epoch(epoch) File "/home/tibo/Documents/Prog/Git/d4rl/d4rl_evaluations/bear/rlkit/core/rl_algorithm.py", line 57, in _end_epoch logger.save_itr_params(epoch, snapshot) File "/home/tibo/Documents/Prog/Git/d4rl/d4rl_evaluations/bear/rlkit/core/logging.py", line 288, in save_itr_params torch.save(params, file_name) File "/home/tibo/.local/lib/python3.7/site-packages/torch/serialization.py", line 370, in save _legacy_save(obj, opened_file, pickle_module, pickle_protocol) File "/home/tibo/.local/lib/python3.7/site-packages/torch/serialization.py", line 442, in _legacy_save pickler.dump(obj) File "/usr/lib/python3.7/socket.py", line 192, in __getstate__ raise TypeError("Cannot serialize socket object") TypeError: Cannot serialize socket object

I guess it mean there is a socket object in the saved snapshot, but I can't figure out what's wrong. Also, what would be a good way to visualize the results of the model in the simulation ?

Thanks for the help, Best,

Tibo

Thibaud-Ardoin commented 4 years ago

It turns out the flow env is the problem, it shouldn't be save with pickle as it uses sockets to communicates with the Sumo simulation.