uvipen / Super-mario-bros-PPO-pytorch

Proximal Policy Optimization (PPO) algorithm for Super Mario Bros
MIT License
1.07k stars 201 forks source link

OSError and EOFError2 #14

Open lvjinqiao opened 3 years ago

lvjinqiao commented 3 years ago

I learned to use your code on windows, but encountered the problem of oserror and eoferror. I checked it env.py I don't think the following paragraph is meaningful. Would you please explain the meaning of this code? Because my mother tongue is not English, can you understand what I mean??

#     for index in range(num_envs):
#
#         process = mp.Process(target=self.run, args=(index,))
#         process.start()
#
#         # self.env_conns[index].close()
#
# def run(self, index):
#
#     # self.agent_conns[index].close()
#     while True:
#
#         request, action = self.env_conns[index].recv()
#         print(request,action)
#         if request == "step":
#             self.env_conns[index].send(self.envs[index].step(action.item()))
#         elif request == "reset":
#             self.env_conns[index].send(self.envs[index].reset())
#
#         else:
#             raise NotImplementedError
zhimakaimenxa commented 2 years ago

我碰到了相同的问题,这两句逻辑不对,运行报错,注释掉以后又会在reset函数里出错,

I learned to use your code on windows, but encountered the problem of oserror and eoferror. I checked it env.py I don't think the following paragraph is meaningful. Would you please explain the meaning of this code? Because my mother tongue is not English, can you understand what I mean??

#     for index in range(num_envs):
#
#         process = mp.Process(target=self.run, args=(index,))
#         process.start()
#
#         # self.env_conns[index].close()
#
# def run(self, index):
#
#     # self.agent_conns[index].close()
#     while True:
#
#         request, action = self.env_conns[index].recv()
#         print(request,action)
#         if request == "step":
#             self.env_conns[index].send(self.envs[index].step(action.item()))
#         elif request == "reset":
#             self.env_conns[index].send(self.envs[index].reset())
#
#         else:
#             raise NotImplementedError
yjh5246 commented 1 year ago

This problem does not occur when running Ubuntu, but it does on win10

Mumasr commented 1 year ago

I figure out what the problem is in win10 first, comment this two lines in env.py,you can‘t use pipe like this in window

self.env_conns[index].close()
....
self.agent_conns[index].close()

next, in env.py the class MultipleEnvironments create all envs in main process and try to access each single env in subprocess but the _LIB in nes_py can't share during processes because some share memory police in window,i guess. so, we should create each single env in each subprocess, in function run()