-
Notifications
You must be signed in to change notification settings - Fork 18
/
theano-cu9.0-dnn7.0-18.03.dockerfile
125 lines (106 loc) · 3.57 KB
/
theano-cu9.0-dnn7.0-18.03.dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
MAINTAINER Chi-Hung Weng <wengchihung@gmail.com>
ARG THEANO_VER=rel-1.0.1
ARG LIBGPUARRAY_VER=v0.7.5
RUN apt update && apt install -y --no-install-recommends \
build-essential \
curl \
wget \
git \
ca-certificates \
cmake \
python \
python3-dev \
python3-setuptools \
python3-nose \
python3-mako \
libopenblas-dev \
libpq-dev \
libxml2-dev \
libxslt1-dev \
libldap2-dev \
libsasl2-dev \
libffi-dev \
libglib2.0 \
libsm6 \
libxrender-dev \
libxext-dev \
graphviz \
vim \
&& \
apt clean && \
rm -rf /var/lib/apt/lists/*
# Get pip for Python3.
RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && \
rm get-pip.py
# Install some useful and deep-learning-related packages for Python3.
RUN pip3 --no-cache-dir install \
h5py==2.7.0 \
jupyter \
matplotlib \
seaborn \
bokeh \
numpy==1.13.3 \
scipy \
pandas \
sklearn \
scikit-image \
autograd \
mlxtend \
pydot-ng \
imgaug \
cython \
opencv-contrib-python
# Obtain libgpuarray & pygpu.
RUN git clone https://github.com/Theano/libgpuarray.git /opt/libgpuarray && \
git -C /opt/libgpuarray checkout ${LIBGPUARRAY_VER}
WORKDIR /opt/libgpuarray
# Build and Install libgpuarray & pygpu.
RUN mkdir Build && \
cd Build && \
cmake .. -DCMAKE_BUILD_TYPE=Release && \
make && \
make install && \
cd .. && \
python3 setup.py build && \
python3 setup.py install && \
ldconfig
# Obtain Theano
RUN git clone git://github.com/Theano/Theano.git /opt/theano && \
git -C /opt/theano checkout $THEANO_VER
WORKDIR /opt/theano
# Build and Install Theano
RUN python3 setup.py build && \
python3 setup.py install && \
cd .. && \
pip3 --no-cache-dir install Theano
ENV THEANO_FLAGS 'device=cuda,floatX=float32'
# FP32 is used by default. You can always reset this flag.
# Install Keras.
RUN pip3 --no-cache-dir install keras
# Tell Keras to use Theano as its backend.
RUN mkdir /root/.keras && \
wget -O /root/.keras/keras.json https://raw.githubusercontent.com/chi-hung/DockerbuildsKeras/master/keras-cntk.json && \
sed -i -e 's/cntk/theano/g' /root/.keras/keras.json
# Set up our notebook config.
RUN mkdir /root/.jupyter && \
cd /root/.jupyter && \
wget https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/docker/jupyter_notebook_config.py
# Jupyter has issues with being run directly:
# https://github.com/ipython/ipython/issues/7062
# We just add a little wrapper script.
RUN cd / && \
wget https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/docker/run_jupyter.sh && \
chmod +x run_jupyter.sh
# Add a sample notebook.
RUN mkdir /notebooks && \
wget -O /notebooks/MNISTDemoKeras.ipynb https://raw.githubusercontent.com/chi-hung/PythonTutorial/master/code_examples/KerasMNISTDemo.ipynb
WORKDIR /notebooks
# Add the "ipyrun" command. It runs the notebook & stores the obtained results into a HTML file.
RUN printf '#!/bin/bash\njupyter nbconvert --ExecutePreprocessor.timeout=None \
--allow-errors \
--to html \
--execute $1' > /sbin/ipyrun && \
chmod +x /sbin/ipyrun
CMD ["/run_jupyter.sh", "--allow-root"]