Skip to content

Commit

Permalink
Merge pull request #145 from ikki407/feature/pickle_model_send_data
Browse files Browse the repository at this point in the history
Fix: `unable to open shared memory object` error in multiprocessing
  • Loading branch information
ikki407 authored Mar 5, 2021
2 parents 6c9750c + 6929e4b commit b5452de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion handyrl/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def server(self):
except:
# return latest model if failed to load specified model
pass
send_data.append(model)
send_data.append(pickle.dumps(model))

if not multi_req and len(send_data) == 1:
send_data = send_data[0]
Expand Down
3 changes: 2 additions & 1 deletion handyrl/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from socket import gethostname
from collections import deque
import multiprocessing as mp
import pickle

from .environment import prepare_env, make_env
from .connection import QueueCommunicator
Expand Down Expand Up @@ -47,7 +48,7 @@ def _gather_models(self, model_ids):
model_pool[model_id] = self.latest_model[1]
else:
# get model from server
model_pool[model_id] = send_recv(self.conn, ('model', model_id))
model_pool[model_id] = pickle.loads(send_recv(self.conn, ('model', model_id)))
# update latest model
if model_id > self.latest_model[0]:
self.latest_model = model_id, model_pool[model_id]
Expand Down

0 comments on commit b5452de

Please sign in to comment.