Skip to content

Instantly share code, notes, and snippets.

@gvanhorn38
Last active April 17, 2017 20:55
Show Gist options
  • Save gvanhorn38/ad85553e37d5245830d7fec33bbf3987 to your computer and use it in GitHub Desktop.
Save gvanhorn38/ad85553e37d5245830d7fec33bbf3987 to your computer and use it in GitHub Desktop.
C4 Instance, Tensorflow r1.1

Installing TensorFlow r1.1 on an AWS C4 instance.

Following this with a few modifications

Built using Ubuntu 16.04 with c4.2xlarge instance and 25GB of standard ssd storage.

# Update and upgrade installed packages
sudo apt-get update
sudo apt-get upgrade
############################################
# Install basic packages needed for TensorFlow and generally needed
########################
sudo apt-get install -y build-essential git python-pip libfreetype6-dev libxft-dev libncurses-dev libopenblas-dev gfortran python-matplotlib libblas-dev liblapack-dev libatlas-base-dev python-dev python-pydot linux-headers-generic linux-image-extra-virtual unzip python-numpy swig python-pandas python-sklearn unzip wget pkg-config zip g++ zlib1g-dev libcurl3-dev
sudo apt-get install bc

# AWS EFS Driver (to mount drives from EFS)
sudo apt-get -y install nfs-common

# Install Python package manager
sudo pip install -U pip
sudo pip install --upgrade pip
sudo pip install wheel numpy
############################################
# Install Bazel
########################
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel
sudo apt-get upgrade bazel
############################################
# Install TensorFlow
########################
git clone https://github.com/tensorflow/tensorflow

cd tensorflow
git checkout r1.1

./configure
# Used all of the default options

# Compiles in AVX2 optimizations.
bazel build -c opt --copt=-march="haswell" //tensorflow/tools/pip_package:build_pip_package

# Build the pip package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

# Install
sudo pip install --upgrade --force-reinstall /tmp/tensorflow_pkg/tensorflow-1.1.0rc2-cp27-cp27mu-linux_x86_64.whl
# Install any additional packages that you want the image to have
sudo pip install pyyaml
sudo pip install keras
sudo pip install ipython jupyter

You should now have a fully functional python environment and all of these should work:

import tensorflow as tf
import keras
import sklearn
from PIL import Image
import numpy as np
import scipy
from matplotlib import pyplot as plt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment