Skip to content

Commit 6bb3441

Browse files
committed
new base image
1 parent 69de894 commit 6bb3441

File tree

7 files changed

+98
-56
lines changed

7 files changed

+98
-56
lines changed

Dockerfile

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,76 @@
1-
FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04
2-
# Contributors: Syed Navaid (https://github.com/syedahmad)
3-
# Vlad Hosu (https://github.com/subpic)
1+
FROM nvcr.io/nvidia/tensorflow:20.09-tf2-py3
42

3+
ENV DEBIAN_FRONTEND noninteractive
54
RUN apt-get update && apt-get install -y \
6-
wget \
7-
vim \
8-
bzip2 \
9-
graphviz \
10-
mc \
11-
htop \
12-
emacs-nox \
13-
rsync \
14-
less \
15-
curl \
16-
#software-properties-common \
17-
build-essential \
18-
libfreetype6-dev \
19-
libpng12-dev \
20-
openssh-client
21-
22-
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
23-
24-
#Downgrade CUDA, TF issue: https://github.com/tensorflow/tensorflow/issues/17566#issuecomment-372490062
25-
RUN apt-get install --allow-downgrades --allow-change-held-packages -y libcudnn7=7.0.5.15-1+cuda9.0 git-lfs
26-
27-
#Install MINICONDA
28-
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda.sh && \
29-
/bin/bash Miniconda.sh -b -p /opt/conda && \
30-
rm Miniconda.sh
5+
wget \
6+
vim \
7+
bzip2 \
8+
graphviz \
9+
mc \
10+
htop \
11+
emacs-nox \
12+
rsync \
13+
less \
14+
curl \
15+
build-essential \
16+
openssh-server \
17+
imagemagick
3118

19+
# Install MINICONDA
20+
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda.sh && \
21+
/bin/bash Miniconda.sh -b -p /opt/conda && \
22+
rm Miniconda.sh
3223
ENV PATH /opt/conda/bin:$PATH
24+
RUN conda update -y -n base -c defaults conda
3325

34-
#Install ANACONDA Environment
35-
RUN conda create -y -n jupyter_env python=3.6 nb_conda_kernels py-xgboost-gpu \
36-
anaconda ipykernel tensorflow-gpu keras-gpu matplotlib numpy scipy pandas \
37-
Pillow pydot munch scikit-learn && \
38-
/opt/conda/envs/jupyter_env/bin/pip install jupyter-tensorboard gitless opencv-python && \
39-
/opt/conda/envs/jupyter_env/bin/python -m ipykernel.kernelspec
40-
41-
RUN conda create -y -n jupyter_env27 python=2.7 nb_conda_kernels py-xgboost-gpu \
42-
anaconda ipykernel tensorflow-gpu keras-gpu matplotlib numpy scipy pandas \
43-
Pillow pydot munch scikit-learn && \
44-
/opt/conda/envs/jupyter_env27/bin/pip install jupyter-tensorboard gitless opencv-python && \
45-
/opt/conda/envs/jupyter_env27/bin/python -m ipykernel.kernelspec
26+
# CREATE ENV and INSTALL
27+
RUN conda create -y -n jupyter_env python nb_conda_kernels py-xgboost-gpu \
28+
anaconda ipykernel tensorflow-gpu keras-gpu matplotlib numpy scipy pandas \
29+
Pillow pydot munch scikit-learn future \
30+
&& /opt/conda/envs/jupyter_env/bin/pip install jupytext jupyter-tensorboard \
31+
gitless opencv-python tensorflow-gpu==2.4.1 \
32+
&& /opt/conda/envs/jupyter_env/bin/python -m ipykernel.kernelspec
4633

4734
# Install OpenCV
4835
RUN apt-get update && apt-get install -y libopencv-dev && \
4936
echo 'ln /dev/null /dev/raw1394' >> ~/.bashrc
5037

38+
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
39+
ENV PATH $HOME/.poetry/bin:$PATH
40+
5141
RUN set -x \
5242
&& cd /tmp \
5343
&& wget https://github.com/sdg-mit/gitless/releases/download/v0.8.8/gl-v0.8.8-linux-x86_64.tar.gz \
5444
&& tar -C /usr/bin/ -xvf gl-v0.8.8-linux-x86_64.tar.gz --strip-components=1 \
5545
&& rm -f gl-v0.8.8-linux-x86_64.tar.gz
5646

5747
COPY docker_deps/entrypoint.sh /root/
48+
COPY tests/test_libraries.py /tmp/
5849
COPY configs/jupyter_notebook_config.py /root/.jupyter/
5950

60-
RUN chmod +x /root/entrypoint.sh
51+
RUN chmod +x /root/entrypoint.sh && \
52+
chown -R 777 /tmp/test_libraries.py
6153

62-
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
63-
ENV PYTHONPATH='/mnt/home/research/:/mnt/home/:$PYTHONPATH'
64-
ENV PASSWORD unknownknowns
65-
ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:$LD_LIBRARY_PATH
54+
RUN mkdir /var/run/sshd \
55+
&& echo 'root:jupyter-data-science' | chpasswd \
56+
&& sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config \
57+
&& sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
58+
&& echo "export VISIBLE=now" >> /etc/profile
59+
ENV NOTVISIBLE "in users profile"
60+
61+
RUN useradd -rm -d /home/science -s /bin/bash -g root -G sudo -u 1000 science \
62+
&& echo 'science:jupyter-data-science' | chpasswd
63+
64+
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 \
65+
PYTHONPATH='/mnt/home/research/:/mnt/home/:$PYTHONPATH' \
66+
PASSWORD=jupyter-data-science \
67+
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
6668

6769
WORKDIR /mnt/home/
6870

69-
# IPython
70-
EXPOSE 8888 6006
71+
# Jupyter + Tensorboard + SSHD
72+
EXPOSE 8888 6006 22
7173

7274
CMD bash /root/entrypoint.sh
75+
76+

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Vlad Hosu
3+
Copyright (c) 2019-2021 Vlad Hosu
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
# Jupyter-Lab Data Science Dockerfile
2-
This is a jupyter-lab based setup for data science, including Anaconda environments for Python (v2 and v3), with Keras + Tensorflow GPU and XGBoost GPU.
1+
## Build
32

4-
After building the image, run using:
53
```
6-
nvidia-docker run -v $PWD:/mnt/home/ -p 8888:8888 -p 6006:6006 jupyter-data-science "$@"
4+
docker build -f Dockerfile -t jupyter-dl .
75
```
86

9-
The entrypoint script accepts Jupyter-Lab arguments:
7+
## Execute
108

119
```
12-
e.g. nvidia-docker run -v $PWD:/mnt/home/ -p 8888:8888 -p 6006:6006 jupyter-data-science --notebook-dir=/mnt/home
10+
nvidia-docker run -v $PWD:/mnt/home/ -p 8888:8888 -p 6006:6006 jupyter-dl
11+
```
12+
13+
Note: The entrypoint script accepts Jupyter-Lab arguments
14+
15+
```
16+
e.g. nvidia-docker run -v $PWD:/mnt/home/ -p 8888:8888 -p 6006:6006 jupyter-dl --notebook-dir=/mnt/home
1317
```

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docker build -f Dockerfile -t jupyter-data-science .
1+
docker build -f Dockerfile -t jupyter-dl .

docker_deps/entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
# ==============================================================================
1616

1717
conda init bash
18-
nohup /opt/conda/envs/jupyter_env/bin/tensorboard --logdir=/mnt/home/research/data/logs&
18+
nohup /opt/conda/envs/jupyter_env/bin/tensorboard --logdir=/mnt/home/logs&
19+
nohup /usr/sbin/sshd -D&
1920
/opt/conda/envs/jupyter_env/bin/jupyter-lab "$@" --allow-root

test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nvidia-docker run -v $PWD:/mnt/home/ -p 8888:8888 -p 6006:6006 jupyter-dl "$@"

tests/test_libraries.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import xgboost as xgb
2+
import sklearn
3+
import tensorflow
4+
import keras
5+
import numpy as np
6+
import unittest
7+
8+
from tensorflow.python.client import device_lib
9+
from keras import backend as K
10+
11+
12+
def get_available_gpus():
13+
local_device_protos = device_lib.list_local_devices()
14+
return [x.name for x in local_device_protos if x.device_type == 'GPU']
15+
16+
17+
class TestGPULibraries(unittest.TestCase):
18+
19+
def test_tensorflow(self):
20+
gpus = get_available_gpus()
21+
assert(len(gpus))
22+
23+
def test_keras_gpu(self):
24+
gpus = K.tensorflow_backend._get_available_gpus()
25+
assert(len(gpus))
26+
27+
def test_xgboost_gpu(self):
28+
gbm = xgb.XGBRegressor(silent=False, tree_method = 'gpu_hist')
29+
X = np.random.rand(10,10)
30+
y = np.random.rand(10)
31+
r = gbm.fit(X, y, verbose=True)
32+
assert(np.mean(np.abs(r.predict(X)-y)))

0 commit comments

Comments
 (0)