Skip to content

Commit dcf6e4e

Browse files
authored
remake nvidia docker (#6686)
* use latest * remake * examples
1 parent f0c5479 commit dcf6e4e

File tree

6 files changed

+84
-22
lines changed

6 files changed

+84
-22
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ jobs:
116116
- script: |
117117
set -e
118118
python -m pytest pl_examples -v --maxfail=2 --durations=0
119-
python setup.py install --user --quiet
120-
bash pl_examples/run_ddp-example.sh
119+
pip install . --user --quiet
120+
bash pl_examples/run_examples-args.sh --gpus 1 --max_epochs 1 --batch_size 64 --limit_train_batches 5 --limit_val_batches 3
121+
bash pl_examples/run_ddp-examples.sh --max_epochs 1 --batch_size 32 --limit_train_batches 2 --limit_val_batches 2
121122
# cd pl_examples/basic_examples
122123
# bash submit_ddp_job.sh
123124
# bash submit_ddp2_job.sh

dockers/nvidia/Dockerfile

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,68 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM nvcr.io/nvidia/pytorch:21.02-py3
15+
FROM nvcr.io/nvidia/cuda:11.1.1-runtime-ubuntu20.04
1616

1717
MAINTAINER PyTorchLightning <https://github.com/PyTorchLightning>
1818

1919
ARG LIGHTNING_VERSION=""
2020

21-
COPY ./ ./pytorch-lightning/
21+
SHELL ["/bin/bash", "-c"]
22+
# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/
23+
ENV \
24+
DEBIAN_FRONTEND=noninteractive \
25+
TZ=Europe/Prague \
26+
PATH="$PATH:/root/.local/bin" \
27+
CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda" \
28+
MKL_THREADING_LAYER=GNU
29+
30+
RUN apt-get update -qq && \
31+
apt-get install -y --no-install-recommends \
32+
build-essential \
33+
python3 \
34+
python3-distutils \
35+
python3-dev \
36+
pkg-config \
37+
cmake \
38+
git \
39+
wget \
40+
unzip \
41+
ca-certificates \
42+
&& \
43+
44+
# Cleaning
45+
apt-get autoremove -y && \
46+
apt-get clean && \
47+
rm -rf /root/.cache && \
48+
rm -rf /var/lib/apt/lists/* && \
49+
50+
# Setup PIP
51+
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
52+
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate && \
53+
python get-pip.py && \
54+
rm get-pip.py && \
55+
pip --version
56+
57+
COPY ./ /home/pytorch-lightning/
2258

23-
# install dependencies
2459
RUN \
25-
#conda install "pip>20.1" && \
26-
pip list | grep torch && \
60+
cd /home && \
61+
mv pytorch-lightning/notebooks . && \
62+
mv pytorch-lightning/pl_examples . && \
63+
# replace by specific version if asked
2764
if [ ! -z "$LIGHTNING_VERSION" ] ; then \
2865
rm -rf pytorch-lightning ; \
2966
wget https://github.com/PyTorchLightning/pytorch-lightning/archive/${LIGHTNING_VERSION}.zip --progress=bar:force:noscroll ; \
3067
unzip ${LIGHTNING_VERSION}.zip ; \
3168
mv pytorch-lightning-*/ pytorch-lightning ; \
3269
rm *.zip ; \
3370
fi && \
34-
pip install ./pytorch-lightning["extra"] --no-cache-dir && \
71+
72+
# Installations
73+
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)" && \
74+
pip install -r ./pytorch-lightning/requirements/extra.txt -U --no-cache-dir && \
75+
pip install -r ./pytorch-lightning/requirements/examples.txt -U --no-cache-dir && \
76+
pip install ./pytorch-lightning --no-cache-dir && \
3577
rm -rf pytorch-lightning
3678

3779
RUN python --version && \

dockers/release/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ MAINTAINER PyTorchLightning <https://github.com/PyTorchLightning>
2121

2222
ARG LIGHTNING_VERSION=""
2323

24-
COPY ./ ./pytorch-lightning/
24+
COPY ./ /home/pytorch-lightning/
2525

2626
# install dependencies
2727
RUN \
28-
#conda install "pip>20.1" && \
28+
cd /home && \
29+
mv pytorch-lightning/notebooks . && \
30+
mv pytorch-lightning/pl_examples . && \
31+
# replace by specific version if asked
2932
if [ ! -z "$LIGHTNING_VERSION" ] ; then \
3033
rm -rf pytorch-lightning ; \
3134
wget https://github.com/PyTorchLightning/pytorch-lightning/archive/${LIGHTNING_VERSION}.zip --progress=bar:force:noscroll ; \

pl_examples/run_ddp-example.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

pl_examples/run_ddp-examples.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
ARGS_EXTRA_DDP=" --gpus 2 --accelerator ddp"
4+
ARGS_EXTRA_AMP=" --precision 16"
5+
6+
python pl_examples/basic_examples/simple_image_classifier.py $@ ${ARGS_EXTRA_DDP}
7+
python pl_examples/basic_examples/simple_image_classifier.py $@ ${ARGS_EXTRA_DDP} ${ARGS_EXTRA_AMP}
8+
9+
python pl_examples/basic_examples/backbone_image_classifier.py $@ ${ARGS_EXTRA_DDP}
10+
python pl_examples/basic_examples/backbone_image_classifier.py $@ ${ARGS_EXTRA_DDP} ${ARGS_EXTRA_AMP}
11+
12+
python pl_examples/basic_examples/autoencoder.py $@ ${ARGS_EXTRA_DDP}
13+
python pl_examples/basic_examples/autoencoder.py $@ ${ARGS_EXTRA_DDP} ${ARGS_EXTRA_AMP}

pl_examples/run_examples-args.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
echo $@
4+
5+
full_path=$(realpath $0)
6+
echo $full_path
7+
8+
dir_path=$(dirname $full_path)
9+
echo $dir_path
10+
11+
python ${dir_path}/basic_examples/simple_image_classifier.py $@
12+
13+
python ${dir_path}/basic_examples/backbone_image_classifier.py $@
14+
15+
python ${dir_path}/basic_examples/autoencoder.py $@

0 commit comments

Comments
 (0)