提交 c5a8c2ba 编写于 作者: H Hongsheng Zeng 提交者: Bo Zhou

fix paddle version bug; refine scripts (#186)

上级 7173368e
...@@ -6,7 +6,7 @@ The **PARL** team gets the first place in NeurIPS reinforcement learning competi ...@@ -6,7 +6,7 @@ The **PARL** team gets the first place in NeurIPS reinforcement learning competi
## Dependencies ## Dependencies
- python3.6 - python3.6
- [paddlepaddle==1.5.2](https://github.com/PaddlePaddle/Paddle) - [paddlepaddle==1.5.1](https://github.com/PaddlePaddle/Paddle)
- [parl>=1.2.1](https://github.com/PaddlePaddle/PARL) - [parl>=1.2.1](https://github.com/PaddlePaddle/PARL)
- [osim-rl==3.0.11](https://github.com/stanfordnmbl/osim-rl) - [osim-rl==3.0.11](https://github.com/stanfordnmbl/osim-rl)
......
...@@ -22,9 +22,10 @@ import numpy as np ...@@ -22,9 +22,10 @@ import numpy as np
from actor import Actor from actor import Actor
from opensim_model import OpenSimModel from opensim_model import OpenSimModel
from opensim_agent import OpenSimAgent from opensim_agent import OpenSimAgent
from parl.utils import logger, ReplayMemory, tensorboard from parl.utils import logger, ReplayMemory, tensorboard, get_gpu_count
from parl.utils.window_stat import WindowStat from parl.utils.window_stat import WindowStat
from parl.remote.client import get_global_client from parl.remote.client import get_global_client
from parl.utils import machine_info
from shutil import copy2 from shutil import copy2
ACT_DIM = 22 ACT_DIM = 22
...@@ -62,6 +63,15 @@ class ActorState(object): ...@@ -62,6 +63,15 @@ class ActorState(object):
class Evaluator(object): class Evaluator(object):
def __init__(self, args): def __init__(self, args):
if machine_info.is_gpu_available():
assert get_gpu_count() == 1, 'Only support training in single GPU,\
Please set environment variable: `export CUDA_VISIBLE_DEVICES=[GPU_ID_TO_USE]` .'
else:
cpu_num = os.environ.get('CPU_NUM')
assert cpu_num is not None and cpu_num == '1', 'Only support training in single CPU,\
Please set environment variable: `export CPU_NUM=1`.'
model = OpenSimModel(OBS_DIM, VEL_DIM, ACT_DIM) model = OpenSimModel(OBS_DIM, VEL_DIM, ACT_DIM)
algorithm = parl.algorithms.DDPG( algorithm = parl.algorithms.DDPG(
model, model,
......
...@@ -20,7 +20,7 @@ def get_args(): ...@@ -20,7 +20,7 @@ def get_args():
parser.add_argument( parser.add_argument(
'--cluster_address', '--cluster_address',
default='localhost:8081', default='localhost:8010',
type=str, type=str,
help='cluster address of xparl.') help='cluster address of xparl.')
parser.add_argument( parser.add_argument(
......
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python evaluate.py --actor_num 160 \ python evaluate.py --actor_num 160 \
--difficulty 1 \ --difficulty 1 \
--penalty_coeff 3.0 \ --penalty_coeff 3.0 \
......
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python evaluate.py --actor_num 160 \ python evaluate.py --actor_num 160 \
--difficulty 2 \ --difficulty 2 \
--penalty_coeff 5.0 \ --penalty_coeff 5.0 \
......
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python evaluate.py --actor_num 160 \ python evaluate.py --actor_num 160 \
--difficulty 3 \ --difficulty 3 \
--vel_penalty_coeff 3.0 \ --vel_penalty_coeff 3.0 \
......
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python evaluate.py --actor_num 160 \ python evaluate.py --actor_num 160 \
--difficulty 3 \ --difficulty 3 \
--vel_penalty_coeff 3.0 \ --vel_penalty_coeff 3.0 \
......
...@@ -4,6 +4,9 @@ if [ $# != 1 ]; then ...@@ -4,6 +4,9 @@ if [ $# != 1 ]; then
exit 0 exit 0
fi fi
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python train.py --actor_num 300 \ python train.py --actor_num 300 \
--difficulty 1 \ --difficulty 1 \
--penalty_coeff 3.0 \ --penalty_coeff 3.0 \
......
...@@ -3,6 +3,9 @@ if [ $# != 1 ]; then ...@@ -3,6 +3,9 @@ if [ $# != 1 ]; then
exit 0 exit 0
fi fi
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python train.py --actor_num 300 \ python train.py --actor_num 300 \
--difficulty 2 \ --difficulty 2 \
--penalty_coeff 5.0 \ --penalty_coeff 5.0 \
......
...@@ -3,6 +3,9 @@ if [ $# != 1 ]; then ...@@ -3,6 +3,9 @@ if [ $# != 1 ]; then
exit 0 exit 0
fi fi
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python train.py --actor_num 300 \ python train.py --actor_num 300 \
--difficulty 3 \ --difficulty 3 \
--vel_penalty_coeff 3.0 \ --vel_penalty_coeff 3.0 \
......
...@@ -3,6 +3,9 @@ if [ $# != 1 ]; then ...@@ -3,6 +3,9 @@ if [ $# != 1 ]; then
exit 0 exit 0
fi fi
# use which GPU
export CUDA_VISIBLE_DEVICES=0
python train.py --actor_num 300 \ python train.py --actor_num 300 \
--difficulty 3 \ --difficulty 3 \
--vel_penalty_coeff 3.0 \ --vel_penalty_coeff 3.0 \
......
...@@ -22,9 +22,10 @@ import numpy as np ...@@ -22,9 +22,10 @@ import numpy as np
from actor import Actor from actor import Actor
from opensim_model import OpenSimModel from opensim_model import OpenSimModel
from opensim_agent import OpenSimAgent from opensim_agent import OpenSimAgent
from parl.utils import logger, ReplayMemory, tensorboard from parl.utils import logger, ReplayMemory, tensorboard, get_gpu_count
from parl.utils.window_stat import WindowStat from parl.utils.window_stat import WindowStat
from parl.remote.client import get_global_client from parl.remote.client import get_global_client
from parl.utils import machine_info
ACT_DIM = 22 ACT_DIM = 22
VEL_DIM = 19 VEL_DIM = 19
...@@ -68,6 +69,15 @@ class ActorState(object): ...@@ -68,6 +69,15 @@ class ActorState(object):
class Learner(object): class Learner(object):
def __init__(self, args): def __init__(self, args):
if machine_info.is_gpu_available():
assert get_gpu_count() == 1, 'Only support training in single GPU,\
Please set environment variable: `export CUDA_VISIBLE_DEVICES=[GPU_ID_TO_USE]` .'
else:
cpu_num = os.environ.get('CPU_NUM')
assert cpu_num is not None and cpu_num == '1', 'Only support training in single CPU,\
Please set environment variable: `export CPU_NUM=1`.'
model = OpenSimModel(OBS_DIM, VEL_DIM, ACT_DIM) model = OpenSimModel(OBS_DIM, VEL_DIM, ACT_DIM)
algorithm = parl.algorithms.DDPG( algorithm = parl.algorithms.DDPG(
model, model,
......
...@@ -20,7 +20,7 @@ def get_args(): ...@@ -20,7 +20,7 @@ def get_args():
parser.add_argument( parser.add_argument(
'--cluster_address', '--cluster_address',
default='localhost:8081', default='localhost:8010',
type=str, type=str,
help='cluster address of xparl.') help='cluster address of xparl.')
parser.add_argument( parser.add_argument(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册