Olivier Grisel - EuroSciPy 2016
https://github.com/ogrisel/docker-distributed
Have a look a the notebooks in the examples
folder.
https://docs.docker.com/engine/installation/
$ docker run python:3.5 python -c "print(40 + 2)"
$ docker run python:3.5 python -c "print(40 + 2)"
$ docker run python:3.5 python -c "print(40 + 2)"
$ docker run --rm python:3.5 python -c "print(40 + 2)"
$ docker run --rm python:3.5 python -c "print(40 + 2)"Unable to find image 'python:3.5' locallylatest: Pulling from library/python357ea8c3d80b: Already exists52befadefd24: Pull complete3c0732d5313c: Pull completeceb711c7e301: Downloading [=========> ] 90.27 MB/129.7 MB4211bb537697: Download complete71f9074c0739: Download complete3e5349707036: Download complete
$ docker run --rm python:3.5 python -c "print(40 + 2)"Unable to find image 'python:3.5' locallylatest: Pulling from library/python357ea8c3d80b: Already exists52befadefd24: Pull complete3c0732d5313c: Pull completeceb711c7e301: Pull complete4211bb537697: Pull complete71f9074c0739: Pull complete3e5349707036: Pull completeDigest: sha256:a755ad5a30b2[...]Status: Downloaded newer image for python:3.542
$ docker run --rm python:3.5 python -c "print(40 + 2)"Unable to find image 'python:3.5' locallylatest: Pulling from library/python357ea8c3d80b: Already exists52befadefd24: Pull complete3c0732d5313c: Pull completeceb711c7e301: Pull complete4211bb537697: Pull complete71f9074c0739: Pull complete3e5349707036: Pull completeDigest: sha256:a755ad5a30b2[...]Status: Downloaded newer image for python:3.542$ docker run --rm python:3.5 python -c "print(40 + 3)"43
$ docker run --rm -ti python:3.5 bashroot@10d2dfedb935:/#
$ docker run --rm -ti python:3.5 bashroot@10d2dfedb935:/# ps PID TTY TIME CMD 1 ? 00:00:00 bash 8 ? 00:00:00 psroot@10d2dfedb935:/#
$ docker run --rm -ti python:3.5 bashroot@10d2dfedb935:/# ps PID TTY TIME CMD 1 ? 00:00:00 bash 8 ? 00:00:00 psroot@10d2dfedb935:/# pythonPython 3.5.2 (default, Aug 9 2016, 20:58:38)[GCC 4.9.2] on linux>>>
$ docker run --rm -ti python:3.5 bashroot@10d2dfedb935:/# ps PID TTY TIME CMD 1 ? 00:00:00 bash 8 ? 00:00:00 psroot@10d2dfedb935:/# pythonPython 3.5.2 (default, Aug 9 2016, 20:58:38)[GCC 4.9.2] on linux>>> 40 + 242
$ docker run --rm -ti python:3.5 bashroot@10d2dfedb935:/# ps PID TTY TIME CMD 1 ? 00:00:00 bash 8 ? 00:00:00 psroot@10d2dfedb935:/# pythonPython 3.5.2 (default, Aug 9 2016, 20:58:38)[GCC 4.9.2] on linux>>> 40 + 242>>> ^Droot@10d2dfedb935:/# exit
$ cd bokeh/bokeyjs$ npm install -g gulp$ gulp build[Bunch or errors caused by a broken nodejs install]
$ cd bokeh$ docker run --rm --volume $PWD:/io node \ bash -c "cd /io/bokehjs && npm install -g gulp && gulp build"
$ cd bokeh$ docker run --rm --volume $PWD:/io node \ bash -c "cd /io/bokehjs && npm install -g gulp && gulp build"
$ cd bokeh$ docker run --rm --volume $PWD:/io node \ bash -c "cd /io/bokehjs && npm install -g gulp && gulp build"npm info it worked if it ends with oknpm info using npm@3.10.3npm info using node@v6.4.0npm info attempt registry request try #1 at 12:45:51 PMnpm http request GET https://registry.npmjs.org/gulp[...] # Download the Internet[13:03:42] Finished 'build' after 10 s$ ls bokehjs/node_modules | wc -l604
$ git clone https://github.com/ogrisel/docker-distributed$ ls docker-distributeddocker-compose.ymlDockerfileexampleskubernetesREADME.mdrequirements.txt
$ git clone https://github.com/ogrisel/docker-distributed$ ls docker-distributeddocker-compose.ymlDockerfileexampleskubernetesREADME.mdrequirements.txt
$ git clone https://github.com/ogrisel/docker-distributed$ ls docker-distributeddocker-compose.ymlDockerfileexampleskubernetesREADME.mdrequirements.txt
FROM debian:jessieMAINTAINER Olivier Grisel <olivier.grisel@ensta.org>RUN apt-get update -yqq && apt-get install -yqq wget bzip2 git \ && rm -rf /var/lib/apt/lists/*# Configure environmentENV LC_ALL=C.UTF-8 LANG=C.UTF-8RUN mkdir /workWORKDIR /work# Install Python 3 from minicondaRUN wget -O miniconda.sh \ https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ && bash miniconda.sh -b -p /work/miniconda \ && rm miniconda.shENV PATH="/work/bin:/work/miniconda/bin:$PATH"RUN conda install -y \ pip \ notebook \ pandas \ scikit-learn \ && conda clean -tipsy# Install the master branch of distributed and daskCOPY requirements.txt .RUN pip install -r requirements.txt && rm -rf ~/.cache/pip/# Add the example notebooksCOPY examples .
$ docker build -t ogrisel/distributed .Sending build context to Docker daemon 178.2 kBStep 1 : FROM debian:jessie ---> 1b01529cc499Step 2 : MAINTAINER Olivier Grisel <olivier.grisel@ensta.org> ---> Using cache ---> 37887ee139f1Step 3 : RUN apt-get update -yqq && apt-get install -yqq wget [...] ---> Using cache ---> 3c2b8caccb80[...]
$ docker build -t ogrisel/distributed .Sending build context to Docker daemon 178.2 kBStep 1 : FROM debian:jessie ---> 1b01529cc499Step 2 : MAINTAINER Olivier Grisel <olivier.grisel@ensta.org> ---> Using cache ---> 37887ee139f1Step 3 : RUN apt-get update -yqq && apt-get install -yqq wget [...] ---> Using cache ---> 3c2b8caccb80[...]$ docker run --rm ogrisel/distributed \ python -c "import sklearn; print(sklearn.__version__)"0.17.1$ docker push ogrisel/distributed
Docker Swarm and Docker Compose
Kubernetes
DC/OS and Mesos
$ gcloud config set compute/zone europe-west1-d$ gcloud container clusters create cluster-1 \ --num-nodes 3 \ --machine-type n1-highcpu-32 \ --scopes bigquery,storage-rw \ --waitCreating cluster cluster-1...done.Created [https://container.googleapis.com/v1/.../cluster-1].kubeconfig entry generated for cluster-1.NAME ZONE ... MACHINE_TYPE NUM_NODES STATUScluster-1 europe-west1-d ... n1-highcpu-32 3 RUNNING
$ gcloud config set compute/zone europe-west1-d$ gcloud container clusters create cluster-1 \ --num-nodes 3 \ --machine-type n1-highcpu-32 \ --scopes bigquery,storage-rw \ --waitCreating cluster cluster-1...done.Created [https://container.googleapis.com/v1/.../cluster-1].kubeconfig entry generated for cluster-1.NAME ZONE ... MACHINE_TYPE NUM_NODES STATUScluster-1 europe-west1-d ... n1-highcpu-32 3 RUNNING
$ gcloud container clusters get-credentials cluster-1Fetching cluster endpoint and auth data.kubeconfig entry generated for cluster-1.
$ git clone https://github.com/ogrisel/docker-distributed$ cd docker-distributed$ kubectl create -f kubernetes/service "dscheduler" createdservice "dscheduler-status" createdreplicationcontroller "dscheduler" createdreplicationcontroller "dworker" createdservice "jupyter-notebook" createdreplicationcontroller "jupyter-notebook" created
$ git clone https://github.com/ogrisel/docker-distributed$ cd docker-distributed$ kubectl create -f kubernetes/service "dscheduler" createdservice "dscheduler-status" createdreplicationcontroller "dscheduler" createdreplicationcontroller "dworker" createdservice "jupyter-notebook" createdreplicationcontroller "jupyter-notebook" created
$ kubectl get servicesNAME CLUSTER-IP EXTERNAL-IP PORT(S)dscheduler 10.115.249.189 <none> 8786/TCP,9786/TCPdscheduler-status 10.115.244.201 130.211.50.206 8787/TCPjupyter-notebook 10.115.254.255 146.148.114.90 80/TCPkubernetes 10.115.240.1 <none> 443/TCP
apiVersion: v1kind: ReplicationControllermetadata: name: dworker-controllerspec: replicas: 3 selector: name: dworker template: metadata: labels: name: dworker spec: containers: - name: dworker image: ogrisel/distributed:latest args: ["dask-worker", "dscheduler:8786"]
Rackspace for free cloud resources to support SciPy projects and for helping the Python community in general.
Google for GCP credits to test distributed Python with Kubernetes.
Inria for supporting my work on scikit-learn and related projects.
"Supermicro Storage" by Robert: https://flic.kr/p/e17qr3
"smiiile!" by mooglet: https://flic.kr/p/am9zQe
"Docker Architecture" https://docs.docker.com/engine/understanding-docker/
"Container terminal" by Martin Abegglen: https://flic.kr/p/b7rw5D
"Symphonic Orchestra and Choir of the WYD" by HazteOir.org: https://flic.kr/p/c5B6Cd
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |