tambetm/simple_dqn

error on PI3 for ./play.sh snapshots/breakout_77.pkl

Closed this issue · 7 comments

hi I am trying to use the test script on a pi3 , raspbian jessie:

unfortunately I get this error, which looks like too small RAM??
Is there any way to fix this?

happens to these commands (to openai gym commands as well)
pi@pi:/home/pi/simple_dqn$ ./test.sh snapshots/breakout_77.pkl
or for play:
pi@pi:~/simple_dqn $ ./play.sh snapshots/breakout_77.pkl

A.L.E: Arcade Learning Environment (version 0.5.1)
[Powered by Stella]
Use -help for help screen.
Warning: couldn't load settings file: ./ale.cfg
Game console created:
ROM file: roms/breakout.bin
Cart Name: Breakout - Breakaway IV (1978) (Atari)
Cart MD5: f34f08e5eb96e500e851a80be3277a56
Display Format: AUTO-DETECT ==> NTSC
ROM Size: 2048
Bankswitch Type: AUTO-DETECT ==> 2K

Screen Display Active. [Manual Control Mode] 'm' [Slowdown] 'a' [Speedup] 's' [VolumeDown] '[' [VolumeUp] ']'.
Running ROM file...
Random seed is 0
2017-01-07 20:19:49,238 Using minimal action set with size 4
2017-01-07 20:19:49,250 Using ALE Environment
Traceback (most recent call last):
File "src/main.py", line 103, in
mem = ReplayMemory(args.replay_size, args)
File "/home/pi/simple_dqn/src/replay_memory.py", line 12, in init
self.screens = np.empty((self.size, args.screen_height, args.screen_width), dtype = np.uint8)
ValueError: array is too big.

You might want to try smaller replay memory size, i.e. --replay_size 100000. Although I suspect learning on Raspberry Pi is going to be painfully slow.

if I use your suggestion like this:
./test.sh snapshots/breakout_77.pkl --replay_size 100000 (or smaller like 1000, or 10)

I get this error now (for play, test, test_gym) :

A.L.E: Arcade Learning Environment (version 0.5.1)
[Powered by Stella]
Use -help for help screen.
Warning: couldn't load settings file: ./ale.cfg
Game console created:
ROM file: roms/breakout.bin
Cart Name: Breakout - Breakaway IV (1978) (Atari)
Cart MD5: f34f08e5eb96e500e851a80be3277a56
Display Format: AUTO-DETECT ==> NTSC
ROM Size: 2048
Bankswitch Type: AUTO-DETECT ==> 2K

Running ROM file...
Random seed is 0
2017-01-07 21:20:06,457 Using minimal action set with size 4
2017-01-07 21:20:06,469 Using ALE Environment
2017-01-07 21:20:06,470 Replay memory size: 1000
Traceback (most recent call last):
File "src/main.py", line 104, in
net = DeepQNetwork(env.numActions(), args)
File "/home/pi/simple_dqn/src/deepqnetwork.py", line 34, in init
stochastic_round = args.stochastic_round)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/backends/init.py", line 108, in gen_backend
deterministic=deterministic)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/backends/backend.py", line 471, in allocate_backend
raise ValueError("backend must be one of (%s)" % (names,))
ValueError: backend must be one of ('cpu')

Try --backend cpu.

great, it works for the arcade environment really slow....ly, but I was just interested if I can run it at all.

so if anyone is interested use:
./play.sh snapshots/breakout_77.pkl --replay_size 100000 --backend cpu
or
./test.sh snapshots/breakout_77.pkl --replay_size 100000 --backend cpu

thanks a lot :)

FYI:

for gym I still get an error as follows:
./test_gym.sh snapshots/breakout_77.pkl --replay_size 100000 --backend cpu

error:
[2017-01-07 22:00:52,838] Making new env: breakout
Traceback (most recent call last):
File "src/test_gym.py", line 71, in
env = GymEnvironment(args.env_id, args)
File "/home/pi/simple_dqn/src/environment.py", line 118, in init
self.gym = gym.make(env_id)
File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 127, in make
return registry.make(id)
File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 91, in make
spec = self.spec(id)
File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 100, in spec
raise error.Error('Attempted to look up malformed environment ID: {}. (Currently all IDs must be of the form {}.)'.format(id.encode('utf-8'), env_id_re.pattern))
gym.error.Error: Attempted to look up malformed environment ID: breakout. (Currently all IDs must be of the form ^(?:[\w:-]+/)?([\w:.-]+)-v(\d+)$.)
pi@mcu:~/simple_dqn $ ./test_gym.sh snapshots/Breakout-v0_77.pkl --replay_size 100000 --backend cpu[2017-01-07 22:01:09,077] Making new env: Breakout-v0
Loading weights from snapshots/Breakout-v0_77.pkl
Traceback (most recent call last):
File "src/test_gym.py", line 78, in
net.load_weights(args.load_weights)
File "/home/pi/simple_dqn/src/deepqnetwork.py", line 189, in load_weights
self.model.load_params(load_path)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/models/model.py", line 413, in load_params
self.deserialize(load_obj(param_path), load_states=load_states)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/util/persist.py", line 150, in load_obj
load_path = open(load_path, 'rb')
IOError: [Errno 2] No such file or directory: 'snapshots/Breakout-v0_77.pkl'

You could try renaming snapshots/breakout_77.pkl to snapshots/Breakout-v0_77.pkl, but if I remember correctly Gym version had slightly different action space and you would have to train a model from scratch to work with Gym. Unfortunately I'm not actively using this codebase any more and able to help here.

if I try out ur suggestion:

first renamed the file to Breakout-v0_77.pkl then:
./test_gym.sh snapshots/Breakout-v0_77.pkl --replay_size 100000 --backend cpu

this gives the following error (somewhere in Nervana):

2017-01-11 12:00:37,681] Making new env: Breakout-v0
Loading weights from snapshots/Breakout-v0_77.pkl
[2017-01-11 12:00:52,956] Using old model serialization format. Serialized the model into new format
Traceback (most recent call last):
File "src/test_gym.py", line 78, in
net.load_weights(args.load_weights)
File "/home/pi/simple_dqn/src/deepqnetwork.py", line 189, in load_weights
self.model.load_params(load_path)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/models/model.py", line 413, in load_params
self.deserialize(load_obj(param_path), load_states=load_states)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/models/model.py", line 457, in deserialize
l.set_params(ps)
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/layers/layer.py", line 657, in set_params
attr.set(pdict['params'][key])
File "/usr/local/lib/python2.7/dist-packages/neon-1.8.0-py2.7.egg/neon/backends/nervanacpu.py", line 246, in set
assert value.size == self.size
AssertionError

This errors seems to be exactly because of different action space. So unfortunately the only option is to retrain from scratch.