├── .gitignore
├── .travis.yml
├── LICENSE
├── Pipfile
├── README.md
├── cuda9.1-cudnn7-devel-python3.6
├── Dockerfile
└── start.sh
├── cuda9.1-devel-python3.6
├── Dockerfile
└── start.sh
├── cuda9.1-python3.6-tensorflow
├── Dockerfile
└── start.sh
├── cuda9.1-python3.6
├── Dockerfile
└── start.sh
├── cuda9.1-python3.7
├── Dockerfile
└── start.sh
├── docker-compose.build.stage01.yml
├── docker-compose.build.stage02.yml
├── python3.6-tensorflow
├── Dockerfile
└── start.sh
├── python3.6
├── Dockerfile
└── start.sh
├── python3.7
├── Dockerfile
└── start.sh
├── scripts
├── build-push.sh
├── deploy.sh
├── lint.sh
├── test-cuda.sh
├── test.sh
└── trigger-children.sh
└── tests
├── __init__.py
├── test_cpu
├── __init__.py
├── test_conda.py
└── test_conda_tensorflow.py
├── test_cuda
├── __init__.py
├── test_conda_cuda.py
└── test_conda_cuda_tensorflow.py
└── utils.py
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Python template
2 | # Byte-compiled / optimized / DLL files
3 | __pycache__/
4 | *.py[cod]
5 | *$py.class
6 | .mypy_cache
7 | .vscode
8 |
9 | # C extensions
10 | *.so
11 |
12 | # Distribution / packaging
13 | .Python
14 | env/
15 | build/
16 | develop-eggs/
17 | dist/
18 | downloads/
19 | eggs/
20 | .eggs/
21 | lib/
22 | lib64/
23 | parts/
24 | sdist/
25 | var/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .coverage
44 | .coverage.*
45 | .cache
46 | nosetests.xml
47 | coverage.xml
48 | *,cover
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 |
57 | # Sphinx documentation
58 | docs/_build/
59 |
60 | # PyBuilder
61 | target/
62 | ### JetBrains template
63 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
64 |
65 | *.iml
66 |
67 | ## Directory-based project format:
68 | .idea/
69 | # if you remove the above rule, at least ignore the following:
70 |
71 | # User-specific stuff:
72 | # .idea/workspace.xml
73 | # .idea/tasks.xml
74 | # .idea/dictionaries
75 |
76 | # Sensitive or high-churn files:
77 | # .idea/dataSources.ids
78 | # .idea/dataSources.xml
79 | # .idea/sqlDataSources.xml
80 | # .idea/dynamic.xml
81 | # .idea/uiDesigner.xml
82 |
83 | # Gradle:
84 | # .idea/gradle.xml
85 | # .idea/libraries
86 |
87 | # Mongo Explorer plugin:
88 | # .idea/mongoSettings.xml
89 |
90 | ## File-based project format:
91 | *.ipr
92 | *.iws
93 |
94 | ## Plugin-specific files:
95 |
96 | # IntelliJ
97 | /out/
98 |
99 | # mpeltonen/sbt-idea plugin
100 | .idea_modules/
101 |
102 | # JIRA plugin
103 | atlassian-ide-plugin.xml
104 |
105 | # Crashlytics plugin (for Android Studio and IntelliJ)
106 | com_crashlytics_export_strings.xml
107 | crashlytics.properties
108 | crashlytics-build.properties
109 |
110 | # Custom
111 | Pipfile.lock
112 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: xenial
2 |
3 | language: python
4 |
5 | python:
6 | - "3.7"
7 |
8 | install:
9 | - pip install docker pytest
10 |
11 | services:
12 | - docker
13 |
14 | script:
15 | - bash scripts/test.sh
16 |
17 | deploy:
18 | provider: script
19 | script: bash scripts/deploy.sh
20 | on:
21 | branch: master
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Sebastián Ramírez
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | name = "pypi"
3 | url = "https://pypi.org/simple"
4 | verify_ssl = true
5 |
6 | [dev-packages]
7 | docker = "*"
8 | black = "*"
9 | mypy = "*"
10 | pylint = "*"
11 | jupyter = "*"
12 | flake8 = "*"
13 | autoflake = "*"
14 |
15 | [requires]
16 | python_version = "3.6"
17 |
18 | [pipenv]
19 | allow_prereleases = true
20 |
21 | [packages]
22 | pytest = "*"
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 🚨 DEPRECATION WARNING 🚨
2 |
3 | I'm currently not using this Docker image and I'm currently not having time to maintain it. Some of the source code might be useful for you, but I suspect the installation of each of the components might have varied a bit through time, so you might be better off creating a new `Dockerfile` from scratch.
4 |
5 |
6 | [](https://travis-ci.org/tiangolo/python-machine-learning-docker)
7 |
8 | ## Supported tags and respective `Dockerfile` links
9 |
10 | * [`python3.7`, `latest` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/python3.7/Dockerfile)
11 | * [`python3.6` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/python3.6/Dockerfile)
12 | * [`cuda9.1-python3.7` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/cuda9.1-python3.7/Dockerfile)
13 | * [`cuda9.1-python3.6` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/cuda9.1-python3.6/Dockerfile)
14 | * [`python3.6-tensorflow` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/python3.6-tensorflow/Dockerfile)
15 | * [`cuda9.1-python3.6-tensorflow` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/cuda9.1-python3.6-tensorflow/Dockerfile)
16 | * [`cuda9.1-devel-python3.6` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/cuda9.1-devel-python3.6/Dockerfile)
17 | * [`cuda9.1-cudnn7-devel-python3.6` _(Dockerfile)_](https://github.com/tiangolo/python-machine-learning-docker/blob/master/cuda9.1-cudnn7-devel-python3.6/Dockerfile)
18 |
19 | # python-machine-learning
20 |
21 | [**Docker**](https://www.docker.com/) image with **[Python](https://www.python.org/) 3.7** and **3.6** for Machine Learning.
22 |
23 | Uses [**Conda**](https://conda.io/en/latest/) (installed with [Miniconda](https://docs.conda.io/en/latest/miniconda.html)).
24 |
25 | Includes optional variants with [**Nvidia CUDA**](https://www.geforce.com/hardware/technology/cuda).
26 |
27 | And optional variants with [**TensorFlow](https://www.tensorflow.org/).
28 |
29 | **GitHub repo**: [https://github.com/tiangolo/python-machine-learning-docker](https://github.com/tiangolo/python-machine-learning-docker)
30 |
31 | **Docker Hub image**: [https://hub.docker.com/r/tiangolo/python-machine-learning](https://hub.docker.com/r/tiangolo/python-machine-learning)
32 |
33 | ## Description
34 |
35 | This Docker image is made to serve as a base for other images and projects for Machine Learning, Data Science, Deep Learning, etc.
36 |
37 | It does not try to include every possible package. On the contrary, it tries to be as slim as possible, but having the minimal common requirements (the difficult parts) for most projects.
38 |
39 | By being slim, apart from reducing the size, it can be kept current more easily, and it can be tailored for each project, being equally useful for development and production.
40 |
41 | ### Conda
42 |
43 | It includes [**Conda**](https://conda.io/en/latest/) (Miniconda, the package manager from Anaconda).
44 |
45 | Conda is, more or less, the "de-facto" standard package manager for Machine Learning Python projects (Data Science, Deep Learning, etc).
46 |
47 | With it, you can install most of the packages used in Machine Learning with a simple command.
48 |
49 | For example, to install Pandas, you can run:
50 |
51 | ```bash
52 | conda install pandas
53 | ```
54 |
55 | In a `Dockerfile` you would add that with:
56 |
57 | ```Dockerfile
58 | RUN conda install -y pandas
59 | ```
60 |
61 | `conda` is especially useful for Machine Learning and Data Science (compared to other package managers like `pip`, `pipenv`) because in many cases it installs optimized versions, compiled with **Intel MKL** (which is not available via `pip`).
62 |
63 | For example, TensorFlow is compiled with [**Intel MKL-DNN**](https://www.anaconda.com/tensorflow-in-anaconda/), which gives up to 8x the performance achievable with `pip`.
64 |
65 | ### Nvidia CUDA
66 |
67 | [**Nvidia CUDA**](https://www.geforce.com/hardware/technology/cuda) is needed to be able to use the GPU, mainly for Deep Learning. There are optional image versions (tags) including CUDA.
68 |
69 | For these versions to work, you need to have an Nvidia GPU and have [**nvidia-docker**](https://github.com/NVIDIA/nvidia-docker) installed.
70 |
71 | **nvidia-docker** is in many cases easier to install and use than installing the full set of dependencies (CUDA, CuDNN, etc) in your local machine.
72 |
73 | This is especially true when you have more than one project, with different dependencies/versions.
74 |
75 | ### TensorFlow
76 |
77 | [**TensorFlow**](https://www.tensorflow.org/) is Google's very popular Deep Learning framework.
78 |
79 | There are versions (tags) of this image with **TensorFlow** already installed with `conda` (with its performance gains). Contrary to the official TensorFlow Docker images, that are installed with `pip`.
80 |
81 | There are also versions with TensorFlow and CUDA. So, you can run TensorFlow (built with the `conda` optimizations) on your GPU, from Docker.
82 |
83 | ## How to use
84 |
85 | * You don't need to clone the GitHub repo. You can use this image as a base image for other images, using this in your `Dockerfile`:
86 |
87 | ```Dockerfile
88 | FROM tiangolo/python-machine-learning:python3.7
89 |
90 | COPY ./main.py /app/main.py
91 | ```
92 |
93 | or any of the image variants, e.g.:
94 |
95 | ```Dockerfile
96 | FROM tiangolo/python-machine-learning:cuda9.1-python3.6-tensorflow
97 |
98 | COPY ./main.py /app/main.py
99 | ```
100 |
101 | By default it just checks and prints the versions of the software installed, Conda and Python. Also Nvida GPU and TensorFlow, in their respective image versions (tags).
102 |
103 | You can override that behavior and run your own program creating a file at `/start.sh`.
104 |
105 | For example:
106 |
107 | ```Dockerfile
108 | FROM tiangolo/python-machine-learning:python3.7
109 |
110 | COPY ./start.sh /start.sh
111 | RUN chmod +x /start.sh
112 |
113 | COPY ./main.py /app/main.py
114 | ```
115 |
116 | **Note**: As the default command (`CMD`) is to run `/start.sh`, if you provide/overwrite that file, you don't have to add a `CMD /start.sh` in your `Dockerfile`.
117 |
118 | ## CUDA Technical details
119 |
120 | First, to be able to run the CUDA versions with Docker you need to be on Linux, have Docker and an Nvidia GPU.
121 |
122 | Then, there are compatibility requirements between versions.
123 |
124 | ### CUDA, GPU Driver, Nvidia Model
125 |
126 | **CUDA** has to be a version that is compatible with the **Nvidia GPU driver**, which is compatible with a **GPU architecture** (a series of specific GPU models). The CUDA versions require Nvidia GPU driver versions "superior to" some driver number (they are backward compatible).
127 |
128 | You can see the [compatibility table](https://github.com/NVIDIA/nvidia-docker/wiki/CUDA#requirements) at the **nvidia-docker** site.
129 |
130 | ### GPU Driver availability in Linux
131 |
132 | As of 2019-03-06, the latest Nvidia driver for Linux is `418`, you can check in the [Nvidia Unix Drivers page](https://www.nvidia.com/object/unix.html).
133 |
134 | But the latest driver officially available for Ubuntu is `390`, check in the [Ubuntu Nvidia drivers page](https://help.ubuntu.com/community/BinaryDriverHowto/Nvidia).
135 |
136 | #### GPU Beta Drivers
137 |
138 | There is a more technical option to install beta drivers.
139 |
140 | You can [add the PPA (Personal Package Archive) for the user `~graphics-drivers`](https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa) and then you can install (as of 2019-03-06) up to version `410`.
141 |
142 | ### TensorFlow
143 |
144 | **TensorFlow** versions are compatible with specific versions of **CUDA**.
145 |
146 | There doesn't seem to be a single page specifying which versions of TensorFlow are compatible with which versions of CUDA, apart from the [GitHub releases page](https://github.com/tensorflow/tensorflow/releases).
147 |
148 | The latest requirements (including CUDA version) (for the latest version of TensorFlow) can be found at the [GPU support section](https://www.tensorflow.org/install/gpu) in the official docs.
149 |
150 | ### Conda
151 |
152 | **Conda** has TensorFlow pre-compiled (with the optimizations) in specific versions, compiled with specific versions of **CUDA**.
153 |
154 | You can install TensorFlow with a specific CUDA version with, e.g.:
155 |
156 | ```bash
157 | conda install tensorflow-gpu cudatoolkit=9.0
158 | ```
159 |
160 | that will install TensorFlow compiled with GPU support (with CUDA) using a CUDA version of 9.0.
161 |
162 | To see the available `cudatoolkit` versions in `conda`, you can run:
163 |
164 | ```bash
165 | conda search cudatoolkit
166 | ```
167 |
168 | ### Current state
169 |
170 | As of 2019-03-06, as the latest Nvidia driver officially [available for Ubuntu is `390`](https://help.ubuntu.com/community/BinaryDriverHowto/Nvidia), this limits the [compatible version of CUDA to max `9.1`](https://github.com/NVIDIA/nvidia-docker/wiki/CUDA#requirements) (unless using the beta drivers).
171 |
172 | That's why the current CUDA flavor is version `9.1`. Even though there are superior base image versions, but those wouldn't run on an Ubuntu machine unless using the beta drivers (or drivers installed by hand, directly from the Nvidia site).
173 |
174 | Then, Conda has `cudatoolkit` available in several versions, the latest are `9.0`, `9.2` and `10.0`. But as the base image is `9.1`, the latest version that is still compatible is `9.0`. That's the version used in the image tag with TensorFlow and CUDA. But as they are backward compatible, it works.
175 |
176 | ### Decide your versions
177 |
178 | **Note**: this will apply when this image has more CUDA versions (tags). As of now, it only describes the process to decide versions and build this image.
179 |
180 | First, check what is the architecture of your GPU, then what is the most recent driver you can install (deciding if you want to have beta drivers).
181 |
182 | This applies for local development or cloud (if you use a cloud server with GPU).
183 |
184 | Then, see what is the latest CUDA version you can have with that driver.
185 |
186 | Then you can get the latest tag (version) of this image that is less than or equal to your driver.
187 |
188 | Next, find which versions of `cudatoolkit` (CUDA) are available in `conda`. Choose the latest one that is less than or equal to the image you chose.
189 |
190 | Then you can install TensorFlow with that `cudatoolkit`.
191 |
192 | ## Tests
193 |
194 | All the image tags are tested.
195 |
196 | CUDA (GPU usage) is tested locally (as CI systems don't provide GPUs easily).
197 |
198 | To run the tests, you need to have the [`Docker SDK for Python`](https://docker-py.readthedocs.io/en/stable/index.html) installed.
199 |
200 | If you are using Pipenv locally, you can install the development dependencies with:
201 |
202 | ```bash
203 | pipenv shell
204 | pipenv install --dev
205 | ```
206 |
207 | Then you can run the tests locally:
208 |
209 | ```bash
210 | bash scripts/test.sh
211 | ```
212 |
213 | You can also run the CUDA (GPU) tests:
214 |
215 | ```bash
216 | bash scripts/test-cuda.sh
217 | ```
218 |
219 | ## Release Notes
220 |
221 | ### Next Release
222 |
223 | * Upgrade Travis. PR [#5](https://github.com/tiangolo/python-machine-learning-docker/pull/5).
224 |
225 | * Add cuDNN version, to compile projects like [dlib](http://dlib.net/) that require the CUDA and cuDNN development toolkit. PR #4.
226 |
227 | * Add CUDA `devel` version, to compile projects like [dlib](http://dlib.net/) that require the CUDA development toolkit. PR #3.
228 |
229 | ### 0.3.0
230 |
231 | * All images are now based on `buildpack-deps:latest` (or equivalent) as is the official image for Python. PR #2.
232 |
233 | ### 0.2.0
234 |
235 | * Refactor image tags, remove `conda-` prefix to all images to simplify. PR #1.
236 |
237 | ### 0.1.0
238 |
239 | * First release, including Conda, Python 3.7, Python 3.6, CUDA and TensorFlow.
240 |
241 | ## License
242 |
243 | This project is licensed under the terms of the MIT license.
244 |
--------------------------------------------------------------------------------
/cuda9.1-cudnn7-devel-python3.6/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nvidia/cuda:9.1-cudnn7-devel
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | # Install buildpack-deps:latest with its base image parts, as it is the base for official Python
6 |
7 | # buildpack-deps:curl https://github.com/docker-library/buildpack-deps/blob/master/stretch/curl/Dockerfile
8 | RUN apt-get update && apt-get install -y --no-install-recommends \
9 | ca-certificates \
10 | curl \
11 | netbase \
12 | wget \
13 | && rm -rf /var/lib/apt/lists/*
14 |
15 | RUN set -ex; \
16 | if ! command -v gpg > /dev/null; then \
17 | apt-get update; \
18 | apt-get install -y --no-install-recommends \
19 | gnupg \
20 | dirmngr \
21 | ; \
22 | rm -rf /var/lib/apt/lists/*; \
23 | fi
24 | # End buildpack-deps:curl
25 |
26 | # buildpack-deps:scm https://github.com/docker-library/buildpack-deps/blob/master/stretch/scm/Dockerfile
27 |
28 | # procps is very common in build systems, and is a reasonably small package
29 | RUN apt-get update && apt-get install -y --no-install-recommends \
30 | bzr \
31 | git \
32 | mercurial \
33 | openssh-client \
34 | subversion \
35 | \
36 | procps \
37 | && rm -rf /var/lib/apt/lists/*
38 |
39 | # End buildpack-deps:scm
40 |
41 | # buildpack-deps:latest https://github.com/docker-library/buildpack-deps/blob/master/stretch/Dockerfile
42 |
43 | RUN set -ex; \
44 | apt-get update; \
45 | apt-get install -y --no-install-recommends \
46 | autoconf \
47 | automake \
48 | bzip2 \
49 | dpkg-dev \
50 | file \
51 | g++ \
52 | gcc \
53 | imagemagick \
54 | libbz2-dev \
55 | libc6-dev \
56 | libcurl4-openssl-dev \
57 | libdb-dev \
58 | libevent-dev \
59 | libffi-dev \
60 | libgdbm-dev \
61 | libgeoip-dev \
62 | libglib2.0-dev \
63 | libgmp-dev \
64 | libjpeg-dev \
65 | libkrb5-dev \
66 | liblzma-dev \
67 | libmagickcore-dev \
68 | libmagickwand-dev \
69 | libncurses5-dev \
70 | libncursesw5-dev \
71 | libpng-dev \
72 | libpq-dev \
73 | libreadline-dev \
74 | libsqlite3-dev \
75 | libssl-dev \
76 | libtool \
77 | libwebp-dev \
78 | libxml2-dev \
79 | libxslt-dev \
80 | libyaml-dev \
81 | make \
82 | patch \
83 | unzip \
84 | xz-utils \
85 | zlib1g-dev \
86 | \
87 | # https://lists.debian.org/debian-devel-announce/2016/09/msg00000.html
88 | $( \
89 | # if we use just "apt-cache show" here, it returns zero because "Can't select versions from package 'libmysqlclient-dev' as it is purely virtual", hence the pipe to grep
90 | if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
91 | echo 'default-libmysqlclient-dev'; \
92 | else \
93 | echo 'libmysqlclient-dev'; \
94 | fi \
95 | ) \
96 | ; \
97 | rm -rf /var/lib/apt/lists/*
98 |
99 | # End buildpack-deps:latest
100 |
101 | ENV PYTHON_VERSION=3.6
102 |
103 | # Conda, fragments from: https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
104 | # Explicit install of Python 3.7 with:
105 | # /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
106 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
107 | ENV PATH /opt/conda/bin:$PATH
108 |
109 | RUN apt-get update --fix-missing && \
110 | apt-get install -y wget bzip2 ca-certificates curl git && \
111 | apt-get clean && \
112 | rm -rf /var/lib/apt/lists/*
113 |
114 | RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O ~/miniconda.sh && \
115 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \
116 | rm ~/miniconda.sh && \
117 | /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
118 | /opt/conda/bin/conda clean -tipsy && \
119 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
120 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
121 | echo "conda activate base" >> ~/.bashrc
122 |
123 | # End Conda
124 |
125 | # Tini: https://github.com/krallin/tini
126 | ENV TINI_VERSION v0.18.0
127 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
128 | RUN chmod +x /tini
129 | ENTRYPOINT ["/tini", "--"]
130 | # End Tini
131 |
132 | COPY ./start.sh /start.sh
133 | RUN chmod +x /start.sh
134 |
135 | CMD [ "/start.sh" ]
136 |
--------------------------------------------------------------------------------
/cuda9.1-cudnn7-devel-python3.6/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 | nvidia-smi
9 |
--------------------------------------------------------------------------------
/cuda9.1-devel-python3.6/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nvidia/cuda:9.1-devel
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | # Install buildpack-deps:latest with its base image parts, as it is the base for official Python
6 |
7 | # buildpack-deps:curl https://github.com/docker-library/buildpack-deps/blob/master/stretch/curl/Dockerfile
8 | RUN apt-get update && apt-get install -y --no-install-recommends \
9 | ca-certificates \
10 | curl \
11 | netbase \
12 | wget \
13 | && rm -rf /var/lib/apt/lists/*
14 |
15 | RUN set -ex; \
16 | if ! command -v gpg > /dev/null; then \
17 | apt-get update; \
18 | apt-get install -y --no-install-recommends \
19 | gnupg \
20 | dirmngr \
21 | ; \
22 | rm -rf /var/lib/apt/lists/*; \
23 | fi
24 | # End buildpack-deps:curl
25 |
26 | # buildpack-deps:scm https://github.com/docker-library/buildpack-deps/blob/master/stretch/scm/Dockerfile
27 |
28 | # procps is very common in build systems, and is a reasonably small package
29 | RUN apt-get update && apt-get install -y --no-install-recommends \
30 | bzr \
31 | git \
32 | mercurial \
33 | openssh-client \
34 | subversion \
35 | \
36 | procps \
37 | && rm -rf /var/lib/apt/lists/*
38 |
39 | # End buildpack-deps:scm
40 |
41 | # buildpack-deps:latest https://github.com/docker-library/buildpack-deps/blob/master/stretch/Dockerfile
42 |
43 | RUN set -ex; \
44 | apt-get update; \
45 | apt-get install -y --no-install-recommends \
46 | autoconf \
47 | automake \
48 | bzip2 \
49 | dpkg-dev \
50 | file \
51 | g++ \
52 | gcc \
53 | imagemagick \
54 | libbz2-dev \
55 | libc6-dev \
56 | libcurl4-openssl-dev \
57 | libdb-dev \
58 | libevent-dev \
59 | libffi-dev \
60 | libgdbm-dev \
61 | libgeoip-dev \
62 | libglib2.0-dev \
63 | libgmp-dev \
64 | libjpeg-dev \
65 | libkrb5-dev \
66 | liblzma-dev \
67 | libmagickcore-dev \
68 | libmagickwand-dev \
69 | libncurses5-dev \
70 | libncursesw5-dev \
71 | libpng-dev \
72 | libpq-dev \
73 | libreadline-dev \
74 | libsqlite3-dev \
75 | libssl-dev \
76 | libtool \
77 | libwebp-dev \
78 | libxml2-dev \
79 | libxslt-dev \
80 | libyaml-dev \
81 | make \
82 | patch \
83 | unzip \
84 | xz-utils \
85 | zlib1g-dev \
86 | \
87 | # https://lists.debian.org/debian-devel-announce/2016/09/msg00000.html
88 | $( \
89 | # if we use just "apt-cache show" here, it returns zero because "Can't select versions from package 'libmysqlclient-dev' as it is purely virtual", hence the pipe to grep
90 | if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
91 | echo 'default-libmysqlclient-dev'; \
92 | else \
93 | echo 'libmysqlclient-dev'; \
94 | fi \
95 | ) \
96 | ; \
97 | rm -rf /var/lib/apt/lists/*
98 |
99 | # End buildpack-deps:latest
100 |
101 | ENV PYTHON_VERSION=3.6
102 |
103 | # Conda, fragments from: https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
104 | # Explicit install of Python 3.7 with:
105 | # /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
106 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
107 | ENV PATH /opt/conda/bin:$PATH
108 |
109 | RUN apt-get update --fix-missing && \
110 | apt-get install -y wget bzip2 ca-certificates curl git && \
111 | apt-get clean && \
112 | rm -rf /var/lib/apt/lists/*
113 |
114 | RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O ~/miniconda.sh && \
115 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \
116 | rm ~/miniconda.sh && \
117 | /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
118 | /opt/conda/bin/conda clean -tipsy && \
119 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
120 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
121 | echo "conda activate base" >> ~/.bashrc
122 |
123 | # End Conda
124 |
125 | # Tini: https://github.com/krallin/tini
126 | ENV TINI_VERSION v0.18.0
127 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
128 | RUN chmod +x /tini
129 | ENTRYPOINT ["/tini", "--"]
130 | # End Tini
131 |
132 | COPY ./start.sh /start.sh
133 | RUN chmod +x /start.sh
134 |
135 | CMD [ "/start.sh" ]
136 |
--------------------------------------------------------------------------------
/cuda9.1-devel-python3.6/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 | nvidia-smi
9 |
--------------------------------------------------------------------------------
/cuda9.1-python3.6-tensorflow/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM tiangolo/python-machine-learning:cuda9.1-python3.6
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | # cudatoolkit=9.1 is not available yet in Conda
6 | RUN conda install tensorflow-gpu cudatoolkit=9.0
7 |
8 | COPY ./start.sh /start.sh
9 | RUN chmod +x /start.sh
10 |
11 | CMD [ "/start.sh" ]
12 |
--------------------------------------------------------------------------------
/cuda9.1-python3.6-tensorflow/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 | nvidia-smi
9 |
10 | python -c "import tensorflow as tf; print('tensorflow version: ' + str(tf.__version__))"
11 |
12 | python -c "import tensorflow as tf; tf.enable_eager_execution(); print('tensorflow compute: ' + str(tf.reduce_sum(tf.random_normal([1000, 1000]))))"
13 |
14 | python -c "import tensorflow as tf; sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))"
15 |
--------------------------------------------------------------------------------
/cuda9.1-python3.6/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nvidia/cuda:9.1-base
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | # Install buildpack-deps:latest with its base image parts, as it is the base for official Python
6 |
7 | # buildpack-deps:curl https://github.com/docker-library/buildpack-deps/blob/master/stretch/curl/Dockerfile
8 | RUN apt-get update && apt-get install -y --no-install-recommends \
9 | ca-certificates \
10 | curl \
11 | netbase \
12 | wget \
13 | && rm -rf /var/lib/apt/lists/*
14 |
15 | RUN set -ex; \
16 | if ! command -v gpg > /dev/null; then \
17 | apt-get update; \
18 | apt-get install -y --no-install-recommends \
19 | gnupg \
20 | dirmngr \
21 | ; \
22 | rm -rf /var/lib/apt/lists/*; \
23 | fi
24 | # End buildpack-deps:curl
25 |
26 | # buildpack-deps:scm https://github.com/docker-library/buildpack-deps/blob/master/stretch/scm/Dockerfile
27 |
28 | # procps is very common in build systems, and is a reasonably small package
29 | RUN apt-get update && apt-get install -y --no-install-recommends \
30 | bzr \
31 | git \
32 | mercurial \
33 | openssh-client \
34 | subversion \
35 | \
36 | procps \
37 | && rm -rf /var/lib/apt/lists/*
38 |
39 | # End buildpack-deps:scm
40 |
41 | # buildpack-deps:latest https://github.com/docker-library/buildpack-deps/blob/master/stretch/Dockerfile
42 |
43 | RUN set -ex; \
44 | apt-get update; \
45 | apt-get install -y --no-install-recommends \
46 | autoconf \
47 | automake \
48 | bzip2 \
49 | dpkg-dev \
50 | file \
51 | g++ \
52 | gcc \
53 | imagemagick \
54 | libbz2-dev \
55 | libc6-dev \
56 | libcurl4-openssl-dev \
57 | libdb-dev \
58 | libevent-dev \
59 | libffi-dev \
60 | libgdbm-dev \
61 | libgeoip-dev \
62 | libglib2.0-dev \
63 | libgmp-dev \
64 | libjpeg-dev \
65 | libkrb5-dev \
66 | liblzma-dev \
67 | libmagickcore-dev \
68 | libmagickwand-dev \
69 | libncurses5-dev \
70 | libncursesw5-dev \
71 | libpng-dev \
72 | libpq-dev \
73 | libreadline-dev \
74 | libsqlite3-dev \
75 | libssl-dev \
76 | libtool \
77 | libwebp-dev \
78 | libxml2-dev \
79 | libxslt-dev \
80 | libyaml-dev \
81 | make \
82 | patch \
83 | unzip \
84 | xz-utils \
85 | zlib1g-dev \
86 | \
87 | # https://lists.debian.org/debian-devel-announce/2016/09/msg00000.html
88 | $( \
89 | # if we use just "apt-cache show" here, it returns zero because "Can't select versions from package 'libmysqlclient-dev' as it is purely virtual", hence the pipe to grep
90 | if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
91 | echo 'default-libmysqlclient-dev'; \
92 | else \
93 | echo 'libmysqlclient-dev'; \
94 | fi \
95 | ) \
96 | ; \
97 | rm -rf /var/lib/apt/lists/*
98 |
99 | # End buildpack-deps:latest
100 |
101 | ENV PYTHON_VERSION=3.6
102 |
103 | # Conda, fragments from: https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
104 | # Explicit install of Python 3.7 with:
105 | # /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
106 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
107 | ENV PATH /opt/conda/bin:$PATH
108 |
109 | RUN apt-get update --fix-missing && \
110 | apt-get install -y wget bzip2 ca-certificates curl git && \
111 | apt-get clean && \
112 | rm -rf /var/lib/apt/lists/*
113 |
114 | RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O ~/miniconda.sh && \
115 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \
116 | rm ~/miniconda.sh && \
117 | /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
118 | /opt/conda/bin/conda clean -tipsy && \
119 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
120 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
121 | echo "conda activate base" >> ~/.bashrc
122 |
123 | # End Conda
124 |
125 | # Tini: https://github.com/krallin/tini
126 | ENV TINI_VERSION v0.18.0
127 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
128 | RUN chmod +x /tini
129 | ENTRYPOINT ["/tini", "--"]
130 | # End Tini
131 |
132 | COPY ./start.sh /start.sh
133 | RUN chmod +x /start.sh
134 |
135 | CMD [ "/start.sh" ]
136 |
--------------------------------------------------------------------------------
/cuda9.1-python3.6/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 | nvidia-smi
9 |
--------------------------------------------------------------------------------
/cuda9.1-python3.7/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nvidia/cuda:9.1-base
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | # Install buildpack-deps:latest with its base image parts, as it is the base for official Python
6 |
7 | # buildpack-deps:curl https://github.com/docker-library/buildpack-deps/blob/master/stretch/curl/Dockerfile
8 | RUN apt-get update && apt-get install -y --no-install-recommends \
9 | ca-certificates \
10 | curl \
11 | netbase \
12 | wget \
13 | && rm -rf /var/lib/apt/lists/*
14 |
15 | RUN set -ex; \
16 | if ! command -v gpg > /dev/null; then \
17 | apt-get update; \
18 | apt-get install -y --no-install-recommends \
19 | gnupg \
20 | dirmngr \
21 | ; \
22 | rm -rf /var/lib/apt/lists/*; \
23 | fi
24 | # End buildpack-deps:curl
25 |
26 | # buildpack-deps:scm https://github.com/docker-library/buildpack-deps/blob/master/stretch/scm/Dockerfile
27 |
28 | # procps is very common in build systems, and is a reasonably small package
29 | RUN apt-get update && apt-get install -y --no-install-recommends \
30 | bzr \
31 | git \
32 | mercurial \
33 | openssh-client \
34 | subversion \
35 | \
36 | procps \
37 | && rm -rf /var/lib/apt/lists/*
38 |
39 | # End buildpack-deps:scm
40 |
41 | # buildpack-deps:latest https://github.com/docker-library/buildpack-deps/blob/master/stretch/Dockerfile
42 |
43 | RUN set -ex; \
44 | apt-get update; \
45 | apt-get install -y --no-install-recommends \
46 | autoconf \
47 | automake \
48 | bzip2 \
49 | dpkg-dev \
50 | file \
51 | g++ \
52 | gcc \
53 | imagemagick \
54 | libbz2-dev \
55 | libc6-dev \
56 | libcurl4-openssl-dev \
57 | libdb-dev \
58 | libevent-dev \
59 | libffi-dev \
60 | libgdbm-dev \
61 | libgeoip-dev \
62 | libglib2.0-dev \
63 | libgmp-dev \
64 | libjpeg-dev \
65 | libkrb5-dev \
66 | liblzma-dev \
67 | libmagickcore-dev \
68 | libmagickwand-dev \
69 | libncurses5-dev \
70 | libncursesw5-dev \
71 | libpng-dev \
72 | libpq-dev \
73 | libreadline-dev \
74 | libsqlite3-dev \
75 | libssl-dev \
76 | libtool \
77 | libwebp-dev \
78 | libxml2-dev \
79 | libxslt-dev \
80 | libyaml-dev \
81 | make \
82 | patch \
83 | unzip \
84 | xz-utils \
85 | zlib1g-dev \
86 | \
87 | # https://lists.debian.org/debian-devel-announce/2016/09/msg00000.html
88 | $( \
89 | # if we use just "apt-cache show" here, it returns zero because "Can't select versions from package 'libmysqlclient-dev' as it is purely virtual", hence the pipe to grep
90 | if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
91 | echo 'default-libmysqlclient-dev'; \
92 | else \
93 | echo 'libmysqlclient-dev'; \
94 | fi \
95 | ) \
96 | ; \
97 | rm -rf /var/lib/apt/lists/*
98 |
99 | # End buildpack-deps:latest
100 |
101 | ENV PYTHON_VERSION=3.7
102 |
103 | # Conda, fragments from: https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
104 | # Explicit install of Python 3.7 with:
105 | # /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
106 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
107 | ENV PATH /opt/conda/bin:$PATH
108 |
109 | RUN apt-get update --fix-missing && \
110 | apt-get install -y wget bzip2 ca-certificates curl git && \
111 | apt-get clean && \
112 | rm -rf /var/lib/apt/lists/*
113 |
114 | RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O ~/miniconda.sh && \
115 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \
116 | rm ~/miniconda.sh && \
117 | /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
118 | /opt/conda/bin/conda clean -tipsy && \
119 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
120 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
121 | echo "conda activate base" >> ~/.bashrc
122 |
123 | # End Conda
124 |
125 | # Tini: https://github.com/krallin/tini
126 | ENV TINI_VERSION v0.18.0
127 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
128 | RUN chmod +x /tini
129 | ENTRYPOINT ["/tini", "--"]
130 | # End Tini
131 |
132 | COPY ./start.sh /start.sh
133 | RUN chmod +x /start.sh
134 |
135 | CMD [ "/start.sh" ]
136 |
--------------------------------------------------------------------------------
/cuda9.1-python3.7/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 | nvidia-smi
9 |
--------------------------------------------------------------------------------
/docker-compose.build.stage01.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | latest:
4 | build: ./python3.7
5 | image: tiangolo/python-machine-learning:latest
6 | python3.7:
7 | build: ./python3.7
8 | image: tiangolo/python-machine-learning:python3.7
9 | python3.6:
10 | build: ./python3.6
11 | image: tiangolo/python-machine-learning:python3.6
12 | cuda9.1-python3.7:
13 | build: ./cuda9.1-python3.7
14 | image: tiangolo/python-machine-learning:cuda9.1-python3.7
15 | cuda9.1-python3.6:
16 | build: ./cuda9.1-python3.6
17 | image: tiangolo/python-machine-learning:cuda9.1-python3.6
18 | cuda9.1-devel-python3.6:
19 | build: ./cuda9.1-devel-python3.6
20 | image: tiangolo/python-machine-learning:cuda9.1-devel-python3.6
21 | cuda9.1-cudnn7-devel-python3.6:
22 | build: ./cuda9.1-cudnn7-devel-python3.6
23 | image: tiangolo/python-machine-learning:cuda9.1-cudnn7-devel-python3.6
24 |
--------------------------------------------------------------------------------
/docker-compose.build.stage02.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | python3.6-tensorflow:
4 | build: ./python3.6-tensorflow
5 | image: tiangolo/python-machine-learning:python3.6-tensorflow
6 | cuda9.1-python3.6-tensorflow:
7 | build: ./cuda9.1-python3.6-tensorflow
8 | image: tiangolo/python-machine-learning:cuda9.1-python3.6-tensorflow
9 |
--------------------------------------------------------------------------------
/python3.6-tensorflow/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM tiangolo/python-machine-learning:python3.6
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | RUN conda install tensorflow
6 |
7 | COPY ./start.sh /start.sh
8 | RUN chmod +x /start.sh
9 |
10 | CMD [ "/start.sh" ]
11 |
--------------------------------------------------------------------------------
/python3.6-tensorflow/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 | python -c "import tensorflow as tf; print('tensorflow version: ' + str(tf.__version__))"
9 |
10 | python -c "import tensorflow as tf; tf.enable_eager_execution(); print('tensorflow compute: ' + str(tf.reduce_sum(tf.random_normal([1000, 1000]))))"
11 |
--------------------------------------------------------------------------------
/python3.6/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM buildpack-deps:stretch
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | ENV PYTHON_VERSION=3.6
6 |
7 | # Conda, fragments from: https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
8 | # Explicit install of Python 3.7 with:
9 | # /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
10 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
11 | ENV PATH /opt/conda/bin:$PATH
12 |
13 | RUN apt-get update --fix-missing && \
14 | apt-get install -y wget bzip2 ca-certificates curl git && \
15 | apt-get clean && \
16 | rm -rf /var/lib/apt/lists/*
17 |
18 | RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O ~/miniconda.sh && \
19 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \
20 | rm ~/miniconda.sh && \
21 | /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
22 | /opt/conda/bin/conda clean -tipsy && \
23 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
24 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
25 | echo "conda activate base" >> ~/.bashrc
26 |
27 | # End Conda
28 |
29 | # Tini: https://github.com/krallin/tini
30 | ENV TINI_VERSION v0.18.0
31 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
32 | RUN chmod +x /tini
33 | ENTRYPOINT ["/tini", "--"]
34 | # End Tini
35 |
36 | COPY ./start.sh /start.sh
37 | RUN chmod +x /start.sh
38 |
39 | CMD [ "/start.sh" ]
40 |
--------------------------------------------------------------------------------
/python3.6/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
8 |
--------------------------------------------------------------------------------
/python3.7/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM buildpack-deps:stretch
2 |
3 | LABEL maintainer="Sebastian Ramirez "
4 |
5 | ENV PYTHON_VERSION=3.7
6 |
7 | # Conda, fragments from: https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
8 | # Explicit install of Python 3.7 with:
9 | # /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
10 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
11 | ENV PATH /opt/conda/bin:$PATH
12 |
13 | RUN apt-get update --fix-missing && \
14 | apt-get install -y wget bzip2 ca-certificates curl git && \
15 | apt-get clean && \
16 | rm -rf /var/lib/apt/lists/*
17 |
18 | RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O ~/miniconda.sh && \
19 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \
20 | rm ~/miniconda.sh && \
21 | /opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
22 | /opt/conda/bin/conda clean -tipsy && \
23 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
24 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
25 | echo "conda activate base" >> ~/.bashrc
26 |
27 | # End Conda
28 |
29 | # Tini: https://github.com/krallin/tini
30 | ENV TINI_VERSION v0.18.0
31 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
32 | RUN chmod +x /tini
33 | ENTRYPOINT ["/tini", "--"]
34 | # End Tini
35 |
36 | COPY ./start.sh /start.sh
37 | RUN chmod +x /start.sh
38 |
39 | CMD [ "/start.sh" ]
40 |
--------------------------------------------------------------------------------
/python3.7/start.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env sh
2 | set -e
3 |
4 | echo "conda version: $(conda --version)"
5 |
6 | python -c 'import sys; print("python version: {}.{}".format(sys.version_info.major, sys.version_info.minor))'
7 |
--------------------------------------------------------------------------------
/scripts/build-push.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
7 |
8 | docker-compose -f docker-compose.build.stage01.yml build
9 |
10 | docker-compose -f docker-compose.build.stage01.yml push
11 |
12 | docker-compose -f docker-compose.build.stage02.yml build
13 |
14 | docker-compose -f docker-compose.build.stage02.yml push
15 |
--------------------------------------------------------------------------------
/scripts/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | bash scripts/build-push.sh
7 |
8 | bash scripts/trigger-children.sh
9 |
--------------------------------------------------------------------------------
/scripts/lint.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -x
4 |
5 | autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place ./ --exclude=__init__.py
6 | isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --apply ./
7 | black ./
8 |
--------------------------------------------------------------------------------
/scripts/test-cuda.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 |
4 | pytest tests/test_cuda
5 |
--------------------------------------------------------------------------------
/scripts/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 |
4 | docker-compose -f docker-compose.build.stage01.yml build
5 | docker-compose -f docker-compose.build.stage02.yml build
6 | pytest tests/test_cpu
7 |
--------------------------------------------------------------------------------
/scripts/trigger-children.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | set -x
5 |
6 | echo "No children yet"
7 |
8 | # body='{
9 | # "request": {
10 | # "branch":"master"
11 | # }}'
12 |
13 | # for child in tiangolo%2Fuvicorn-gunicorn-fastapi-docker tiangolo%2Fuvicorn-gunicorn-starlette-docker; do
14 | # curl -s -X POST \
15 | # -H "Content-Type: application/json" \
16 | # -H "Accept: application/json" \
17 | # -H "Travis-API-Version: 3" \
18 | # -H "Authorization: token $TRAVIS_TOKEN" \
19 | # -d "$body" \
20 | # https://api.travis-ci.org/repo/$child/requests
21 | # done
22 |
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiangolo/python-machine-learning-docker/3fa897f015f393ca89a389b1b323c6475e20c8a5/tests/__init__.py
--------------------------------------------------------------------------------
/tests/test_cpu/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiangolo/python-machine-learning-docker/3fa897f015f393ca89a389b1b323c6475e20c8a5/tests/test_cpu/__init__.py
--------------------------------------------------------------------------------
/tests/test_cpu/test_conda.py:
--------------------------------------------------------------------------------
1 | import docker
2 | import pytest
3 |
4 | from ..utils import CONTAINER_NAME, remove_previous_container
5 |
6 | client = docker.from_env()
7 |
8 |
9 | def verify_container(logs, python_version):
10 | assert "conda version: conda 4." in logs
11 | assert f"python version: {python_version}" in logs
12 |
13 |
14 | @pytest.mark.parametrize(
15 | "image,python_version",
16 | [
17 | ("tiangolo/python-machine-learning:python3.6", "3.6"),
18 | ("tiangolo/python-machine-learning:python3.7", "3.7"),
19 | ],
20 | )
21 | def test_defaults(image, python_version):
22 | remove_previous_container(client)
23 | logs = client.containers.run(image, name=CONTAINER_NAME, remove=True)
24 | verify_container(logs.decode("utf-8"), python_version)
25 |
--------------------------------------------------------------------------------
/tests/test_cpu/test_conda_tensorflow.py:
--------------------------------------------------------------------------------
1 | import docker
2 | import pytest
3 |
4 | from ..utils import CONTAINER_NAME, remove_previous_container
5 |
6 | client = docker.from_env()
7 |
8 |
9 | def verify_container(logs, python_version):
10 | assert "conda version: conda 4." in logs
11 | assert f"python version: {python_version}" in logs
12 | assert "tensorflow version: " in logs
13 | assert "tensorflow compute: " in logs
14 |
15 |
16 | @pytest.mark.parametrize(
17 | "image,python_version",
18 | [("tiangolo/python-machine-learning:python3.6-tensorflow", "3.6")],
19 | )
20 | def test_defaults(image, python_version):
21 | remove_previous_container(client)
22 | logs = client.containers.run(image, name=CONTAINER_NAME, remove=True)
23 | verify_container(logs.decode("utf-8"), python_version)
24 |
--------------------------------------------------------------------------------
/tests/test_cuda/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiangolo/python-machine-learning-docker/3fa897f015f393ca89a389b1b323c6475e20c8a5/tests/test_cuda/__init__.py
--------------------------------------------------------------------------------
/tests/test_cuda/test_conda_cuda.py:
--------------------------------------------------------------------------------
1 | import docker
2 | import pytest
3 |
4 | from ..utils import CONTAINER_NAME, remove_previous_container
5 |
6 | client = docker.from_env()
7 |
8 |
9 | def verify_container(logs, python_version):
10 | assert "conda version: conda 4." in logs
11 | assert f"python version: {python_version}" in logs
12 | assert "NVIDIA-SMI" in logs
13 | assert "GPU Memory" in logs
14 |
15 |
16 | @pytest.mark.parametrize(
17 | "image,python_version",
18 | [
19 | ("tiangolo/python-machine-learning:cuda9.1-python3.6", "3.6"),
20 | ("tiangolo/python-machine-learning:cuda9.1-python3.7", "3.7"),
21 | ("tiangolo/python-machine-learning:cuda9.1-devel-python3.6", "3.6"),
22 | ("tiangolo/python-machine-learning:cuda9.1-cudnn7-devel-python3.6", "3.6"),
23 | ],
24 | )
25 | def test_defaults(image, python_version):
26 | remove_previous_container(client)
27 | logs = client.containers.run(image, name=CONTAINER_NAME, remove=True)
28 | verify_container(logs.decode("utf-8"), python_version)
29 |
--------------------------------------------------------------------------------
/tests/test_cuda/test_conda_cuda_tensorflow.py:
--------------------------------------------------------------------------------
1 | import docker
2 | import pytest
3 |
4 | from ..utils import CONTAINER_NAME, remove_previous_container
5 |
6 | client = docker.from_env()
7 |
8 |
9 | def verify_container(logs, python_version):
10 | assert "conda version: conda 4." in logs
11 | assert f"python version: {python_version}" in logs
12 | assert "tensorflow version: " in logs
13 | assert "tensorflow compute: " in logs
14 | assert "NVIDIA-SMI" in logs
15 | assert "GPU Memory" in logs
16 | assert "GPU device" in logs
17 | assert "device:GPU:0" in logs
18 |
19 |
20 | @pytest.mark.parametrize(
21 | "image,python_version",
22 | [("tiangolo/python-machine-learning:cuda9.1-python3.6-tensorflow", "3.6")],
23 | )
24 | def test_defaults(image, python_version):
25 | remove_previous_container(client)
26 | logs = client.containers.run(image, name=CONTAINER_NAME, remove=True)
27 | verify_container(logs.decode("utf-8"), python_version)
28 |
--------------------------------------------------------------------------------
/tests/utils.py:
--------------------------------------------------------------------------------
1 | from docker.errors import NotFound
2 |
3 | CONTAINER_NAME = "python-machine-learning-testconctainer"
4 | IMAGE_NAME = "python-machine-learning-testimage"
5 |
6 |
7 | def remove_previous_container(client):
8 | try:
9 | previous = client.containers.get(CONTAINER_NAME)
10 | previous.stop()
11 | previous.remove()
12 | except NotFound:
13 | return None
14 |
15 |
16 | def get_logs(container):
17 | logs: str = container.logs()
18 | return logs.decode("utf-8")
19 |
--------------------------------------------------------------------------------