tristandeleu/pytorch-maml-rl

Can not read your env in the Jupyter

CeyaoZhang opened this issue · 1 comments

Hi, very nice code.

I downloaded your code and wanted to create envrinoment in the Jupyter.
I created config manually. When I try to make the gym env, it failed.
Seems that your mujoco env is not connected with the gym/envs/mujoco, and thus I can not read your mujoco env from gym.make

My codes and the errors are listed as follows:

import argparse
import multiprocessing as mp
import yaml
import json
import os
import gym
import torch

arser = argparse.ArgumentParser(description='Reinforcement learning with '
                                             'Model-Agnostic Meta-Learning (MAML) - Train')
# parser.add_argument('--config', type=str, required=True,help='path to the configuration file.')

# Miscellaneous
misc = parser.add_argument_group('Miscellaneous')
misc.add_argument('--output-folder', type=str,
                  help='name of the output folder')
misc.add_argument('--seed', type=int, default=None,
                  help='random seed')
misc.add_argument('--num-workers', type=int, default=mp.cpu_count() - 1,
                  help='number of workers for trajectories sampling (default: '
                       '{0})'.format(mp.cpu_count() - 1))
misc.add_argument('--use-cuda', action='store_true',
                  help='use cuda (default: false, use cpu). WARNING: Full upport for cuda '
                       'is not guaranteed. Using CPU is encouraged.')

# args = parser.parse_args()
# args.device = ('cuda' if (torch.cuda.is_available()
#                           and args.use_cuda) else 'cpu')

args = parser.parse_args(args=[])

args.config = "configs/maml/halfcheetah-vel.yaml"
with open(args.config, 'r') as f:
    config = yaml.load(f, Loader=yaml.FullLoader)

args.output_folder = "maml-halfcheetah-vel"
if args.output_folder is not None:
    if not os.path.exists(args.output_folder):
        os.makedirs(args.output_folder)
    policy_filename = os.path.join(args.output_folder, 'policy.th')
    config_filename = os.path.join(args.output_folder, 'config.json')

print(config['env-name'], config['env-kwargs'])
env = gym.make(config['env-name'], **config.get('env-kwargs', {}))

bug

BR,
Charles

I got it.

I forgot to upload the env import maml_rl.envs

Thx anyway~