hill-a / stable-baselines

A fork of OpenAI Baselines, implementations of reinforcement learning algorithms
http://stable-baselines.readthedocs.io/
MIT License
4.16k stars 725 forks source link

Problems with docker image after change #565 No module named 'stable_baselines.common' #650

Closed sikora507 closed 4 years ago

sikora507 commented 4 years ago

I noticed that some time ago, exactly at Nov 21, 2019, there was a change in documentation by @AdamGleave The change in file docs/guide/install.rst was from line: docker pull araffin/stable-baselines to line docker pull stablebaselines/stable-baselines

I see that on docker hub, there are now 2 images, but I can't get stablebaselines/stable-baselines to work.

When I do docker pull stablebaselines/stable-baselines Then I run docker run -it stablebaselines/stable-baselines Then inside the container i run root@e138a33e5fca:/# pip install stable-baselines Then I run python root@e138a33e5fca:/# python

And when I try to include something from stable_baselines like this line taken straight from the documentation: >>> from stable_baselines.common.policies import MlpPolicy I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'stable_baselines.common'

This is not the issue with old image docker pull araffin/stable-baselines and I can run examples from the documentation. But I guess we are using docker pull stablebaselines/stable-baselines now which I think is not working. With the new image, I cannot include anything from stable_baselines.

Please help.

araffin commented 4 years ago

Hello, the docker image does not have Stable Baselines installed. as written in the docs: " If you are looking for docker images with stable-baselines already installed in it, we recommend using images from RL Baselines Zoo.

Otherwise, the following images contained all the dependencies for stable-baselines but not the stable-baselines package itself. They are made for development."

sikora507 commented 4 years ago

Yes i saw this. That's why I'm doing pip install stable-baselines after using this image. It worked for araffin/stable-baselines but something is not right with the new one.

Even on baselines zoo the dockerfile is installing stable-baselines through pip on line 45 in dockerfile: pip install stable-baselines[mpi,tests]==2.9.0 && \

Here's my example dockerfile I created for hosting flask web api in python using stable-baselines from old image:

FROM araffin/stable-baselines

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

RUN \
    pip install stable-baselines
RUN \
    pip install flask
RUN \
    pip install -U ptvsd

ENV PATH=~/.local/bin:$PATH

COPY . /root/code
WORKDIR /root/code

ENTRYPOINT [ "python", "-m", "flask", "run", "-h", "0.0.0.0", "-p", "5010", "--no-debugger", "--no-reload"]

After changing from "affin" to "stablebaselines" it won't work (python imports won't find the modules). I can't figure out what the problem is. I looked at RL Baselines Zoo for a moment, but there you need to build your docker images first so I thought it cannot be that complicated and created my own dockerfile instead. But I'll give it a try.

I noticed that when I'm using araffin/stable-baselines, pip is downloading stable-baselines package:

tomasz@white:~$ docker run -it araffin/stable-baselines 
root@aa4a5d979ff3:/# pip3 install stable-baselines
Collecting stable-baselines
  Downloading https://files.pythonhosted.org/packages/c0/05/f6651855083020c0363acf483450c23e38d96f5c18bec8bded113d528da5/stable_baselines-2.9.0-py3-none-any.whl (232kB)
     |################################| 235kB 1.4MB/s 
Requirement already satisfied: pandas in /root/venv/lib/python3.5/site-packages (from stable-baselines) (0.24.2)
Requirement already satisfied: cloudpickle>=0.5.5 in /root/venv/lib/python3.5/site-packages (from stable-baselines) (1.2.1)
Requirement already satisfied: matplotlib in /root/venv/lib/python3.5/site-packages (from stable-baselines) (3.0.3)
Requirement already satisfied: numpy in /root/venv/lib/python3.5/site-packages (from stable-baselines) (1.17.0)
Requirement already satisfied: gym[atari,classic_control]>=0.10.9 in /root/venv/lib/python3.5/site-packages (from stable-baselines) (0.14.0)
Requirement already satisfied: joblib in /root/venv/lib/python3.5/site-packages (from stable-baselines) (0.13.2)
Requirement already satisfied: opencv-python in /root/venv/lib/python3.5/site-packages (from stable-baselines) (4.1.0.25)
Requirement already satisfied: scipy in /root/venv/lib/python3.5/site-packages (from stable-baselines) (1.3.0)
Requirement already satisfied: python-dateutil>=2.5.0 in /root/venv/lib/python3.5/site-packages (from pandas->stable-baselines) (2.8.0)
Requirement already satisfied: pytz>=2011k in /root/venv/lib/python3.5/site-packages (from pandas->stable-baselines) (2019.2)
Requirement already satisfied: cycler>=0.10 in /root/venv/lib/python3.5/site-packages (from matplotlib->stable-baselines) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /root/venv/lib/python3.5/site-packages (from matplotlib->stable-baselines) (1.1.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /root/venv/lib/python3.5/site-packages (from matplotlib->stable-baselines) (2.4.2)
Requirement already satisfied: six in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (1.12.0)
Requirement already satisfied: pyglet<=1.3.2,>=1.2.0 in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (1.3.2)
Requirement already satisfied: atari-py~=0.2.0; extra == "atari" in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (0.2.6)
Requirement already satisfied: Pillow; extra == "atari" in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (6.1.0)
Requirement already satisfied: setuptools in /root/venv/lib/python3.5/site-packages (from kiwisolver>=1.0.1->matplotlib->stable-baselines) (41.0.1)
Requirement already satisfied: future in /root/venv/lib/python3.5/site-packages (from pyglet<=1.3.2,>=1.2.0->gym[atari,classic_control]>=0.10.9->stable-baselines) (0.17.1)
Installing collected packages: stable-baselines
Successfully installed stable-baselines-2.9.0
WARNING: You are using pip version 19.2.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

but when I'm using stablebaselines/stable-baselines it's not collecting the package when I run pip. It looks like it's already in /root/code but trying to include it from python won't work

tomasz@white:~$ docker run -it stablebaselines/stable-baselines
root@d55b01f1cd00:/# pip3 install stable-baselines
Requirement already satisfied: stable-baselines in /root/code (2.10.0a0)
Requirement already satisfied: gym[atari,classic_control]>=0.10.9 in /root/venv/lib/python3.5/site-packages (from stable-baselines) (0.15.4)
Requirement already satisfied: scipy in /root/venv/lib/python3.5/site-packages (from stable-baselines) (1.4.1)
Requirement already satisfied: joblib in /root/venv/lib/python3.5/site-packages (from stable-baselines) (0.14.1)
Requirement already satisfied: cloudpickle>=0.5.5 in /root/venv/lib/python3.5/site-packages (from stable-baselines) (1.2.2)
Requirement already satisfied: opencv-python in /root/venv/lib/python3.5/site-packages (from stable-baselines) (4.1.2.30)
Requirement already satisfied: numpy in /root/venv/lib/python3.5/site-packages (from stable-baselines) (1.18.0)
Requirement already satisfied: pandas in /root/venv/lib/python3.5/site-packages (from stable-baselines) (0.24.2)
Requirement already satisfied: matplotlib in /root/venv/lib/python3.5/site-packages (from stable-baselines) (3.0.3)
Requirement already satisfied: six in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (1.13.0)
Requirement already satisfied: pyglet<=1.3.2,>=1.2.0 in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (1.3.2)
Requirement already satisfied: Pillow; extra == "atari" in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (6.2.1)
Requirement already satisfied: atari-py~=0.2.0; extra == "atari" in /root/venv/lib/python3.5/site-packages (from gym[atari,classic_control]>=0.10.9->stable-baselines) (0.2.6)
Requirement already satisfied: python-dateutil>=2.5.0 in /root/venv/lib/python3.5/site-packages (from pandas->stable-baselines) (2.8.1)
Requirement already satisfied: pytz>=2011k in /root/venv/lib/python3.5/site-packages (from pandas->stable-baselines) (2019.3)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /root/venv/lib/python3.5/site-packages (from matplotlib->stable-baselines) (2.4.6)
Requirement already satisfied: cycler>=0.10 in /root/venv/lib/python3.5/site-packages (from matplotlib->stable-baselines) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /root/venv/lib/python3.5/site-packages (from matplotlib->stable-baselines) (1.1.0)
Requirement already satisfied: future in /root/venv/lib/python3.5/site-packages (from pyglet<=1.3.2,>=1.2.0->gym[atari,classic_control]>=0.10.9->stable-baselines) (0.18.2)
Requirement already satisfied: setuptools in /root/venv/lib/python3.5/site-packages (from kiwisolver>=1.0.1->matplotlib->stable-baselines) (44.0.0)
root@d55b01f1cd00:/# 

EDIT I just realized pip3 install --upgrade --force-reinstall stable-baselines does the trick and I can import modules now.