ZedongPeng / SCM-DRL

2 stars 1 forks source link

AttributeError: Can't pickle local object 'main.<locals>.train_func' #1

Closed sunjing1102628 closed 3 years ago

sunjing1102628 commented 3 years ago

Sorry for my disturbing. When I run the "SCM-DRL" source code, I have met some errors. The errors are as follows: "Running experiment with seed 1 Traceback (most recent call last): File "/Users/sunjing/PycharmProjects/Q_learning1118/SCL_DRL20210320/pg3.py", line 799, in main() File "/Users/sunjing/PycharmProjects/Q_learning1118/SCL_DRL20210320/pg3.py", line 789, in main p.start() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 283, in _Popen return Popen(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'main..train_func' ". Why can't it pickle train_func()? I will be appreciated your early reply. Thanks and looking forward to your early reply.

ZedongPeng commented 3 years ago

I think it's a problem related to your python environment.

The Policy Gradient code in this repo is based on SPINNING's VPG implementation. https://github.com/openai/spinningup/blob/master/spinup/algos/tf1/vpg/vpg.py

You can first check if the SPINNING's VPG code goes well in your environment.

sunjing1102628 commented 3 years ago

Dear Dr. Zedong,

Thanks for your early reply. I will check the python environment according to your suggestions.

Best regards, Jing

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: @.> Sent: Monday, 29 March 2021 3:48 pm To: @.> Cc: Sun @.>; @.> Subject: Re: [ZedongPeng/SCM-DRL] AttributeError: Can't pickle local object 'main..train_func' (#1)

I think it's a problem related to your python environment.

The Policy Gradient code in this repo is based on SPINNING's VPG implementation. https://github.com/openai/spinningup/blob/master/spinup/algos/tf1/vpg/vpg.py

You can first check if the SPINNING's VPG code goes well in your environment.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ZedongPeng/SCM-DRL/issues/1#issuecomment-809154554, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOTVZDMHI7KIRG467YW6GA3TGAWF5ANCNFSM4Z52ZSBA.


CONFIDENTIALITY: This email is intended solely for the person(s) named and may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us and do not copy, use, or disclose its contents. Towards a sustainable earth: Print only when necessary. Thank you.

ZedongPeng commented 3 years ago

I am not sure if your computing environment supports multiprocessing. If not, I'd suggest you remove the multiprocessing code and run it using a single thread.

ZedongPeng commented 3 years ago

FYI, the multiprocessing code is based on here. https://github.com/berkeleydeeprlcourse/homework/blob/master/hw2/train_pg_f18.py

sunjing1102628 commented 3 years ago

Dear Dr. Zedong Peng,

Sorry for my disturbing again. Since the “train_func” function based on the “train_PG” function, so I run the “train_PG” function in the main function. However, I have met some new errors as follows. I have found the error location in the “supply_distribution” which said that the episode length is zero when update demand. Is there anything wrong when I check the functions? Could you give me some suggestions to run these functions? Thanks and looking forward to your early reply.

Best regards, Jing @.***D724D0.B0B0C010]

@.***D724D0.C70F86C0]

@.***D724D1.DA2658F0] Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: @.> Sent: Monday, 29 March 2021 4:04 pm To: @.> Cc: Sun @.>; @.> Subject: Re: [ZedongPeng/SCM-DRL] AttributeError: Can't pickle local object 'main..train_func' (#1)

FYI, the multiprocessing code is based on here. https://github.com/berkeleydeeprlcourse/homework/blob/master/hw2/train_pg_f18.py

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ZedongPeng/SCM-DRL/issues/1#issuecomment-809165040, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOTVZDKY4XXSINZCJ5VDGRLTGAX6RANCNFSM4Z52ZSBA.


CONFIDENTIALITY: This email is intended solely for the person(s) named and may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us and do not copy, use, or disclose its contents. Towards a sustainable earth: Print only when necessary. Thank you.