Skip to content

Commit

Permalink
Ramanuzan/multiprocessing issue (#33)
Browse files Browse the repository at this point in the history
* update cumtom_dict can be pickled

* update qsize -> empty, full

* update ray 1.7.0 -> 1.8.0 to supports Windows

* remove _nomp.py

* update docs and readme

Co-authored-by: kakao_ent <kakao_ent@kakao-entui-MacBookPro.local>
  • Loading branch information
ramanuzan and kakao_ent authored Nov 6, 2021
1 parent fa9564c commit 1d85e72
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 141 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ Hello Wo**RL**d!!:hand: **Join Our Reinforcement Learning framework for Develop
- Distributed RL algorithms are provided using [ray](https://github.com/ray-project/ray)
- Benchmark of the algorithms is conducted in many RL environment

## :exclamation:Notification
## :heavy_check_mark: Tested

Currently, JORLDY is pre-release version. It supports Linux only, but all the scripts can be run on Windows and Mac in the following ways.
- Windows: Docker or WSL
- Mac: Docker

However, you can use only (single, sync_distributed)_train_nomp.py and eval.py on a local environment in Windows and Mac. We will address these issues as soon as possible.

**\* (single, sync_distributed)_train_nomp.py: these scripts don't use multiprocessing library. In detail, the manage process is included in the main process. So it can be a bit slow.**
| Python | Windows | Mac | Linux |
| :----: | :---------: | :-----: | :------: |
| 3.8 | :heavy_check_mark: | :heavy_check_mark: | WSL, Ubuntu 18.04 |

## :arrow_down: Installation

Expand Down
1 change: 0 additions & 1 deletion docs/How_to_use.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- sync_distributed_train.py: train with sychronous distributed setting.
- async_distributed_train.py: train with asychronous distributed setting.
- eval.py: evaluate with trained agent.
- (single, sync_distributed)_train_nomp.py: this scripts don't use multiprocessing library. In detail, the manage process is included in the main process. So it can be a bit slow.
if you want to know the specific process of each script, please refer to [Distributed Architecture](./Distributed_Architecture.md)

## How to Check Implemented List
Expand Down
4 changes: 2 additions & 2 deletions jorldy/async_distributed_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if config.train.distributed_batch_size:
agent_config["batch_size"] = config.train.distributed_batch_size

trans_queue = mp.Queue()
trans_queue = mp.Queue(10)
interact_sync_queue = mp.Queue(1)
result_queue = mp.Queue()
manage_sync_queue = mp.Queue(1)
Expand Down Expand Up @@ -58,7 +58,7 @@
step, _step, print_stamp, save_stamp = 0, 0, 0, 0
while step < config.train.run_step:
transitions = []
while (_step == 0 or trans_queue.qsize() > 0) and\
while (_step == 0 or not trans_queue.empty()) and\
(_step - step < config.train.update_period):
_step, _transitions = trans_queue.get()
transitions += _transitions
Expand Down
6 changes: 6 additions & 0 deletions jorldy/manager/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class CustomDict(dict):
def __init__(self, init_dict={}):
self.update(init_dict)

def __getstate__(self):
return self.__dict__

def __setstate__(self, d):
self.__dict__.update(d)

def type_cast(var):
try:
return int(var)
Expand Down
6 changes: 3 additions & 3 deletions jorldy/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def interact_process(DistributedManager, distributed_manager_config,
delta_t = len(transitions) / num_workers
step += delta_t
trans_queue.put((int(step), transitions))
if sync_queue.qsize() > 0:
if sync_queue.full():
distributed_manager.sync(sync_queue.get())
while trans_queue.qsize() == 10:
while trans_queue.full():
time.sleep(0.1)
except Exception as e:
traceback.print_exc()
Expand All @@ -39,7 +39,7 @@ def manage_process(Agent, agent_config,
try:
while step < run_step:
wait = True
while wait or result_queue.qsize() > 0:
while wait or not result_queue.empty():
_step, result = result_queue.get()
metric_manager.append(result)
wait = False
Expand Down
66 changes: 0 additions & 66 deletions jorldy/single_train_nomp.py

This file was deleted.

60 changes: 0 additions & 60 deletions jorldy/sync_distributed_train_nomp.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
torch==1.8.1
tensorboard==2.5.0
ray==1.7.0
ray==1.8.0
opencv-python==4.5.2.52
pygifsicle==1.0.4
gym==0.21.0
Expand Down

0 comments on commit 1d85e72

Please # to comment.