Stable_baseline3 PPO 获取“进程已完成,退出代码为 139”

分享于2022年07月17日 openai-gym reinforcement-learning stable-baselines 问答
【问题标题】:Stable_baseline3 PPO get "Process finished with exit code 139"Stable_baseline3 PPO 获取“进程已完成,退出代码为 139”
【发布时间】:2022-07-17 22:16:32
【问题描述】:

我使用 Stable_baseline3.PPO 在 Highway-fast-v0 上训练代理(继续动作类型), 并发现调用 ppo.learn() 方法时,它以“Process finished with exit code 139”中止,并且没有其他错误消息。而且这个错误不是在训练的时候同时出现的time_step,请问如何解决?

import gym 
from stable_baselines3 import PPO
import warnings
warnings.filterwarnings('ignore')
# ==================================
#        Main script
# ==================================

def make_configure_env(**kwargs):
    env = gym.make(kwargs["id"])
    env.configure(kwargs["config"])
    env.reset()
    return env


env_kwargs = {
    'id': 'highway-fast-v0',
    'config': {
        "action": {
            "type": "ContinuousAction"
        }
    }
}
n_cpu = 6
batch_size = 64
env = make_configure_env(**env_kwargs)
env.reset()
model = PPO("MlpPolicy",
            env,
            policy_kwargs=dict(net_arch=[dict(pi=[256, 256], vf=[256, 256])]),
            n_steps=batch_size * 12 // n_cpu,
            batch_size=batch_size,
            n_epochs=10,
            learning_rate=5e-4,
            gamma=0.8,
            verbose=2,
            tensorboard_log="highway_ppo/")
# Train the agent
model.learn(total_timesteps=2e4)
# Save the agent
model.save("highway_ppo_continues/model")


【解决方案1】:

在阅读代码时,我发现其中缺少 import Highway_env。我尝试将相同的代码与 import 一起使用,它对我有用。

【讨论】: