66
Containers for Science and High-Performance Computing Dmitry Spodarets Root Linux GlobalLogic Conference 2017

Containers for Science and High-Performance Computing

Embed Size (px)

Citation preview

Page 1: Containers for Science and High-Performance Computing

Containers for Science and High-Performance Computing

Dmitry Spodarets

Root Linux GlobalLogic Conference 2017

Page 2: Containers for Science and High-Performance Computing

Who am I

Dmitry Spodarets• Founder and CEO at FlyElephant

• PhD candidate at Odessa National University

• Lecturer at Odessa Polytechnic University • Organizer of technical conferences about

Data Science, HPC, JS, Web Technologies …

Page 3: Containers for Science and High-Performance Computing

Data ScienceRendering

Engineering Simulation

Academia

Page 4: Containers for Science and High-Performance Computing

FlyElephant

We automate Data Science and Engineering Simulationand help teams to work efficiently.

Computing resources

Ready-computing infrastructure

Collaboration& Sharing

Fast Deployment

Expert Community

Page 5: Containers for Science and High-Performance Computing

Agenda

•Scientific tasks•Computing resources•High-Performance Computing•Containers •Singularity•Conferences

Page 6: Containers for Science and High-Performance Computing

Scientific tasks

Page 7: Containers for Science and High-Performance Computing

Healthcare Financial RetailLife Sciences Manufacturing

Page 8: Containers for Science and High-Performance Computing

Scientific Method

Page 9: Containers for Science and High-Performance Computing

Computing resources

Page 10: Containers for Science and High-Performance Computing

Computing resources

Page 11: Containers for Science and High-Performance Computing

Computing resources

NVIDIADGX-1Deep Learning Supercomputer

GPU Xeon Phi

FPGA

Page 12: Containers for Science and High-Performance Computing

1080 vs Titan X vs K80 vs P100

0,25

8,8

0,3

10,1

2,9

8,7

5,3

10,6

0

2

4

6

8

10

12

FP32(Singleprecision) FP64(Doubleprecision)

1080 TitanX K80 P100

http://www.nvidia.com/

TFLO

PS

Page 13: Containers for Science and High-Performance Computing

Public Cloud

Page 14: Containers for Science and High-Performance Computing

High-Performance Computingand Supercomputer

Page 15: Containers for Science and High-Performance Computing

Big tasks – big power

Page 16: Containers for Science and High-Performance Computing

HPC

SunwayTaihuLight / China10,649,600 Cores125,436TFlop/s

Page 17: Containers for Science and High-Performance Computing

HPC in the Cloud

Page 18: Containers for Science and High-Performance Computing

Hybrid HPC

Page 19: Containers for Science and High-Performance Computing

What about elastic environment?

Page 20: Containers for Science and High-Performance Computing

Containers

Page 21: Containers for Science and High-Performance Computing

Docker

Page 22: Containers for Science and High-Performance Computing

Timeline of LXC Tools

http://kiwenlau.blogspot.com/2015/01/linux-container-technology-overview.html

Page 23: Containers for Science and High-Performance Computing

Containers vs Virtual Machines

Page 24: Containers for Science and High-Performance Computing

Docker (Dockerfile)

FROM registry.flyelephant.net/leap

MAINTAINER Dmitry Spodarets <[email protected]>

RUN zypper ref && zypper -n in blender && zypper clean

Page 25: Containers for Science and High-Performance Computing

Docker (build.sh)

#!/bin/bashfunction docker_build {

docker build -t $1 ./$1; docker tag $1 registry.flyelephant.net/$1 docker push registry.flyelephant.net/$1 docker rmi $1 registry.flyelephant.net/$1

}case $1 in all)

for i in `cat build.list`; do docker_build $i;

done ;;

*) docker_build $1;;

esac

Page 26: Containers for Science and High-Performance Computing

Docker Hub

Page 27: Containers for Science and High-Performance Computing

Docker

1. docker images

2. docker run --memory 512m --cpus="2" --name mycont registry.flyelephant.net/tensorflow

3. docker exec -i -t mycont bash

4. docker ps

5. docker stats

6. docker stop CONTAINER ID

7. docker start CONTAINER ID

8. docker rm CONTAINER ID

Page 28: Containers for Science and High-Performance Computing

Docker Machine

• Amazon Web Services

• Digital Ocean

• Exoscale

• Generic

• Google Compute Engine

• IBM Softlayer

• Microsoft Azure

• Microsoft Hyper-V

• OpenStack

• Oracle

• VirtualBox

• Rackspace

• VMware Fusion

• VMware v

• Cloud Air

• VMware vSphere

docker-machine create --driver azure --azure-subscription-id subscription-id --azure-resource-group resourcename --azure-ssh-user user --azure-size machine-name

docker-machine ssh machine-name

Page 29: Containers for Science and High-Performance Computing

But

Page 30: Containers for Science and High-Performance Computing

Generally containers technologies have been designed to solve a single primary use case for the

enterprise:

micro-service virtualization

Page 31: Containers for Science and High-Performance Computing

This is *NOT* the scientific or HPC use case!

So… what is our use case?

Page 32: Containers for Science and High-Performance Computing

Scientists are like Pirates, pillaging for resources instead of booty!

We want to run our jobs. We want to get results.

Page 33: Containers for Science and High-Performance Computing
Page 34: Containers for Science and High-Performance Computing

And when we find available resources, we need to ensure application and environment compatibility.

This is where containers can be a perfect fit…

Our use-case and needs are very different from enterprise!

Page 35: Containers for Science and High-Performance Computing

For example, reproducibility is of the utmost importance in

science.

Page 36: Containers for Science and High-Performance Computing

Science that isn’t easily reproducible is challenged

and sometimes embarrassingly erased.

Page 37: Containers for Science and High-Performance Computing

Software environments can often be very difficult to reproduce… Sometimes

impossible.

Page 38: Containers for Science and High-Performance Computing

And as scientists, we need reproducibility!

Page 39: Containers for Science and High-Performance Computing
Page 40: Containers for Science and High-Performance Computing

So why not just keep using Docker?

The good news:You can! It works great for local and private resources. You can use

it to develop and share your work with others using Docker-hub.

The bad news:If you ever need to scale beyond your local resources, it maybe a dead end path! Docker, and other enterprise focused containers,

are not designed for, efficient or even compatible with traditional HPC.

No HPC centers allow it!

Page 41: Containers for Science and High-Performance Computing

Shifter vs Charlie Cloud vs Docker vs Singularity

Page 42: Containers for Science and High-Performance Computing

Singularity

Page 43: Containers for Science and High-Performance Computing

Singularity

• Project lead: Gregory M. Kurtzer

• Sponsored by: HPC @ LBNL

• URL: http://singularity.lbl.gov

Page 44: Containers for Science and High-Performance Computing

Singularity - Containers for Science

• First public release in April 2016, followed by a massive uptake•HPC Wire Editor’s choice: Top Technologies to Watch for 2017• Simple integration with resource managers, InfiniBand, GPUs, MPI, file

systems, and supports multiple architectures (x86_64, PPC, ARM, etc..)• Limits user’s privileges (inside user == outside user)•No root owned container daemon•Network images are supported via URIs and all require local caching:

○ docker:// - This will pull a container from Docker Hub

○ http://, https:// - This will pull an image or tarball from the URL, cache and run it

○ shub:// - Pull an image from the Singularity Hub

Page 45: Containers for Science and High-Performance Computing

Singularity: access and privilege

User contexts are always maintained when the container is launched.

When launched by a particular user, the programs inside will be running as that user. Any escalation pathways inside

the container are blocked. Thus…

If you want to be root inside the container,you must first be root outside of the container!

Page 46: Containers for Science and High-Performance Computing

Singularity: access and privilege

[m31@centos7-x64 ~]$ whoamim31[m31@centos7-x64 ~]$ singularity shell /tmp/debian.imgSingularity: Invoking an interactive shell within container…

Singularity.debian.img> whoamim31Singularity.debian.img> sudo whoamisudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file

system without root privileges?Singularity.debian.img> ls -l /usr/bin/sudo-rwsr-xr-x. 1 root root 136808 Aug 17 13:20 /usr/bin/sudoSingularity.debian.img> exit

[m31@centos7-x64 ~]$ sudo singularity shell /tmp/debian.imgSingularity: Invoking an interactive shell within container...

Singularity.debian.img> whoamirootSingularity.debian.img> exit

Page 47: Containers for Science and High-Performance Computing

Singularity: Workflow

Page 48: Containers for Science and High-Performance Computing

Singularity: Creating the container

$ sudo singularity create --size 2048 /tmp/Centos-7.img

Page 49: Containers for Science and High-Performance Computing

Singularity: Bootstrapping the container

$ sudo singularity bootstrap /tmp/Centos-7.img centos.def

Page 50: Containers for Science and High-Performance Computing

The container is ready

$ singularity shell /tmp/Centos-7.img Singularity: Invoking an interactive shell within container...

Singularity.Centos-7.img> cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)

Page 51: Containers for Science and High-Performance Computing

Singularity: Bootstrap definition - RedHat/YUM

$ cat examples/centos.defBootStrap: yumOSVersion: 7MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/$basearch/Include: yum

%runscriptecho "This is what happens when you run the container..."

%postecho "Hello from inside the container"yum -y install vim-minimal

● The header defines the core operating system● %runscript: What should this container do when “run” (singularity run, or ./container.img)● %post: After the core operating system has been built, this gets executed inside the new container

Page 52: Containers for Science and High-Performance Computing

Singularity: Bootstrap definition - Debian/Ubuntu

$ cat examples/debian.defBootStrap: debootstrapOSVersion: stableMirrorURL: http://ftp.us.debian.org/debian/

%runscriptecho "This is what happens when you run the container..."

%postecho "Hello from inside the container"apt-get updateapt-get -y install vim

Page 53: Containers for Science and High-Performance Computing

Singularity: Bootstrap definition - OpenSuse

$ cat examples/opensuse.defBootStrap: zypperOSVersion: 42.2 MirrorURL: http://download.opensuse.org/distribution/leap/%{OSVERSION}/repo/oss/

%runscriptecho "This is what happens when you run the container..."

%post echo "Hello from inside the container"

Page 54: Containers for Science and High-Performance Computing

Usage Examples

$ python ./hello.pyHello World: The Python version is 2.7.5

$ sudo singularity exec --writable /tmp/debian.img apt-get install python…

$ singularity exec /tmp/debian.img python ./hello.pyHello World: The Python version is 2.7.13

$ cat hello.py | singularity exec /tmp/debian.img pythonHello World: The Python version is 2.7.13

Page 55: Containers for Science and High-Performance Computing

Usage Examples

$ mpirun singularity exec /tmp/Centos7-ompi.img /usr/bin/mpi_ringProcess 0 sending 10 to 1, tag 201 (4 processes in ring)Process 0 sent to 1Process 0 decremented value: 9Process 0 decremented value: 8Process 0 decremented value: 7Process 0 decremented value: 6Process 0 decremented value: 5Process 0 decremented value: 4Process 0 decremented value: 3Process 0 decremented value: 2Process 0 decremented value: 1Process 0 decremented value: 0Process 0 exitingProcess 1 exitingProcess 2 exitingProcess 3 exiting

Page 56: Containers for Science and High-Performance Computing

Container Image types supported

● Local images supported:

○ Singularity 2.x default image format

○ SquashFS

○ Tarballs (requires caching)

○ Flat directories (chroots)

● Network images are supported via URIs and all require local caching:

○ docker:// - This will pull a container from Docker Hub

○ http://, https:// - This will pull an image or tarball from the URL, cache and run it

○ shub:// - Pull an image from the Singularity Hub … Wait, what?! Patience, all in due time!

Page 57: Containers for Science and High-Performance Computing

Usage Examples

$ singularity exec docker://python:latest /usr/local/bin/python hello.pylibrary/python:latestDownloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:e41da2f0bac3da1769ecdac8b0f5df53c1db38603e39b9e261cafd10caf904deDownloading layer: sha256:75ef15b2048b4cfb06c02f2180f4d89033d02c63f698672d2909b8c9878c4270Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:45b2a7e03e44b5ea7fad081537134c9cc725bddf94f9093b00e1fa8d8ebbcda1Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:52f3db4b5710849a53bc2eea0b6f0895c494d751c38c597404d805da82b3f37cDownloading layer: sha256:76610ec20bf5892e24cebd4153c7668284aa1d1151b7c3b0c7d50c579aa5ce75Downloading layer: sha256:fce5728aad85a763fe3c419db16885eb6f7a670a42824ea618414b8fb309ccdeDownloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4Downloading layer: sha256:5040bd2983909aa8896b9932438c3f1479d25ae837a5f6220242a264d0221f2dHello World: The Python version is 3.6.0

Page 58: Containers for Science and High-Performance Computing

Usage Examples

$ singularity exec docker://tensorflow/tensorflow python -m tensorflow.models.image.mnist.convolutionaltensorflow/tensorflow:latestDownloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4...Initialized!Step 0 (epoch 0.00), 5.1 msMinibatch loss: 8.334, learning rate: 0.010000Minibatch error: 85.9%Validation error: 84.6%Step 100 (epoch 0.12), 140.0 msMinibatch loss: 3.250, learning rate: 0.010000Minibatch error: 6.2%…Step 8500 (epoch 9.89), 134.2 msMinibatch loss: 1.618, learning rate: 0.006302Minibatch error: 0.0%Validation error: 0.9%Test error: 0.8%

Page 59: Containers for Science and High-Performance Computing

Singularity Hub: Container Registry

Page 60: Containers for Science and High-Performance Computing

Singularity Hub: Build/Import workflow

● Singularity bootstrap definition is committed and pushed to a GitHub repository (named ‘Singularity’)

● GitHub communicates with Singularity Hub via a web hook, and it gets queued to be built via continuous integration

● Once built the resulting product is stored in Google Cloud and available to be accessed

● The container will be archived and can/should be cited in your scientific publications so others can replicate and leverage your work with:

$ singularity shell shub://$UNIQUE_ID$ singularity run shub://$USER/$CONTAINER:$TAG

Sochat V.,Prybol C,Kurtzer GM.SingularityHub:RegistryforReproducibleContainers(manuscriptinprogress)

Page 61: Containers for Science and High-Performance Computing

Who are using Singularity?

Page 62: Containers for Science and High-Performance Computing

Contributors to Singularity

Page 63: Containers for Science and High-Performance Computing

singularity.lbl.gov

Twitter:@SingularityAppGitHub:http://www.github.com/singularityware/singularity

Slack:http://singularity-container.slack.com (emailmeforinvite)

Page 64: Containers for Science and High-Performance Computing

Conferences

Page 65: Containers for Science and High-Performance Computing

DS and HPC Conferences

• Data Science Lab• May 13, Odessa, Ukraine• http://www.datascience.in.ua/

• ISC HIGH PERFORMANCE• June 18-22, Frankfurt, Germany• http://www.isc-hpc.com/

• SC Conference• November 12-17, Denver, Colorado, USA• http://sc17.supercomputing.org/

Page 66: Containers for Science and High-Performance Computing

Dmitry Spodarets

[email protected]