Проблемы с создание контейнера Docker
Я установил OpenAi Universe
cd ~ git clone https://github.com/openai/universe.git
cd universe
pip install -e .
При установке было такое сообщение:
Obtaining file:///Users/user/universe
Preparing metadata (setup.py) ... done
Requirement already satisfied: universe in /Users/user/universe (0.21.5)
Requirement already satisfied: autobahn>=0.16.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (24.4.2)
Requirement already satisfied: docker-py==1.10.3 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (1.10.3)
Requirement already satisfied: docker-pycreds==0.2.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.2.1)
Requirement already satisfied: fastzbarlight>=0.0.13 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.0.14)
Requirement already satisfied: go-vncdriver>=0.4.8 in /Users/danilabrikanov/go-vncdriver (from universe==0.21.5) (0.4.19)
Requirement already satisfied: gym>=0.8.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.26.2)
Requirement already satisfied: Pillow>=3.3.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (10.4.0)
Requirement already satisfied: PyYAML>=3.12 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (6.0.1)
Requirement already satisfied: six>=1.10.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (1.16.0)
Requirement already satisfied: twisted>=16.5.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (23.10.0)
Requirement already satisfied: ujson>=1.35 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (5.10.0)
Requirement already satisfied: requests<2.11,>=2.5.2 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from docker-py==1.10.3->universe==0.21.5) (2.10.0)
Requirement already satisfied: websocket-client>=0.32.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from docker-py==1.10.3->universe==0.21.5) (1.8.0)
Requirement already satisfied: txaio>=21.2.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (23.1.1)
Requirement already satisfied: cryptography>=3.4.6 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (43.0.0)
Requirement already satisfied: hyperlink>=21.0.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (21.0.0)
Requirement already satisfied: setuptools in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (75.1.0)
Requirement already satisfied: numpy in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from go-vncdriver>=0.4.8->universe==0.21.5) (1.26.4)
Requirement already satisfied: cloudpickle>=1.2.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from gym>=0.8.1->universe==0.21.5) (3.0.0)
Requirement already satisfied: gym_notices>=0.0.4 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from gym>=0.8.1->universe==0.21.5) (0.0.8)
Requirement already satisfied: attrs>=21.3.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (23.1.0)
Requirement already satisfied: automat>=0.8.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (20.2.0)
Requirement already satisfied: constantly>=15.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (23.10.4)
Requirement already satisfied: incremental>=22.10.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (22.10.0)
Requirement already satisfied: typing-extensions>=4.2.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (4.11.0)
Requirement already satisfied: zope-interface>=5 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (5.4.0)
Requirement already satisfied: cffi>=1.12 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from cryptography>=3.4.6->autobahn>=0.16.0->universe==0.21.5) (1.17.1)
Requirement already satisfied: idna>=2.5 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from hyperlink>=21.0.0->autobahn>=0.16.0->universe==0.21.5) (3.7)
Requirement already satisfied: pycparser in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=3.4.6->autobahn>=0.16.0->universe==0.21.5) (2.21)
Installing collected packages: universe
Attempting uninstall: universe
Found existing installation: universe 0.21.5
Uninstalling universe-0.21.5:
Successfully uninstalled universe-0.21.5
DEPRECATION: Legacy editable install of universe==0.21.5 from file:///Users/user/universe (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
Running setup.py develop for universe
Successfully installed universe
Далее мне нужно было создать образ Docker:
docker build -t universe .
После выполнения этой команды появляется ошибка при создании:
[+] Building 3.2s (10/18) docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.48kB 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:16.04 3.0s
=> [auth] library/ubuntu:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 66B 0.0s
=> [ 1/13] FROM docker.io/library/ubuntu:16.04@sha256:1f1a2d56de1d604801 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 13.44kB 0.0s
=> CACHED [ 2/13] RUN apt-get update && apt-get install -y libav-too 0.0s
=> CACHED [ 3/13] RUN true 0.0s
=> CACHED [ 4/13] RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip && ln 0.0s
=> ERROR [ 5/13] RUN pip install gym[all] 0.2s
------
> [ 5/13] RUN pip install gym[all]:
0.164 Traceback (most recent call last):
0.164 File "/usr/local/bin/pip", line 7, in <module>
0.164 from pip._internal.cli.main import main
0.164 File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 67
0.164 sys.stderr.write(f"ERROR: {exc}")
0.164 ^
0.164 SyntaxError: invalid syntax
------
Dockerfile:36
--------------------
34 |
35 | # Install gym
36 | >>> RUN pip install gym[all]
37 |
38 | # Get the faster VNC driver
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install gym[all]" did not complete successfully: exit code: 1
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/lzvq2rrk75dfl8bh6pc8k4wsr
Что можно сделать чтобы исправить это, читаю книгу "Глубокое обучение с подкреплением на Python" Судхарсана Равичандирана. Из-за этой проблемы не могу продолжить чтение.
Dockerfile:
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y libav-tools \
python3-numpy \
python3-scipy \
python3-setuptools \
python3-pip \
libpq-dev \
libjpeg-dev \
curl \
cmake \
swig \
python3-opengl \
libboost-all-dev \
libsdl2-dev \
wget \
unzip \
git \
golang \
net-tools \
iptables \
libvncserver-dev \
software-properties-common \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ARG BASE_COMMAND="true"
RUN $BASE_COMMAND
RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip \
&& ln -sf /usr/bin/python3 /usr/local/bin/python \
&& pip install -U pip
# Install gym
RUN pip install gym[all]
# Get the faster VNC driver
RUN pip install go-vncdriver>=0.4.0
# Install pytest (for running test cases)
RUN pip install pytest
# Force the container to use the go vnc driver
ENV UNIVERSE_VNCDRIVER='go'
WORKDIR /usr/local/universe/
# Cachebusting
COPY ./setup.py ./
COPY ./tox.ini ./
RUN pip install -e .
# Upload our actual code
COPY . ./
# Just in case any python cache files were carried over from the source directory, remove them
RUN py3clean .
Ответы (1 шт):
UPDATE
Собранный докер не будет работать. Начиная с Python 3.7 идентификатор async
является ключевым словом, а в исходном коде universal
есть присваивание async = что-то-там()
. На этом месте выполнение ломается.
Я попробовал собрать в 3.6 - не собирается gym
.
Видимо, вам нужно подыскать книгу поновее.
НЕ РАБОТАЕТ Попробуйте вот такой Dockerfile. Он собран на более новой версии убунты, и собирает свежие версии numpy и scipy из сборника пакетов python.
FROM ubuntu:20.04
RUN apt-get clean
RUN apt-get update
RUN apt install python3 python3-pip -y
RUN /usr/bin/python3 -m pip install -U pip
RUN /usr/bin/python3 -m pip install setuptools
RUN /usr/bin/python3 -m pip install numpy scipy
ENV DEBIAN_FRONTEND noninteractive
RUN apt install tzdata -y
RUN apt-get install -y ffmpeg \
libpq-dev \
libjpeg-dev \
curl \
cmake \
swig \
# python3-numpy \
# python3-scipy \
# python3-setuptools \
# python3-pip \
python3-opengl \
libboost-all-dev \
libsdl2-dev \
wget \
unzip \
git \
golang \
net-tools \
iptables \
libvncserver-dev \
software-properties-common
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip \
&& ln -sf /usr/bin/python3 /usr/local/bin/python \
&& pip install -U pip
# Install gym
RUN pip install gym[all]
# Get the faster VNC driver
RUN pip install go-vncdriver>=0.4.0
# Install pytest (for running test cases)
RUN pip install pytest
# Force the container to use the go vnc driver
ENV UNIVERSE_VNCDRIVER 'go'
WORKDIR /usr/local/universe/
# Cachebusting
COPY ./setup.py ./
COPY ./tox.ini ./
RUN pip install -e .
# Upload our actual code
COPY . ./
# Just in case any python cache files were carried over from the source directory, remove them
RUN py3clean .
Я не знаю, что вы будете делать с этим образом и какие проблемы могут вылезти из-за разнобоя в версиях python, но как минимум он собирается.