- you’re running the OS X Yosemite 10.10.* and
- you have all updates installed
- you’re familiar with git
- you have at least 4GB of free storage (not a problem nowdays, right?)
- you’re at least 16 years old female.
In brief, we’re about to set up the following (plus tons of invisible shit):
- Anaconda - this is free Python distribution for large-scale data processing, predictive analytics, and scientific computing
- IPython - an enhanced Interactive Python
- Caffe - this is a deep learning framework by the Berkeley Vision and Learning Center (BVLC). I hope, the original installation instructions could help you as well.
Ok, the start is here:
scene in which the reader first becomes a writer
Make sure you have Git installed. Open the terminal window and type
It should say something like
git version 2.3.2 (Apple Git-55)
If it does not, install git from http://git-scm.com/download/mac, then close the terminal window and open it again.
scene in which the reader makes a version
Type in the terminal window:
there are two scenarios:
A) either you have developer tools installed and it prints a version number...
B) OR you see something like
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
.. and a dialog pops up. Push the Install button and meditate for 2 minutes. Repeat the scene 2 again and again until you end up with
GNU Make 3.81 ...followed by some boring stuff.
scene in which the reader meets The Anaconda
We’re going to install Anaconda. It will strangle you in the end, but for today we need it. So, just get it and follow the instructions. When you’re done, type in the terminal window:
it should answer
scene in which the reader dives into beer
Make sure you have Homebrew installed, type in terminal:
if it says
command not found
then go to http://brew.sh/ and do what they say (note, it will ask for your passwords during the installation).
When Homebrew is ready, run the following. This will install the dependencies required by Caffe.
sudo chown -R `whoami` /usr/local brew install -vd snappy leveldb gflags glog szip lmdb brew tap homebrew/science brew install opencv
.. pray and proceed:
brew install --build-from-source --with-python -vd protobuf brew install --build-from-source -vd boost boost-python
Now, to make sure it was OK, type
and it should answer
scene in which the reader is having Caffe, while Caffe is having the reader.
Obtain Caffe source codes from github.
cd ~/ git clone https://github.com/BVLC/caffe.git cd caffe
Now it's time to build the Caffe. Copy the Make file and open it for editing:
cp Makefile.config.example Makefile.config open -t Makefile.config
Find the line
#CPU_ONLY := 1and uncomment it (remove #)
Find the line starting from
#ANACONDA_HOMEand uncomment it also. Make sure
ANACONDA_HOMEpoints to the dir you have it installed to. With no comments your config should look like this:
CPU_ONLY := 1 CUDA_DIR := /usr/local/cuda 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 := atlas ANACONDA_HOME := /Users/artem/anaconda PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ $(ANACONDA_HOME)/include/python2.7 \ $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \ INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib BUILD_DIR := build DISTRIBUTE_DIR := distribute TEST_GPUID := 0 Q ?= @
Since some libraries are coming with Anaconda, you have to define the fallback path
Ok, seems like we're ready to build Caffe:
make all -j8
Where '8' is the number of CPU cores you probably have. There's about 50% probability that everything went smoothly. If you're lucky, make tests and run them:
make test -j8 make runtest
Ideally, it should end with
[----------] Global test environment tear-down [==========] 824 tests from 127 test cases ran. (27164 ms total) [ PASSED ] 824 tests.
scene in which the the сollective unconscious absorbs the reader
Finally, get the Neural Network art script (plus a couple of sample images) and play with it.
curl -o dream.ipynb "https://raw.githubusercontent.com/google/deepdream/master/dream.ipynb" curl -o sky1024px.jpg "https://raw.githubusercontent.com/google/deepdream/master/sky1024px.jpg" curl -o flowers.jpg "https://raw.githubusercontent.com/google/deepdream/master/flowers.jpg" export PYTHONPATH=$HOME/caffe/python:$PYTHONPATH ipython notebook dream.ipynb
It opens your browser and navigates to
http://localhost:8888/notebooks/dream.ipynbwhere you should be able to run the script cell by cell to make your experiments in deepdreams.
scene In which the reader meets Lucy in the sky with diamonds. Unfinished.