baselines icon indicating copy to clipboard operation
baselines copied to clipboard

Poor PPO 1 CPU performance on the Pong task

Open ViktorM opened this issue 9 years ago • 10 comments

Hi,

I've started the default Pong training with run_atari.py on my laptop. The only change to the start parameters was a num_cpu =1. After more than a 2 days training the reward was still around -20.4. It started from -20.6 after a day of training temporary improved to the -20.2 and then dropped again to -20.4 without any changes for a quite long time. On the same laptop it took near the same time to train baselines vanilla DQN agent to the maximal reward 20+.

Is it an expected result for a single CPU PPO training?

ViktorM avatar Jul 24 '17 17:07 ViktorM

I failed to run PPO, can you tell me how to do it? Thank you~

shijcnju avatar Jul 25 '17 13:07 shijcnju

@shijcnju sorry for delay with reply, traveling at the moment. If you previously had no problem to run DQN. It's pretty straightforward. The only required change if you plan to run it on PC or laptop with 1 CPU- to set num_cpu=1 in:

def main():
    train('PongNoFrameskip-v4', num_timesteps=40e6, seed=0, num_cpu=8)

Except this change PPO for me was running out of the box, except reward growth.

ViktorM avatar Jul 26 '17 01:07 ViktorM

Also you should pip install mpi4py first and on Windows a few more actions were required to make mpi4py work.

ViktorM avatar Jul 26 '17 02:07 ViktorM

If you set num_cpu = 4 and run run_atari.py again, you should observe around 17.0 mean reward in about 2k iterations.

However if you are working in Anaconda environment and have installed mpi4py via pip or conda install, this probably will report some errors like 'detected that one or more processes exited with non-zero status'. In this case, you should remove mpi4y and reinstall from source https://bitbucket.org/mpi4py/mpi4py instead.

iamzoumao avatar Aug 02 '17 06:08 iamzoumao

Thanks @iamzoumao for the advice. With 4 num_cpu I see a bit different errors:

 File "run_atari2.py", line 54, in <module>
    main()
  File "run_atari2.py", line 51, in main
    train('PongNoFrameskip-v4', num_timesteps=40e6, seed=0, num_cpu=4)
  File "run_atari2.py", line 20, in train
    whoami  = mpi_fork(num_cpu)
  File "D:\baselines\baselines\common\mpi_fork.py", line 20, in mpi_fork
    subprocess.check_call(args, env=env)
  File "C:\Users\Viktor\Anaconda3\envs\deep-rl\lib\subprocess.py", line 576, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Users\Viktor\Anaconda3\envs\deep-rl\lib\subprocess.py", line 557, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\Viktor\Anaconda3\envs\deep-rl\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Viktor\Anaconda3\envs\deep-rl\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

But will try reinstalling from source in any way, thanks.

ViktorM avatar Aug 02 '17 08:08 ViktorM

Ran into the same problem as @ViktorM. Tried installing mpi4py from source, but got the same error.

nchentanez avatar Aug 14 '17 06:08 nchentanez

Ok I got it to work: First, install both the mpi run time and mpi SDK from https://www.microsoft.com/en-us/download/details.aspx?id=55494

Then rename/copy C:\Program Files\Microsoft MPI\Bin\mpiexec.exe to C:\Program Files\Microsoft MPI\Bin\mpirun.exe

or need to modify baselines\common\mpi_fork.py to call mpiexec instead, if running on Windows

nchentanez avatar Aug 14 '17 09:08 nchentanez

Using ubuntu 16.04, and running these from a conda environment. Unable to run PPO or TRPO as I get the error that @iamzoumao stated. Was unable to make mpi4py from source. Any workaround for this?

KeirSimmons avatar Aug 21 '17 07:08 KeirSimmons

@KeirSimmons for me on Ubuntu 16.04 just conda install mpi4py worked well.

ViktorM avatar Aug 27 '17 19:08 ViktorM

We don't officially support Windows. It's great if it works, but we don't have Windows here anywhere. Please post a PR if you're able to fix a specific Windows problem.

olegklimov avatar Feb 05 '18 21:02 olegklimov