Update docker image for 2nd edition
parent
f680e49ea2
commit
fb47fab0c8
|
@ -1 +1 @@
|
||||||
COMPOSE_PROJECT_NAME=handson-ml
|
COMPOSE_PROJECT_NAME=handson-ml2
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM continuumio/anaconda3:5.2.0
|
FROM continuumio/anaconda3:2019.03
|
||||||
|
|
||||||
RUN apt-get update && apt-get upgrade -y \
|
RUN apt-get update && apt-get upgrade -y \
|
||||||
&& apt-get install -y \
|
&& apt-get install -y \
|
||||||
|
@ -7,20 +7,37 @@ RUN apt-get update && apt-get upgrade -y \
|
||||||
git \
|
git \
|
||||||
sudo \
|
sudo \
|
||||||
cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev libboost-all-dev libsdl2-dev swig \
|
cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev libboost-all-dev libsdl2-dev swig \
|
||||||
|
unzip zip \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN conda update -n base conda
|
RUN conda update -n base conda
|
||||||
|
RUN conda install -y \
|
||||||
|
joblib \
|
||||||
|
PyYAML==3.13
|
||||||
RUN conda install -y -c conda-forge \
|
RUN conda install -y -c conda-forge \
|
||||||
tensorflow \
|
pyopengl \
|
||||||
jupyter_contrib_nbextensions \
|
xgboost \
|
||||||
pyopengl
|
nbdime
|
||||||
|
RUN pip install "urlextract"
|
||||||
RUN pip install "gym[atari,box2d,classic_control]"
|
RUN pip install "gym[atari,box2d,classic_control]"
|
||||||
|
RUN pip install "tensorflow-hub"
|
||||||
|
RUN pip install "tensorflow-serving-api"
|
||||||
|
RUN pip install "tfx"
|
||||||
|
#RUN pip install "tensorflow-addons"
|
||||||
|
RUN pip install "tf-agents-nightly"
|
||||||
|
RUN pip install "tfds-nightly"
|
||||||
|
RUN pip install "tfp-nightly"
|
||||||
|
RUN pip uninstall -y tensorflow
|
||||||
|
RUN pip uninstall -y tensorboard
|
||||||
|
RUN pip install "tf-nightly-2.0-preview"
|
||||||
|
RUN pip install "tb-nightly"
|
||||||
|
|
||||||
|
|
||||||
ARG username
|
ARG username
|
||||||
ARG userid
|
ARG userid
|
||||||
|
|
||||||
ARG home=/home/${username}
|
ARG home=/home/${username}
|
||||||
ARG workdir=${home}/handson-ml
|
ARG workdir=${home}/handson-ml2
|
||||||
|
|
||||||
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
|
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
|
||||||
&& echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} \
|
&& echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} \
|
||||||
|
@ -29,25 +46,17 @@ RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
|
||||||
WORKDIR ${workdir}
|
WORKDIR ${workdir}
|
||||||
RUN chown ${username}:${username} ${workdir}
|
RUN chown ${username}:${username} ${workdir}
|
||||||
|
|
||||||
USER ${username}
|
|
||||||
|
|
||||||
RUN jupyter contrib nbextension install --user
|
|
||||||
RUN jupyter nbextension enable toc2/main
|
|
||||||
|
|
||||||
|
|
||||||
# INFO: Jupyter and nbdime extension are not totally integrated (anaconda image is py36,
|
|
||||||
# nbdime checks for py35 at the moment, still the config below enables diffing
|
|
||||||
# notebooks with nbdiff (and nbdiff support in git diff command) after connecting
|
|
||||||
# to the container by "make exec" (or "docker-compose exec handson-ml bash")
|
|
||||||
# You may also try running:
|
|
||||||
# nbd NOTEBOOK_NAME.ipynb
|
|
||||||
# to get nbdiff between checkpointed version and current version of the given notebook
|
|
||||||
USER root
|
|
||||||
WORKDIR /
|
|
||||||
RUN conda install -y -c conda-forge nbdime
|
|
||||||
USER ${username}
|
USER ${username}
|
||||||
WORKDIR ${workdir}
|
WORKDIR ${workdir}
|
||||||
|
|
||||||
|
# The config below enables diffing notebooks with nbdiff (and nbdiff support
|
||||||
|
# in git diff command) after connecting to the container by "make exec" (or
|
||||||
|
# "docker-compose exec handson-ml2 bash")
|
||||||
|
# You may also try running:
|
||||||
|
# nbdiff NOTEBOOK_NAME.ipynb
|
||||||
|
# to get nbdiff between checkpointed version and current version of the
|
||||||
|
# given notebook.
|
||||||
|
|
||||||
RUN git-nbdiffdriver config --enable --global
|
RUN git-nbdiffdriver config --enable --global
|
||||||
|
|
||||||
# INFO: Optionally uncomment any (one) of the following RUN commands below to ignore either
|
# INFO: Optionally uncomment any (one) of the following RUN commands below to ignore either
|
||||||
|
@ -56,19 +65,6 @@ RUN git-nbdiffdriver config --enable --global
|
||||||
RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-details'
|
RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-details'
|
||||||
|
|
||||||
|
|
||||||
# INFO: Dirty nbdime patching (ignored if not matching)
|
|
||||||
COPY docker/nbdime-*.patch /tmp/
|
|
||||||
USER root
|
|
||||||
WORKDIR /
|
|
||||||
RUN patch -d /opt/conda/lib/python3.6/site-packages -p1 --forward --reject-file=- < \
|
|
||||||
/tmp/nbdime-1-details.patch || true \
|
|
||||||
&& patch -d /opt/conda/lib/python3.6/site-packages -p1 --forward --reject-file=- < \
|
|
||||||
/tmp/nbdime-2-toc.patch || true
|
|
||||||
RUN rm /tmp/nbdime-*.patch
|
|
||||||
USER ${username}
|
|
||||||
WORKDIR ${workdir}
|
|
||||||
|
|
||||||
|
|
||||||
COPY docker/bashrc.bash /tmp/
|
COPY docker/bashrc.bash /tmp/
|
||||||
RUN cat /tmp/bashrc.bash >> ${home}/.bashrc
|
RUN cat /tmp/bashrc.bash >> ${home}/.bashrc
|
||||||
RUN echo "export PATH=\"${workdir}/docker/bin:$PATH\"" >> ${home}/.bashrc
|
RUN echo "export PATH=\"${workdir}/docker/bin:$PATH\"" >> ${home}/.bashrc
|
||||||
|
@ -81,11 +77,13 @@ RUN sudo rm /tmp/bashrc.bash
|
||||||
#RUN cat /tmp/jupyter_notebook_config.py >> ${home}/.jupyter/jupyter_notebook_config.py
|
#RUN cat /tmp/jupyter_notebook_config.py >> ${home}/.jupyter/jupyter_notebook_config.py
|
||||||
#RUN sudo rm /tmp/jupyter_notebook_config.py
|
#RUN sudo rm /tmp/jupyter_notebook_config.py
|
||||||
|
|
||||||
|
|
||||||
# INFO: Uncomment the RUN command below to disable git diff paging
|
# INFO: Uncomment the RUN command below to disable git diff paging
|
||||||
#RUN git config --global core.pager ''
|
#RUN git config --global core.pager ''
|
||||||
|
|
||||||
|
|
||||||
# INFO: Uncomment the RUN command below for easy and constant notebook URL (just localhost:8888)
|
# INFO: Uncomment the RUN command below for easy and constant notebook URL (just localhost:8888)
|
||||||
# That will switch jupyter to using empty password instead of a token.
|
# That will switch Jupyter to using empty password instead of a token.
|
||||||
# To avoid making a security hole you SHOULD in fact not only uncomment but
|
# To avoid making a security hole you SHOULD in fact not only uncomment but
|
||||||
# regenerate the hash for your own non-empty password and replace the hash below.
|
# regenerate the hash for your own non-empty password and replace the hash below.
|
||||||
# You can compute a password hash in any notebook, just run the code:
|
# You can compute a password hash in any notebook, just run the code:
|
||||||
|
|
|
@ -4,11 +4,11 @@ help:
|
||||||
run:
|
run:
|
||||||
docker-compose up
|
docker-compose up
|
||||||
exec:
|
exec:
|
||||||
docker-compose exec handson-ml bash
|
docker-compose exec handson-ml2 bash
|
||||||
build: stop .FORCE
|
build: stop .FORCE
|
||||||
docker-compose build
|
docker-compose build
|
||||||
rebuild: stop .FORCE
|
rebuild: stop .FORCE
|
||||||
docker-compose build --force-rm
|
docker-compose build --force-rm
|
||||||
stop:
|
stop:
|
||||||
docker stop handson-ml || true; docker rm handson-ml || true;
|
docker stop handson-ml2 || true; docker rm handson-ml2 || true;
|
||||||
.FORCE:
|
.FORCE:
|
||||||
|
|
|
@ -18,11 +18,11 @@ Some general knowledge about `docker` infrastructure might be useful (that's an
|
||||||
|
|
||||||
Switch to `docker` directory here and run `make build` (or `docker-compose build`) to build your docker image. That may take some time but is only required once. Or perhaps a few times after you tweak something in a `Dockerfile`.
|
Switch to `docker` directory here and run `make build` (or `docker-compose build`) to build your docker image. That may take some time but is only required once. Or perhaps a few times after you tweak something in a `Dockerfile`.
|
||||||
|
|
||||||
After the process is finished you have a `handson-ml` image, that will be the base for your experiments. You can confirm that looking on results of `docker images` command.
|
After the process is finished you have a `handson-ml2` image, that will be the base for your experiments. You can confirm that looking on results of `docker images` command.
|
||||||
|
|
||||||
### Run the notebooks
|
### Run the notebooks
|
||||||
|
|
||||||
Run `make run` (or just `docker-compose up`) to start the jupyter server inside the container (also named `handson-ml`, same as image). Just point your browser to the URL printed on the screen (or just <http://localhost:8888> if you enabled password authentication) and you're ready to play with the book's code!
|
Run `make run` (or just `docker-compose up`) to start the jupyter server inside the container (also named `handson-ml2`, same as image). Just point your browser to the URL printed on the screen (or just <http://localhost:8888> if you enabled password authentication) and you're ready to play with the book's code!
|
||||||
|
|
||||||
The server runs in the directory containing the notebooks, and the changes you make from the browser will be persisted there.
|
The server runs in the directory containing the notebooks, and the changes you make from the browser will be persisted there.
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ You can close the server just by pressing `Ctrl-C` in terminal window.
|
||||||
|
|
||||||
### Run additional commands in container
|
### Run additional commands in container
|
||||||
|
|
||||||
Run `make exec` (or `docker-compose exec handson-ml bash`) while the server is running to run an additional `bash` shell inside the `handson-ml` container. Now you're inside the environment prepared within the image.
|
Run `make exec` (or `docker-compose exec handson-ml2 bash`) while the server is running to run an additional `bash` shell inside the `handson-ml2` container. Now you're inside the environment prepared within the image.
|
||||||
|
|
||||||
One of the usefull things that can be done there would be starting TensorBoard (for example with simple `tb` command, see bashrc file).
|
One of the useful things that can be done there would be starting TensorBoard (for example with simple `tb` command, see bashrc file).
|
||||||
|
|
||||||
Another one may be comparing versions of the notebooks using the `nbdiff` command if you haven't got `nbdime` installed locally (it is **way** better than plain `diff` for notebooks). See [Tools for diffing and merging of Jupyter notebooks](https://github.com/jupyter/nbdime) for more details.
|
Another one may be comparing versions of the notebooks using the `nbdiff` command if you haven't got `nbdime` installed locally (it is **way** better than plain `diff` for notebooks). See [Tools for diffing and merging of Jupyter notebooks](https://github.com/jupyter/nbdime) for more details.
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
handson-ml:
|
handson-ml2:
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: ./docker/Dockerfile
|
dockerfile: ./docker/Dockerfile
|
||||||
args:
|
args:
|
||||||
- username=devel
|
- username=devel
|
||||||
- userid=1000
|
- userid=1000
|
||||||
container_name: handson-ml
|
container_name: handson-ml2
|
||||||
image: handson-ml
|
image: handson-ml2
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
logging:
|
logging:
|
||||||
driver: json-file
|
driver: json-file
|
||||||
options:
|
options:
|
||||||
|
@ -18,5 +18,5 @@ services:
|
||||||
- "8888:8888"
|
- "8888:8888"
|
||||||
- "6006:6006"
|
- "6006:6006"
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/home/devel/handson-ml
|
- ../:/home/devel/handson-ml2
|
||||||
command: /opt/conda/bin/jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser
|
command: /opt/conda/bin/jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
--- a/nbdime/diffing/notebooks.py
|
|
||||||
+++ b/nbdime/diffing/notebooks.py
|
|
||||||
@@ -548,8 +548,12 @@ def set_notebook_diff_targets(sources=True, outputs=True, attachments=True, meta
|
|
||||||
metadata_keys = ("/cells/*/metadata", "/metadata", "/cells/*/outputs/*/metadata")
|
|
||||||
if metadata:
|
|
||||||
for key in metadata_keys:
|
|
||||||
- if key in notebook_differs:
|
|
||||||
- del notebook_differs[key]
|
|
||||||
+ if details:
|
|
||||||
+ if key in notebook_differs:
|
|
||||||
+ del notebook_differs[key]
|
|
||||||
+ else:
|
|
||||||
+ notebook_differs[key] = diff_ignore_keys(
|
|
||||||
+ inner_differ=diff, ignore_keys=['collapsed', 'autoscroll', 'deletable', 'editable'])
|
|
||||||
else:
|
|
||||||
for key in metadata_keys:
|
|
||||||
notebook_differs[key] = diff_ignore
|
|
|
@ -1,11 +0,0 @@
|
||||||
--- a/nbdime/diffing/notebooks.py
|
|
||||||
+++ b/nbdime/diffing/notebooks.py
|
|
||||||
@@ -553,7 +553,7 @@
|
|
||||||
del notebook_differs[key]
|
|
||||||
else:
|
|
||||||
notebook_differs[key] = diff_ignore_keys(
|
|
||||||
- inner_differ=diff, ignore_keys=['collapsed', 'autoscroll', 'deletable', 'editable'])
|
|
||||||
+ inner_differ=diff, ignore_keys=['toc', 'collapsed', 'autoscroll', 'deletable', 'editable'])
|
|
||||||
else:
|
|
||||||
for key in metadata_keys:
|
|
||||||
notebook_differs[key] = diff_ignore
|
|
Loading…
Reference in New Issue