From a9850ba0c23fce99c5035ec399e93f440cb5aaf1 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 19 Apr 2021 09:59:41 +0200 Subject: [PATCH 1/7] version check --- dockers/nvidia/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dockers/nvidia/Dockerfile b/dockers/nvidia/Dockerfile index 6396ab43f65e6..2d1ced6708b04 100644 --- a/dockers/nvidia/Dockerfile +++ b/dockers/nvidia/Dockerfile @@ -13,7 +13,7 @@ # limitations under the License. # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel_21-03.html#rel_21-03 -FROM nvcr.io/nvidia/pytorch:20.12-py3 +FROM nvcr.io/nvidia/pytorch:21.03-py3 MAINTAINER PyTorchLightning @@ -21,6 +21,8 @@ ARG LIGHTNING_VERSION="" COPY ./ /workspace/pytorch-lightning/ +ENV TORCH_VERSION=$(python -c "import torch ; print(torch.__version__)") + RUN \ cd /workspace && \ mv pytorch-lightning/notebooks . && \ @@ -39,12 +41,13 @@ RUN \ pip install -r ./pytorch-lightning/requirements/extra.txt --no-cache-dir --upgrade-strategy only-if-needed && \ pip install -r ./pytorch-lightning/requirements/examples.txt --no-cache-dir --upgrade-strategy only-if-needed && \ pip install ./pytorch-lightning --no-cache-dir && \ - pip install "Pillow>=8.1" "torchtext>=0.9.0" ipython[all] --no-cache-dir --upgrade-strategy only-if-needed && \ + pip install "Pillow>=8.1" "torchtext>=0.9.1" ipython[all] --no-cache-dir --upgrade-strategy only-if-needed && \ rm -rf pytorch-lightning RUN python --version && \ pip --version && \ pip list && \ + python -c "import torch; assert torch.__version__ == '$TORCH_VERSION', torch.__version__" && \ python -c "import pytorch_lightning as pl; print(pl.__version__)" # CMD ["/bin/bash"] From c6cf7d18ad60117ba60a0bd796496a1dc9131c27 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 19 Apr 2021 23:40:22 +0200 Subject: [PATCH 2/7] ... --- dockers/nvidia/Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dockers/nvidia/Dockerfile b/dockers/nvidia/Dockerfile index 2d1ced6708b04..cf9f233e8f621 100644 --- a/dockers/nvidia/Dockerfile +++ b/dockers/nvidia/Dockerfile @@ -19,9 +19,9 @@ MAINTAINER PyTorchLightning ARG LIGHTNING_VERSION="" -COPY ./ /workspace/pytorch-lightning/ +RUN python -c "import torch ; print(torch.__version__)" >> torch_version.info -ENV TORCH_VERSION=$(python -c "import torch ; print(torch.__version__)") +COPY ./ /workspace/pytorch-lightning/ RUN \ cd /workspace && \ @@ -41,13 +41,16 @@ RUN \ pip install -r ./pytorch-lightning/requirements/extra.txt --no-cache-dir --upgrade-strategy only-if-needed && \ pip install -r ./pytorch-lightning/requirements/examples.txt --no-cache-dir --upgrade-strategy only-if-needed && \ pip install ./pytorch-lightning --no-cache-dir && \ - pip install "Pillow>=8.1" "torchtext>=0.9.1" ipython[all] --no-cache-dir --upgrade-strategy only-if-needed && \ + pip install "Pillow>=8.1" --no-cache-dir --upgrade-strategy only-if-needed && \ rm -rf pytorch-lightning -RUN python --version && \ +RUN \ + TORCH_VERSION=$(cat torch_version.info) && \ + rm torch_version.info && \ + python --version && \ pip --version && \ pip list && \ - python -c "import torch; assert torch.__version__ == '$TORCH_VERSION', torch.__version__" && \ + python -c "import torch; assert torch.__version__ == '$TORCH_VERSION', f'got: `{torch.__version__}` instead of `$TORCH_VERSION`'" && \ python -c "import pytorch_lightning as pl; print(pl.__version__)" # CMD ["/bin/bash"] From c30178d6766e7ea40ad93686c206bac32b56c1fb Mon Sep 17 00:00:00 2001 From: jirka Date: Thu, 22 Apr 2021 23:45:13 +0200 Subject: [PATCH 3/7] ... --- dockers/nvidia/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dockers/nvidia/Dockerfile b/dockers/nvidia/Dockerfile index cf9f233e8f621..c649842c647b9 100644 --- a/dockers/nvidia/Dockerfile +++ b/dockers/nvidia/Dockerfile @@ -42,15 +42,16 @@ RUN \ pip install -r ./pytorch-lightning/requirements/examples.txt --no-cache-dir --upgrade-strategy only-if-needed && \ pip install ./pytorch-lightning --no-cache-dir && \ pip install "Pillow>=8.1" --no-cache-dir --upgrade-strategy only-if-needed && \ - rm -rf pytorch-lightning + rm -rf pytorch-lightning && \ + pip list RUN \ TORCH_VERSION=$(cat torch_version.info) && \ rm torch_version.info && \ python --version && \ pip --version && \ - pip list && \ - python -c "import torch; assert torch.__version__ == '$TORCH_VERSION', f'got: `{torch.__version__}` instead of `$TORCH_VERSION`'" && \ + pip list | grep torch && \ + python -c "from torch import __version__ as ver ; assert ver == '$TORCH_VERSION', ver" && \ python -c "import pytorch_lightning as pl; print(pl.__version__)" # CMD ["/bin/bash"] From 2537d734f453772a915dee5b132708729480cf24 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 23 Apr 2021 00:25:29 +0200 Subject: [PATCH 4/7] ... --- dockers/nvidia/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dockers/nvidia/Dockerfile b/dockers/nvidia/Dockerfile index c649842c647b9..2a71fb42c6447 100644 --- a/dockers/nvidia/Dockerfile +++ b/dockers/nvidia/Dockerfile @@ -25,8 +25,6 @@ COPY ./ /workspace/pytorch-lightning/ RUN \ cd /workspace && \ - mv pytorch-lightning/notebooks . && \ - mv pytorch-lightning/pl_examples . && \ # replace by specific version if asked if [ ! -z "$LIGHTNING_VERSION" ] ; then \ rm -rf pytorch-lightning ; \ @@ -35,6 +33,9 @@ RUN \ mv pytorch-lightning-*/ pytorch-lightning ; \ rm *.zip ; \ fi && \ +# save the examples + mv pytorch-lightning/notebooks . && \ + mv pytorch-lightning/pl_examples . && \ # Installations python -c "fname = './pytorch-lightning/requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)" && \ @@ -45,6 +46,8 @@ RUN \ rm -rf pytorch-lightning && \ pip list +ENV PYTHONPATH="/workspace" + RUN \ TORCH_VERSION=$(cat torch_version.info) && \ rm torch_version.info && \ From 2385202fd821b2ec9a0d98dd98e16b395a5b0316 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 23 Apr 2021 00:53:20 +0200 Subject: [PATCH 5/7] cmd --- dockers/nvidia/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/nvidia/Dockerfile b/dockers/nvidia/Dockerfile index 2a71fb42c6447..41e5ddea8fc0b 100644 --- a/dockers/nvidia/Dockerfile +++ b/dockers/nvidia/Dockerfile @@ -57,4 +57,4 @@ RUN \ python -c "from torch import __version__ as ver ; assert ver == '$TORCH_VERSION', ver" && \ python -c "import pytorch_lightning as pl; print(pl.__version__)" -# CMD ["/bin/bash"] +CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"] From df950fdf730a2381c7d584dfcae54f69a2ca242e Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 23 Apr 2021 00:58:04 +0200 Subject: [PATCH 6/7] docs --- dockers/README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/dockers/README.md b/dockers/README.md index 89647ac443dde..5b2c1f088c49d 100644 --- a/dockers/README.md +++ b/dockers/README.md @@ -45,7 +45,7 @@ docker image list docker image rm pytorch-lightning:latest ``` -### Run docker image with GPUs +## Run docker image with GPUs To run docker image with access to you GPUs you need to install ```bash @@ -63,3 +63,23 @@ and later run the docker image with `--gpus all` so for example ``` docker run --rm -it --gpus all pytorchlightning/pytorch_lightning:base-cuda-py3.7-torch1.6 ``` + +## Run Jupyter server + +Inspiration comes from https://u.group/thinking/how-to-put-jupyter-notebooks-in-a-dockerfile + +1. Build the docker image: + ```bash + docker image build \ + -t pytorch-lightning:v1.2.9 \ + -f dockers/nvidia/Dockerfile \ + --build-arg LIGHTNING_VERSION=1.2.9 \ + . + ``` +2. start the server and map ports: + ```bash + docker run --rm -it --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all -p 8888:8888 pytorch-lightning:v1.2.9 + ``` +3. Connect in local browser: + - copy the generated path e.g. ` http://hostname:8888/?token=0719fa7e1729778b0cec363541a608d5003e26d4910983c6` + - replace the `hostname` by `localhost` \ No newline at end of file From 712e2da91febea2299f1e96f28c8505440fe12ed Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Fri, 23 Apr 2021 09:06:47 +0200 Subject: [PATCH 7/7] typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Carlos MocholĂ­ --- dockers/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockers/README.md b/dockers/README.md index 5b2c1f088c49d..eaafe2eda7739 100644 --- a/dockers/README.md +++ b/dockers/README.md @@ -81,5 +81,5 @@ Inspiration comes from https://u.group/thinking/how-to-put-jupyter-notebooks-in- docker run --rm -it --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all -p 8888:8888 pytorch-lightning:v1.2.9 ``` 3. Connect in local browser: - - copy the generated path e.g. ` http://hostname:8888/?token=0719fa7e1729778b0cec363541a608d5003e26d4910983c6` - - replace the `hostname` by `localhost` \ No newline at end of file + - copy the generated path e.g. `http://hostname:8888/?token=0719fa7e1729778b0cec363541a608d5003e26d4910983c6` + - replace the `hostname` by `localhost`