Skip to content

Instantly share code, notes, and snippets.

@biojazzard
Forked from robertsdionne/deepdream-install.md
Last active October 14, 2015 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biojazzard/6220a896bf24c50bd388 to your computer and use it in GitHub Desktop.
Save biojazzard/6220a896bf24c50bd388 to your computer and use it in GitHub Desktop.
Deepdream installation
#!/usr/bin/env bash

# Assuming OS X 10.9

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install

# Install the Homebrew package manager if you don't already use it; see source http://brew.sh
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install homebrew cask
brew install caskroom/cask/brew-cask

# Install Python 2.7 and pip
brew install python pip

# Install Cuda 7
brew cask install cuda

# Optionally install cuDNN from https://developer.nvidia.com/cudnn which requries
# 1) Registering for an NVIDIA account, accepting an end-user-license-agreement
# 2) Downloading and extracting a tar.gz archive
# 3) Copying lib* files to /usr/local/cuda/lib and cudnn.h to /usr/local/cuda/include
#
# robertsdionne:~/$ ls /usr/local/cuda/lib/*dnn*
# /usr/local/cuda/lib/libcudnn.6.5.dylib /usr/local/cuda/lib/libcudnn_static.a
# /usr/local/cuda/lib/libcudnn.dylib
# robertsdionne:~/$ ls /usr/local/cuda/include/*dnn*
# /usr/local/cuda/include/cudnn.h

# Install dependencies; see http://caffe.berkeleyvision.org/install_osx.html
brew install --fresh -vd snappy leveldb gflags glog szip lmdb
# need the homebrew science source for OpenCV and hdf5
brew tap homebrew/science
brew install hdf5 opencv
# with Python pycaffe needs dependencies built from source
brew install --build-from-source --with-python --fresh -vd protobuf
# We need boost{,-python}-1.57.0 due to a bug in 1.58.0 on Yosemite 10.10.4
brew install --build-from-source --fresh -vd \
    https://raw.githubusercontent.com/Homebrew/homebrew/6fd6a9b6b2f56139a44dd689d30b7168ac13effb/Library/Formula/boost.rb \
    https://raw.githubusercontent.com/Homebrew/homebrew/3141234b3473717e87f3958d4916fe0ada0baba9/Library/Formula/boost-python.rb

# Clone caffe
git clone https://github.com/BVLC/caffe.git
cd caffe

# Install python dependencies
pip install --requirement python/requirements.txt

# Adjust Makefile.config
cp Makefile.config.example Makefile.config

########## Make the following adjustments to Makefile.config:

SEE Atached Makefile.config

```bash
# Build caffe
make all -j8; make pycaffe -j8

# Package caffe
make distribute

# Set your environment variables for success
export PYTHONPATH="$HOME/caffe/distribute/python:$PYTHONPATH"
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/lib:$HOME/caffe/distribute/lib:$DYLD_FALLBACK_LIBRARY_PATH

# Clone deepdream
cd ..
git clone https://github.com/google/deepdream.git
cd deepdream

# Install python requirements
pip install numpy scipy scikit-image pillow ipython[notebook]

# Start IPython Notebook and select dream.ipynb
ipython notebook dream.ipynb
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1 ########### Keep it like this to disable cuDNN
USE_CUDNN := 1 ########### Make it like this to enable cuDNN
# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
# USE_LEVELDB := 0
# USE_LMDB := 0
# USE_OPENCV := 0
# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++
# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr
# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50
# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers
# BLAS_LIB := /path/to/your/blas
# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib
# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/local/lib/python2.7/site-packages/numpy/core/include/ /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7/
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
# $(ANACONDA_HOME)/include/python2.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/local/lib/python2.7 /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/ /usr/local/lib/python2.7/site-packages/numpy/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib
# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib
# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
INCLUDE_DIRS += $(shell brew --prefix)/include
LIBRARY_DIRS += $(shell brew --prefix)/lib
# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1
# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0
# enable pretty build (comment to see full commands)
Q ?= @
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment