【bug记录】Windows rllab搭建及运行报错记录

安装rllab

https://github.com/rll/rllab下载zip,解压后将文件夹rllab放入到anaconda虚拟环境(虚拟环境!!)的\Lib\site-packages文件夹中。(这一步自己粗心把文件夹放在了主环境下,import rllab,一直提示 no model named ‘rllab’)
将解压后的文件夹scripts也移动到env\你的虚拟环境\Lib\site-packages文件夹中,因为examples代码中用到了run_experiment_lite.py。

测试

运行examples文件夹下的trpo_cartpole_pickled.py

报错:ImportError: cannot import name ‘MemmapingPool’
解决: 修改源文件,MemmapingPool 改成 MemmappingPool

报错:run_experiment_lite.py: error: argument --n_parallel: invalid int value: "'2'"

解决:这里可能是源码在参数处理的时候不太好,直接修改函数源码,找到\Lib\site-packages\rllab\misc\instrument.py的to_local_command函数,加一个elif

    for k, v in params.items():
        if isinstance(v, dict):
            for nk, nv in v.items():
                if str(nk) == "_name":
                    command += "  --%s %s" % (k, _to_param_val(nv))
                else:
                    command += \
                        "  --%s_%s %s" % (k, nk, _to_param_val(nv))
        elif isinstance(v, int):
            command += "  --%s %d" % (k,v)
        else:
            command += "  --%s %s" % (k, _to_param_val(v))

 

报错:OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: “'C:”
这个问题在函数os.makedirs中,没弄明白是为什么,好像这个函数的参数必须是绝对路径,或者是传进去的参数不对?而rllab中,参数是虚拟环境安装的相对路径。
解决:直接在调用run_experiment_lite函数的时候,传入log的地址。

run_experiment_lite(
    run_task,
    # Number of parallel workers for sampling
    #n_parallel=2,
    # Only keep the snapshot parameters for the last iteration
    snapshot_mode="last",
    # Specifies the seed for the experiment. If this is not provided, a random seed
    # will be used
   # seed=1,
    #plot=True
    log_dir = "data",
)

 

报错:UnicodeEncodeError: 'gbk' codec can't encode character '\xd6' in position 27: illegal multibyte sequence

解决:在logger.py的131行加上 out = out.encode('utf-8').decode("cp936"),将out的编码格式转换为cp936

回溯源码\lib\site-packages\rllab\misc\logger.py,打印_text_fds信息,输出:ssssss {"'data'\\debug.log": <_io.TextIOWrapper name="'data'\\debug.log" mode='a' encoding='cp936'>},_text_fds的编码格式是cp936(奇奇怪怪的编码)

报错: NotImplementedError

解决:打印了_snapshot_mode的结果为‘last’,却没有走 elif   _snapshot_mode == 'last':的条件语句

原来是字符串本身是‘last’,if判断时应该改为_snapshot_mode == "'last'",总之很迷。。字符串带引号,什么迷惑行为,hhhh

代码在D:\anaconda3\envs\py36\Lib\site-packages\rllab\misc\logger.py

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值