├── README.md ├── ansible.cfg ├── gpu-instance.yml ├── hosts └── roles ├── common ├── tasks │ ├── java8.yml │ ├── linux.yml │ ├── locale.yml │ ├── main.yml │ ├── ntp.yml │ └── utils.yml ├── templates │ └── locale.j2 └── vars │ └── main.yml ├── gpu ├── tasks │ ├── cuda.yml │ ├── cudnn.yml │ ├── driver.yml │ ├── main.yml │ └── optimize.yml └── vars │ └── main.yml └── tools ├── files ├── Makefile.config ├── jupyter_notebook_config.py ├── notebook.conf └── theanorc ├── tasks ├── anaconda.yml ├── caffe2.yml ├── keras.yml ├── main.yml ├── mxnet.yml ├── notebook.yml ├── tensorflow.yml └── theano.yml └── vars └── main.yml /README.md: -------------------------------------------------------------------------------- 1 | # ec2-gpu-instance 2 | Ansible provision scripts for configuration of an Amazon EC2 GPU P2 instance. 3 | 4 | ## Amazon instance and AMI 5 | 6 | These provision scripts should be applied to an EC2 P2 GPU instance configured with an *Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-47a23a30* machine image. 7 | 8 | ## Installed software 9 | 10 | The following software is installed on the instance: 11 | - **common**; regular packages like java8, git, curl, make, etc. 12 | - **cuda**; Nvidia drivers, CUDA 8.0, CUDNN 5.1 13 | - **tools**; Anaconda (python 3), Theano, TensorFlow, Keras, MXNet 14 | 15 | ## Running the ansible-playbook 16 | 17 | To allow the installation of the NVIDIA® cuDNN – GPU Accelerated Deep Learning libraries, please download the binaries from https://developer.nvidia.com/cudnn. 18 | 19 | Perform the following steps to successfully install the instance using the ansible playbook: 20 | 21 | 1. Make sure ansible is installed (preferably in python 2 environment, if not install using `pip install ansible`). 22 | 2. Add the cudnn-8.0-linux-x64-v5.1.tgz file to the **roles/gpu/files/**-folder. 23 | 3. Add the public ip or dns of the instance to the hosts file. 24 | 4. Add the path of the pem key file to the ansible.cfg file. 25 | 5. Run the playbook from the root of this repository by executing: `ansible-playbook gpu-instance.yml`. 26 | 27 | ## Accessing Jupyter notebook 28 | 29 | Jupyter notebook is by default installed and started during bootup of the instance: 30 | 1. Make sure you setup the security group such that port 9999 is exposed to you local ip. 31 | 2. Open your browser and got to the following url **https://public_ip:9999** 32 | 3. Ignore the ssl certificate warning and login with the default password `accelerator` 33 | -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host} 3 | inventory = hosts 4 | remote_user = ubuntu 5 | private_key_file = 6 | 7 | [ssh_connection] 8 | ssh_args = -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -------------------------------------------------------------------------------- /gpu-instance.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | become: true 4 | become_method: sudo 5 | roles: 6 | - { role: common, tags: common } 7 | - { role: gpu, tags: gpu } 8 | - { role: tools, tags: tools } -------------------------------------------------------------------------------- /hosts: -------------------------------------------------------------------------------- 1 | [gpu-instance] 2 | 3 | -------------------------------------------------------------------------------- /roles/common/tasks/java8.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add java8 apt-repository 3 | apt_repository: repo='ppa:webupd8team/java' 4 | 5 | - name: Automatically select the Oracle License 6 | shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections 7 | 8 | - name: Install java8 9 | apt: pkg=oracle-java8-installer state=latest update_cache=yes force=yes -------------------------------------------------------------------------------- /roles/common/tasks/linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - apt: upgrade=dist update_cache=yes 3 | 4 | - name: Restart server 5 | shell: sleep 2 && /sbin/shutdown -r now 6 | async: 1 7 | poll: 0 8 | ignore_errors: true 9 | 10 | - name: Wait for server to restart 11 | local_action: 12 | module: wait_for host={{ inventory_hostname }} delay=30 timeout=120 state=started 13 | become: false -------------------------------------------------------------------------------- /roles/common/tasks/locale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure locales is installed 3 | apt: name=locales state=installed 4 | 5 | - name: Ensure language packages are installed 6 | apt: pkg={{ locale_language_packs }} state=installed 7 | register: locale_languages 8 | 9 | - name: Ensure dpkg is reconfigured 10 | command: dpkg-reconfigure locales 11 | when: locale_languages.changed 12 | 13 | - name: Set system wide locale 14 | template: > 15 | src=locale.j2 16 | dest=/etc/default/locale 17 | owner=root group=root mode=644 18 | 19 | - name: Detect locale gen file 20 | stat: 21 | path: /etc/local.gen 22 | register: locales_gen 23 | 24 | - name: Create locale gen file 25 | file: 26 | path: /etc/local.gen 27 | state: touch 28 | when: not locales_gen.stat.exists 29 | 30 | - name: Detect locale supported file 31 | stat: 32 | path: /var/lib/locales/supported.d/local 33 | register: locales_supported 34 | 35 | - name: Create locale supported file 36 | file: 37 | path: /var/lib/locales/supported.d/local 38 | state: touch 39 | when: not locales_supported.stat.exists 40 | 41 | - name: Ensure locales is generated 42 | locale_gen: name={{ locale_settings.LANG }} state=present 43 | -------------------------------------------------------------------------------- /roles/common/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - { include: linux.yml, tags: linux } 3 | - { include: locale.yml, tags: locale } 4 | - { include: utils.yml, tags: utils } 5 | - { include: ntp.yml, tags: ntp } 6 | - { include: java8.yml, tags: java8 } -------------------------------------------------------------------------------- /roles/common/tasks/ntp.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure tzdata is installed 3 | apt: name=tzdata state=installed 4 | 5 | - name: Set to correct timezone 6 | file: > 7 | src=/usr/share/zoneinfo/{{ ntp_timezone }} 8 | dest=/etc/localtime 9 | state=link 10 | force=true 11 | 12 | - name: Ensure ntp packages is installed 13 | apt: name={{ item }} state=installed 14 | with_items: 15 | - ntp 16 | - ntpdate 17 | 18 | - name: Ensure service ntp is running and enabled 19 | service: name=ntp state=started enabled=yes 20 | -------------------------------------------------------------------------------- /roles/common/tasks/utils.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure utility packages installed 3 | apt: pkg={{ utils_packages }} state=installed update_cache=yes 4 | 5 | 6 | -------------------------------------------------------------------------------- /roles/common/templates/locale.j2: -------------------------------------------------------------------------------- 1 | {% for key, value in locale_settings.iteritems() %} 2 | {{key|e}}="{{value|e}}" 3 | {% endfor %} 4 | -------------------------------------------------------------------------------- /roles/common/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | locale_language_packs: 3 | - language-pack-en 4 | - language-pack-en-base 5 | 6 | # See: 7 | # - https://help.ubuntu.com/community/Locale 8 | # - https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable 9 | locale_settings: 10 | LANG: "en_US.UTF-8" 11 | LANGUAGE: "en_US:" 12 | 13 | utils_packages: 14 | - build-essential 15 | - binutils 16 | - g++ 17 | - curl 18 | - debconf 19 | - dmidecode 20 | - htop 21 | - iftop 22 | - iotop 23 | - pciutils 24 | - screen 25 | - sysstat 26 | - tmux 27 | - unzip 28 | - vim 29 | - wget 30 | - git 31 | - tree 32 | - make 33 | - cmake 34 | - automake 35 | - p7zip-full 36 | - unrar-free 37 | - bzip2 38 | - bc 39 | - software-properties-common 40 | 41 | ntp_timezone: Etc/UTC -------------------------------------------------------------------------------- /roles/gpu/tasks/cuda.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Download latest CUDA deb packages 3 | get_url: url={{ cuda_deb }} dest=/tmp/cuda.deb 4 | 5 | - name: Add CUDA deb 6 | shell: dpkg -i /tmp/cuda.deb 7 | 8 | - name: Update packages 9 | apt: update_cache=yes 10 | 11 | - name: Install cuda package 12 | apt: name=cuda state=present 13 | 14 | - name: Adding cuda bin to PATH 15 | lineinfile: dest=~/.bashrc line="export PATH=$PATH:/usr/local/cuda/bin" 16 | become: false 17 | 18 | - name: Adding cuda lib64 to LD_LIBRARY_PATH 19 | lineinfile: dest=~/.bashrc line="export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64" 20 | become: false 21 | 22 | - name: Adding cuda root to CUDA_ROOT 23 | lineinfile: dest=~/.bashrc line="export CUDA_ROOT=/usr/local/cuda" 24 | become: false 25 | 26 | - name: Restart server 27 | shell: sleep 2 && /sbin/shutdown -r now 28 | async: 1 29 | poll: 0 30 | ignore_errors: true 31 | 32 | - name: Wait for server to restart 33 | local_action: 34 | module: wait_for host={{ inventory_hostname }} delay=30 timeout=120 state=started 35 | become: false -------------------------------------------------------------------------------- /roles/gpu/tasks/cudnn.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Copy and extract cudnn archive 3 | unarchive: src={{ cuddnn_archive }} dest=/tmp 4 | 5 | - name: Copy cdnn.h file into cuda include dir 6 | shell: cp /tmp/cuda/include/cudnn.h /usr/local/cuda/include/ 7 | 8 | - name: Copy libcudnn* files into cuda lib64 dir 9 | shell: cp /tmp/cuda/lib64/* /usr/local/cuda/lib64/ 10 | -------------------------------------------------------------------------------- /roles/gpu/tasks/driver.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Blacklist processes nouveau 3 | kernel_blacklist: name=nouveau state=present 4 | 5 | - name: Update system with nouveau disabled 6 | shell: update-initramfs -u 7 | 8 | # http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/ 9 | - name: Install linux packages 10 | apt: pkg=linux-image-extra-virtual state=installed 11 | 12 | - name: Restart server 13 | shell: sleep 2 && /sbin/shutdown -r now 14 | async: 1 15 | poll: 0 16 | ignore_errors: true 17 | 18 | - name: Wait for server to restart 19 | local_action: 20 | module: wait_for host={{ inventory_hostname }} delay=30 timeout=120 state=started 21 | become: false 22 | 23 | - name: Download latest NVIDA drivers 24 | get_url: url={{ nvidia_driver }} dest=/tmp/driver.run 25 | 26 | - name: Install the NVIDIA driver 27 | shell: sh /tmp/driver.run -q -a -n -s -------------------------------------------------------------------------------- /roles/gpu/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - { include: driver.yml, tags: driver } 3 | - { include: cuda.yml, tags: cuda } 4 | - { include: cudnn.yml, tags: cudnn } 5 | - { include: optimize.yml, tags: optimize } -------------------------------------------------------------------------------- /roles/gpu/tasks/optimize.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Optmize P2 according to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html#optimize_gpu 3 | - name: Configure the GPU settings to be persistent 4 | shell: nvidia-smi -pm 1 5 | 6 | - name: Disable the autoboost feature for all GPUs on the instance. 7 | shell: nvidia-smi --auto-boost-default=0 8 | 9 | - name: Set all GPU clock speeds to their maximum frequency. 10 | shell: nvidia-smi -ac 2505,875 11 | 12 | - name: Killing libdc1394 warning 13 | file: src=/dev/null dest=/dev/raw1394 state=link -------------------------------------------------------------------------------- /roles/gpu/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | cuda_deb: http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.61-1_amd64.deb 4 | cuddnn_archive: cudnn-8.0-linux-x64-v5.1.tgz 5 | nvidia_driver: http://us.download.nvidia.com/XFree86/Linux-x86_64/375.39/NVIDIA-Linux-x86_64-375.39.run -------------------------------------------------------------------------------- /roles/tools/files/Makefile.config: -------------------------------------------------------------------------------- 1 | ## Refer to http://caffe.berkeleyvision.org/installation.html 2 | # Contributions simplifying and improving our build system are welcome! 3 | 4 | # cuDNN acceleration switch (uncomment to build with cuDNN). 5 | USE_CUDNN := 1 6 | 7 | # CPU-only switch (uncomment to build without GPU support). 8 | # CPU_ONLY := 1 9 | 10 | # To customize your choice of compiler, uncomment and set the following. 11 | # N.B. the default for Linux is g++ and the default for OSX is clang++ 12 | # CUSTOM_CXX := g++ 13 | 14 | # CUDA directory contains bin/ and lib/ directories that we need. 15 | CUDA_DIR := /usr/local/cuda 16 | # On Ubuntu 14.04, if cuda tools are installed via 17 | # "sudo apt-get install nvidia-cuda-toolkit" then use this instead: 18 | # CUDA_DIR := /usr 19 | 20 | # CUDA architecture setting: going with all of them. 21 | # For CUDA < 6.0, comment the *_50 lines for compatibility. 22 | CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \ 23 | -gencode arch=compute_20,code=sm_21 \ 24 | -gencode arch=compute_30,code=sm_30 \ 25 | -gencode arch=compute_35,code=sm_35 \ 26 | -gencode arch=compute_50,code=sm_50 \ 27 | -gencode arch=compute_50,code=compute_50 28 | 29 | # BLAS choice: 30 | # atlas for ATLAS (default) 31 | # mkl for MKL 32 | # open for OpenBlas 33 | BLAS := open 34 | # Custom (MKL/ATLAS/OpenBLAS) include and lib directories. 35 | # Leave commented to accept the defaults for your choice of BLAS 36 | # (which should work)! 37 | # BLAS_INCLUDE := /path/to/your/blas 38 | # BLAS_LIB := /path/to/your/blas 39 | 40 | # This is required only if you will compile the matlab interface. 41 | # MATLAB directory should contain the mex binary in /bin. 42 | # MATLAB_DIR := /usr/local 43 | # MATLAB_DIR := /Applications/MATLAB_R2012b.app 44 | 45 | # NOTE: this is required only if you will compile the python interface. 46 | # We need to be able to find Python.h and numpy/arrayobject.h. 47 | #PYTHON_INCLUDE := /usr/include/python2.7 \ 48 | # /usr/lib/python2.7/dist-packages/numpy/core/include 49 | # Anaconda Python distribution is quite popular. Include path: 50 | # Verify anaconda location, sometimes it's in root. 51 | ANACONDA_HOME := $(HOME)/anaconda2 52 | PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ 53 | $(ANACONDA_HOME)/include/python2.7 \ 54 | $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \ 55 | 56 | # We need to be able to find libpythonX.X.so or .dylib. 57 | # PYTHON_LIB := /usr/lib 58 | PYTHON_LIB := $(ANACONDA_HOME)/lib 59 | 60 | # Uncomment to support layers written in Python (will link against Python libs) 61 | # WITH_PYTHON_LAYER := 1 62 | 63 | # Whatever else you find you need goes here. 64 | INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include 65 | LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 66 | 67 | # Uncomment to use `pkg-config` to specify OpenCV library paths. 68 | # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.) 69 | # USE_PKG_CONFIG := 1 70 | 71 | BUILD_DIR := build 72 | DISTRIBUTE_DIR := distribute 73 | 74 | # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171 75 | # DEBUG := 1 76 | 77 | # The ID of the GPU that 'make runtest' will use to run unit tests. 78 | TEST_GPUID := 0 79 | 80 | # enable pretty build (comment to see full commands) 81 | Q ?= @ 82 | -------------------------------------------------------------------------------- /roles/tools/files/jupyter_notebook_config.py: -------------------------------------------------------------------------------- 1 | # Set options for certfile, ip, password, and toggle off browser auto-opening 2 | c.NotebookApp.certfile = u'/home/ubuntu/.jupyter/mycert.pem' 3 | c.NotebookApp.keyfile = u'/home/ubuntu/.jupyter/mykey.key' 4 | # Set ip to '*' to bind on all interfaces (ips) for the public server 5 | c.NotebookApp.ip = '*' 6 | c.NotebookApp.password = u'sha1:c3eacd915e69:65c80dc268c6dab2c28a885b9e9d50cbc9614a2c' #accelerator 7 | c.NotebookApp.open_browser = False 8 | c.NotebookApp.notebook_dir = '/home/ubuntu/' 9 | 10 | # It is a good idea to set a known, fixed port for server access 11 | c.NotebookApp.port = 9999 -------------------------------------------------------------------------------- /roles/tools/files/notebook.conf: -------------------------------------------------------------------------------- 1 | description "Jupyter notebook daemon" 2 | 3 | start on started networking 4 | stop on (deconfiguring-networking or runlevel [016]) 5 | 6 | respawn 7 | respawn limit 5 10 8 | 9 | setuid ubuntu 10 | setgid ubuntu 11 | 12 | env PATH=/home/ubuntu/miniconda/bin:/home/ubuntu/caffe/build/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/cuda/bin 13 | env LD_LIBRARY_PATH=/usr/local/cuda/lib64:/home/ubuntu/miniconda/lib 14 | env CUDA_ROOT=/usr/local/cuda 15 | 16 | export PATH 17 | export LD_LIBRARY_PATH 18 | export CUDA_ROOT 19 | 20 | chdir /home/ubuntu 21 | exec /home/ubuntu/miniconda/bin/jupyter notebook --config ~/.jupyter/jupyter_notebook_config.py -------------------------------------------------------------------------------- /roles/tools/files/theanorc: -------------------------------------------------------------------------------- 1 | [global] 2 | floatX = float32 3 | device = gpu0 4 | 5 | [nvcc] 6 | fastmath = True 7 | 8 | [cuda] 9 | root = /usr/local/cuda -------------------------------------------------------------------------------- /roles/tools/tasks/anaconda.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Download miniconda installer 3 | get_url: url={{ miniconda_installer }} 4 | dest=/tmp/miniconda.sh 5 | 6 | - name: Check if miniconda is installed 7 | stat: 8 | path: ~/miniconda 9 | register: installed 10 | become: false 11 | 12 | - name: Install miniconda (default folder) 13 | shell: bash /tmp/miniconda.sh -b -p $HOME/miniconda 14 | become: false 15 | when: installed.stat.exists == False 16 | 17 | - name: Add miniconda to the PATH 18 | lineinfile: dest=~/.bashrc line="export PATH=~/miniconda/bin:$PATH" 19 | become: false 20 | when: installed.stat.exists == False 21 | 22 | - name: Update conda 23 | shell: ~/miniconda/bin/conda update conda -y --force 24 | become: false 25 | 26 | - name: Check if anaconda35 env is installed 27 | stat: 28 | path: ~/miniconda/envs/anaconda35 29 | register: anaconda35 30 | become: false 31 | 32 | - name: Create anaconda python 3.5 env 33 | shell: ~/miniconda/bin/conda create -y -n anaconda35 python=3.5 anaconda 34 | become: false 35 | when: anaconda35.stat.exists == False 36 | 37 | - name: Upgrating setuptools 38 | shell: /usr/bin/yes | ~/miniconda/envs/anaconda35/bin/pip install -q --upgrade setuptools 39 | ignore_errors: yes 40 | become: false 41 | when: anaconda35.stat.exists == False 42 | 43 | - name: By default activate anaconda35 env 44 | lineinfile: dest=~/.bashrc line="source activate anaconda35" 45 | become: false 46 | when: anaconda35.stat.exists == False 47 | 48 | - name: Check if anaconda27 env is installed 49 | stat: 50 | path: ~/miniconda/envs/anaconda27 51 | register: anaconda27 52 | become: false 53 | 54 | - name: Create anaconda python 2.7 env 55 | shell: ~/miniconda/bin/conda create -y -n anaconda27 python=2.7 anaconda 56 | become: false 57 | when: anaconda27.stat.exists == False 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /roles/tools/tasks/caffe2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install caffe2 dependencies 3 | apt: 4 | pkg: '{{ caffe2_dependencies }}' 5 | state: installed 6 | update_cache: yes 7 | install_recommends: no 8 | 9 | - name: Cloning caffe2 git repo 10 | git: repo=https://github.com/caffe2/caffe2.git dest=~/caffe2 11 | become: false 12 | 13 | - name: Install python dependencies 14 | shell: ~/miniconda/envs/anaconda27/bin/pip install {{ item }} 15 | with_items: 16 | - protobuf 17 | - pydot python-nvd3 18 | - graphviz 19 | - hypothesis 20 | become: false 21 | 22 | - name: Symlink anaconda27 23 | file: 24 | src: /home/ubuntu/miniconda/envs/anaconda27/bin/python 25 | dest: /usr/bin/python 26 | state: link 27 | 28 | - name: Build caffe 29 | shell: make -j$(nproc) chdir=~/caffe2/ 30 | become: false 31 | 32 | - name: Install caffe2 33 | shell: make install chdir=~/caffe2/build/ 34 | 35 | - name: reverting symlink 36 | file: 37 | src: /usr/bin/python2.7 38 | dest: /usr/bin/python 39 | state: link 40 | 41 | -------------------------------------------------------------------------------- /roles/tools/tasks/keras.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: checkout keras repo 3 | git: repo=https://github.com/fchollet/keras.git dest=~/keras update=yes 4 | become: false 5 | 6 | - name: Install latest version of keras 7 | shell: ~/miniconda/envs/anaconda35/bin/pip install --upgrade -e ~/keras 8 | become: false -------------------------------------------------------------------------------- /roles/tools/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - { include: anaconda.yml, tags: anaconda } 3 | - { include: notebook.yml, tags: notebook } 4 | - { include: tensorflow.yml, tags: tensorflow } 5 | - { include: keras.yml, tags: keras } 6 | - { include: theano.yml, tags: theano} 7 | - { include: mxnet.yml, tags: mxnet } 8 | #- { include: caffe2.yml, tags: caffe2 } 9 | -------------------------------------------------------------------------------- /roles/tools/tasks/mxnet.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Checkout MXNet repo 3 | git: repo=https://github.com/dmlc/mxnet.git dest=~/mxnet update=yes 4 | become: false 5 | 6 | - name: Copy config.mk 7 | shell: cp ~/mxnet/make/config.mk ~/mxnet 8 | become: false 9 | 10 | - name: Update config.mk 11 | blockinfile: 12 | dest: ~/mxnet/config.mk 13 | block: | 14 | USE_CUDA=1 15 | USE_CUDA_PATH=/usr/local/cuda 16 | USE_CUDNN=1 17 | become: false 18 | 19 | - name: Ensure MXNet dependencies are installed 20 | apt: name={{ item }} state=installed 21 | with_items: 22 | - build-essential 23 | - libatlas-base-dev 24 | - libopencv-dev 25 | - graphviz 26 | 27 | - name: Make MXNet 28 | shell: make -j$(nproc) chdir=~/mxnet/ 29 | become: false 30 | 31 | - name: Install graphviz 32 | shell: ~/miniconda/envs/anaconda35/bin/pip install --upgrade graphviz 33 | become: false 34 | 35 | - name: Install MXNet python package 36 | shell: ~/miniconda/envs/anaconda35/bin/python setup.py install chdir=~/mxnet/python 37 | become: false -------------------------------------------------------------------------------- /roles/tools/tasks/notebook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install nb_conda 3 | command: ~/miniconda/bin/conda install -y jupyter nb_conda -c conda-forge 4 | become: false 5 | 6 | - name: Enable conda kernels 7 | command: ~/miniconda/bin/python -m nb_conda_kernels.install --enable 8 | become: false 9 | 10 | - name: Copy jupyter notebook config file to instance 11 | copy: src=jupyter_notebook_config.py dest=~/.jupyter/ 12 | become: false 13 | 14 | - name: Create cerificate and key 15 | shell: openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.jupyter/mykey.key -out ~/.jupyter/mycert.pem -subj "/C=NL" 16 | become: false 17 | 18 | - name: Add upstart script to /etc/init 19 | copy: src=notebook.conf dest=/etc/init 20 | 21 | - name: link sh to bash 22 | file: path=/bin/sh src=/bin/bash state=link force=yes 23 | become: true 24 | 25 | - name: Restart server 26 | shell: sleep 2 && /sbin/shutdown -r now 27 | async: 1 28 | poll: 0 29 | ignore_errors: true 30 | 31 | - name: Wait for server to restart 32 | local_action: 33 | module: wait_for host={{ inventory_hostname }} delay=30 timeout=120 state=started 34 | become: false -------------------------------------------------------------------------------- /roles/tools/tasks/tensorflow.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install tensorflow with GPU support 3 | shell: ~/miniconda/envs/anaconda35/bin/pip install --upgrade tensorflow-gpu 4 | become: false 5 | 6 | - name: Install tensorboard 7 | shell: ~/miniconda/envs/anaconda35/bin/pip install tensorboard 8 | become: false -------------------------------------------------------------------------------- /roles/tools/tasks/theano.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install latest version of theanorc 3 | shell: ~/miniconda/envs/anaconda35/bin/pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git 4 | become: false 5 | 6 | - name: Copy theanorc file to instance 7 | copy: src=theanorc dest=~/.theanorc 8 | become: false -------------------------------------------------------------------------------- /roles/tools/vars/main.yml: -------------------------------------------------------------------------------- 1 | 2 | miniconda_installer: https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh 3 | 4 | caffe2_dependencies: 5 | - libgoogle-glog-dev 6 | - libprotobuf-dev 7 | - protobuf-compiler 8 | - libgtest-dev 9 | - libiomp-dev 10 | - libleveldb-dev 11 | - liblmdb-dev 12 | - libopencv-dev 13 | - libopenmpi-dev 14 | - libsnappy-dev 15 | - openmpi-bin 16 | - openmpi-doc 17 | - python-pydot --------------------------------------------------------------------------------