facebookresearch / ELF

An End-To-End, Lightweight and Flexible Platform for Game Research
Other
2.09k stars 285 forks source link

Atari Environment could not Run #91

Open lynl7130 opened 6 years ago

lynl7130 commented 6 years ago

I Installed ALE according to https://github.com/facebookresearch/ELF/issues, finished all the makes under ELF/atari/build, and git cloned rom files to my own directory.

But when I test to run the environment with any rom file I get the following error, how could I fix this!!:

$ python game.py --rom_file=./atari-py/atari_py/atari_roms/adventure.bin PID: 16986 ========== Args ============ Loader: frame_skip=4,hist_len=4,rom_file="./atari-py/atari_py/atari_roms/adventure.bin",actor_only=False,reward_clip=1,rom_dir="",additional_labels=None,gpu=None ContextArgs: num_games=1024,batchsize=128,game_multi=None,T=6,eval=False,wait_per_group=False,num_collectors=0,verbose_comm=False,verbose_collector=False,mcts_threads=0,mcts_rollout_per_thread=1,mcts_verbose=False,mcts_save_tree_filename="",mcts_verbose_time=False,mcts_use_prior=False,mcts_pseudo_games=0,mcts_pick_method="most_visited" ========== End of Args ============ Warning: key = env_eval_only cannot be found from either args or environment! A.L.E: Arcade Learning Environment (version 0.6.0) [Powered by Stella] Use -help for help screen. Warning: couldn't load settings file: ./ale.cfg Game console created: ROM file: ./atari-py/atari_py/atari_roms/adventure.bin Cart Name: Adventure (1978) (Atari) (PAL) [!] Cart MD5: 4b27f5397c442d25f0c418ccdacf1926 Display Format: AUTO-DETECT ==> PAL ROM Size: 4096 Bankswitch Type: AUTO-DETECT ==> 4K

WARNING: Possibly unsupported ROM: mismatched MD5. Cartridge_MD5: 4b27f5397c442d25f0c418ccdacf1926 Cartridge_name: Adventure (1978) (Atari) (PAL) [!]

Running ROM file... Random seed is 83016338 Action set: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Version: 9952b83bebc242608879710b49a81b193c339de9_staged Num Actions: 18

recv_thread = 4

Group 0: Collector[0] Batchsize: 128 Info: [gid=0][T=1][name=""] Collector[1] Batchsize: 128 Info: [gid=1][T=1][name=""] Collector[2] Batchsize: 128 Info: [gid=2][T=1][name=""] Collector[3] Batchsize: 128 Info: [gid=3][T=1][name=""] Group 1: Collector[4] Batchsize: 128 Info: [gid=4][T=6][name=""] Collector[5] Batchsize: 128 Info: [gid=5][T=6][name=""] Collector[6] Batchsize: 128 Info: [gid=6][T=6][name=""] Collector[7] Batchsize: 128 Info: [gid=7][T=6][name=""]

0%| | 0/5000 [00:00<?, ?it/s] Traceback (most recent call last): File "game.py", line 169, in GC.Run() File "../elf/utils_elf.py", line 379, in Run res = self._call(self.infos) File "../elf/utils_elf.py", line 365, in _call sel_reply.copy_from(reply, batch_key=batch_key) File "../elf/utils_elf.py", line 164, in copy_from raise ValueError("Batch[%s].copy_from: Reply[%s] is not assigned" % (batch_key, k)) ValueError: Batch[actor-0].copy_from: Reply[pi] is not assigned Prepare to stop ... Segmentation fault

richardliaw commented 6 years ago

Seems like the bug is that the Reply does not cover all of the fields needed to finish a batch. You need to change the def actor in game.py to the following:

    def actor(batch):
        global actor_count, GC
        actor_count += 1
        batchsize = batch["s"].size(1)
        actions = [
            random.randint(0, GC.params["num_action"] - 1)
            for i in range(batchsize)
        ]
        values = [
            random.random()
            for i in range(batchsize)
        ]
        rv =[
            random.random()
            for i in range(batchsize)
        ]
        pi = torch.from_numpy(np.random.rand(1, batchsize, GC.params["num_action"]))

        reply = dict(a=actions,
                     V=values,
                     rv=rv,
                     pi=pi)
        return reply