pysc2-examples icon indicating copy to clipboard operation
pysc2-examples copied to clipboard

train mineral shard example is not compatible with baselines library

Open snurkabill opened this issue 7 years ago • 13 comments

I can't get started train_minteral_shards.py example. Getting this error:

$ python train_mineral_shards.py Traceback (most recent call last): File "train_mineral_shards.py", line 14, in from common.vec_env.subproc_vec_env import SubprocVecEnv File "D:\devel\repositories\pysc2-examples\common_init_.py", line 1, in from baselines.common.console_util import * ImportError: No module named 'baselines.common.console_util'

btw, I am using windows, can't it be problem? I've tried build baselines from repository, but I've failed on atari.py dependency (not very compatible with windows). baselines0.1.4 or lower libraries can be installed using pip, but seem to be not sufficient for example. Please help how to proceed.

snurkabill avatar Oct 11 '17 22:10 snurkabill

You need to install baselines library from the baselines Github repo.

pip install git+https://github.com/openai/baselines

Try this!

chris-chris avatar Oct 12 '17 05:10 chris-chris

ok, I've switched to another machine with linux and I was able to install baselines from repository. (baselines with version 0.1.4 does not work). Now I am getting error while running this script:

python3 train_mineral_shards.py --algorithm=deepq --prioritized=True --dueling=True --timesteps=2000000 --exploration_fraction=0.2 --num_cpu=4 --lr=0.0005
algorithm : deepq
timesteps : 2000000
exploration_fraction : 0.2
prioritized : True
dueling : True
num_cpu : 4
lr : 0.0005
Traceback (most recent call last):
  File "train_mineral_shards.py", line 289, in <module>
    main()
  File "train_mineral_shards.py", line 97, in main
    visualize=True) as env:
  File "/home/snurkabill/.local/lib/python3.5/site-packages/pysc2/env/sc2_env.py", line 116, in __init__
    raise ValueError("All arguments must be passed as keyword arguments.")
ValueError: All arguments must be passed as keyword arguments.

also for example:

algorithm : acktr
timesteps : 2000000
exploration_fraction : 0.5
prioritized : True
dueling : True
num_cpu : 4
lr : 0.0005
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/snurkabill/dev/repositories/pysc2-examples/common/vec_env/subproc_vec_env.py", line 15, in worker
    step_mul=1) as env:
  File "/home/snurkabill/.local/lib/python3.5/site-packages/pysc2/env/sc2_env.py", line 116, in __init__
    raise ValueError("All arguments must be passed as keyword arguments.")
ValueError: All arguments must be passed as keyword arguments.
Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/snurkabill/dev/repositories/pysc2-examples/common/vec_env/subproc_vec_env.py", line 15, in worker
    step_mul=1) as env:
  File "/home/snurkabill/.local/lib/python3.5/site-packages/pysc2/env/sc2_env.py", line 116, in __init__
    raise ValueError("All arguments must be passed as keyword arguments.")
ValueError: All arguments must be passed as keyword arguments.
Process Process-3:
Traceback (most recent call last):
  File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/snurkabill/dev/repositories/pysc2-examples/common/vec_env/subproc_vec_env.py", line 15, in worker
    step_mul=1) as env:
  File "/home/snurkabill/.local/lib/python3.5/site-packages/pysc2/env/sc2_env.py", line 116, in __init__
    raise ValueError("All arguments must be passed as keyword arguments.")
ValueError: All arguments must be passed as keyword arguments.
Process Process-4:
Traceback (most recent call last):
  File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/snurkabill/dev/repositories/pysc2-examples/common/vec_env/subproc_vec_env.py", line 15, in worker
    step_mul=1) as env:
  File "/home/snurkabill/.local/lib/python3.5/site-packages/pysc2/env/sc2_env.py", line 116, in __init__
    raise ValueError("All arguments must be passed as keyword arguments.")
ValueError: All arguments must be passed as keyword arguments.

Can you point me forward one more time, please?

snurkabill avatar Oct 12 '17 17:10 snurkabill

Hi, @chris-chris . I've tried modify your examples but I somehow failed. Could you please provide solution to my problem? I would be very grateful :)

snurkabill avatar Oct 15 '17 12:10 snurkabill

@snurkabill Try adding _only_use_kwargs=False to constructor "with sc2_env.SC2Env(" Idk what is purpose of this code >.>

ShadowDancer avatar Oct 16 '17 20:10 ShadowDancer

@snurkabill

Can you pull the latest code and try it again? I fixed this issue recently :)

chris-chris avatar Nov 04 '17 00:11 chris-chris

I still got that errors: Traceback (most recent call last): File "train_mineral_shards.py", line 13, in from common.vec_env.subproc_vec_env import SubprocVecEnv File "/home/howard/pysc2-examples/common/init.py", line 1, in from baselines.common.console_util import * ImportError: No module named 'baselines.common.console_util'

mcdavid109 avatar Dec 29 '17 03:12 mcdavid109

@mcdavid109

pip install git+https://github.com/openai/baselines

same thing "ImportError: No module named 'baselines.common.console_util'"

so, I tried

  1. Step : git clone https://github.com/openai/baselines.git
  2. Step : pip install -e . (in baselines directory)

and found 'baselines.common.console_util'

Environment : win10 + bash.. // bash app is very honey!

ghost avatar Dec 31 '17 22:12 ghost

I (Ubuntu 16.04) get this error

Failed building wheel for mpi4py

Both when I do

pip install git+https://github.com/openai/baselines

and as @d4r6

Faur avatar Jan 21 '18 07:01 Faur

Solved the mpi4py issue with this https://geeksww.com/tutorials/operating_systems/linux/installation/downloading_compiling_and_installing_cmake_on_linux.php

Then I had a problem with installing atari-py, which i solved using this https://github.com/openai/gym/issues/218

Faur avatar Jan 21 '18 07:01 Faur

@Faur I had this "mpi4py" problem too and I solved it this way: 1 sudo apt-get install libopenmpi-dev openmpi-bin openmpi-doc 2 pip install mpi4py

mushroom1116 avatar Feb 01 '18 01:02 mushroom1116

I have the same exact issue with snurkabill. ImportError: No module named 'baselines.common.console_util' I am using win10. Do I have to change to Linux?

gokimsky avatar Feb 03 '18 04:02 gokimsky

@gokimsky no. I have the example running. I am using anaconda with a tensorflow-gpu installation on windows 10. If you install the current atari-py first from their git repo and then baselines you do not need mpi:

git clone [email protected]:openai/atari-py.git
cd atari-py
pip install -e .
cd ..
git clone [email protected]:openai/baselines.git
cd baselines
pip install -e .
cd ..

The second problem is that the baselines API has changed, so the code here needs some changes. I got the defeat_zerglings and enjoy_mineral_shads files running in my fork for now, take a look at my changes here: https://github.com/chris-chris/pysc2-examples/compare/master...brean:baseline_changes (I am not that experienced with deep learning yet so I will not directly provide a pull request and let you guys take a look at my code first, so feel free to copy stuff from it and merge it with this repo).

brean avatar Feb 06 '18 16:02 brean

when i run the

python3 train_mineral_shards.py --algorithm=a2c I got a similar problem,but this is the problem of my tensorflow. The output is that:

Traceback (most recent call last): File "train_mineral_shards.py", line 5, in from baselines import deepq File "/home/limenglin519/pysc2-examples/baselines/baselines/deepq/init.py", line 1, in from baselines.deepq import models # noqa File "/home/limenglin519/pysc2-examples/baselines/baselines/deepq/models.py", line 2, in import tensorflow.contrib.layers as layers ImportError: No module named 'tensorflow.contrib' I wuold be grateful ,if u can help me to solve this.

lml519 avatar Oct 17 '19 07:10 lml519