并行训练中Actor访问不到模块
Created by: Termset
程序在一个强化学习环境(MaCA)的train/abc/下,在该环境的根目录下面执行程序。 environment/:推演环境 interface.py:环境调用接口 agent/:用于存储封装好的可直接调用的智能体决策代码,每个决策代码可单独设立一个文件夹,按照标准封装,系统直接调用 fix_rule/:基于规则的同构异构对抗决策算法 fix_rule_no_att/:基于规则的同构异构对抗决策算法(无攻击能力) simple/:基于DQN的同构对抗决策示例算法,需使用pytorch obs_construct/:观测值组织形式自定义,开发者可根据算法需要自定义obs结构 simple/:基于DQN的同构对抗决策示例对应的obs组织 fight_mp.py:对抗调度程序 replay.py 日志回放入口程序 maps/:对抗场景库 1000_1000_2_10_vs_2_10.map:预置异构对抗场景 1000_1000_fighter10v10.map:预置同构对抗场景 configuration/:配置数据 reward.py:部分预置回报检查点的赋值 system.py:部分系统推演规则定义 train/:决策算法训练所在路径 simple/:simple决策模型训练代码
Actor部分程序如下:
from train.abc.maca_agent import MaCA_Agent
from train.abc.env_construct import env_construct
@parl.remote_class
class Actor(object):
def __init__(self, config):
self.config = config
self.envs = []
for _ in range(config['env_num']):
# config['blue'] = blue_agent.get_obs_ind()
env = Environment(config['map_path'], config['red_get_obs_ind'], config['blue_get_obs_ind'],
max_step=config['max_step'],
random_pos=config['random_pos'],
render=config['render'])
env = env_construct(env)
self.red_fighter_num = env.red_fighter_num
env = MonitorEnv(env)
self.envs.append(env)
单独运行Actor也是正常的,进行训练时会报错No module named 'train'
[07-12 22:19:50 MainThread @machine_info.py:86] nvidia-smi -L found gpu count: 1
[07-12 22:19:50 MainThread @machine_info.py:86] nvidia-smi -L found gpu count: 1
[07-12 22:19:50 MainThread @main.py:157] Waiting for 1 remote actors to connect.
[07-12 22:19:50 MainThread @main.py:161] Remote actor count: 1
Exception in thread Thread-4:
Traceback (most recent call last):
File "/home/xtq/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/xtq/anaconda3/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "train/abc/main.py", line 172, in run_remote_sample
remote_actor = Actor(self.config)
File "/home/xtq/anaconda3/lib/python3.6/site-packages/parl/remote/remote_decorator.py", line 127, in __init__
raise RemoteError('__init__', traceback_str)
parl.remote.exceptions.RemoteError: [PARL remote error when calling function `__init__`]:
No module named 'train'
traceback:
Traceback (most recent call last):
File "/home/xtq/anaconda3/lib/python3.6/site-packages/parl/remote/job.py", line 298, in wait_for_connection
cls = cloudpickle.loads(message[1])
ModuleNotFoundError: No module named 'train'
这个@parl.remote_class修饰的类,访问模块有什么特殊的吗?