Monday, April 6, 2015

Compiling MNIST on MacOSX [cudnn test]


$ make
g++ -c -o mnistCUDNN.o mnistCUDNN.cpp -I. -I/usr/local/cuda/include -I/usr/local/cuda/cudnn  -I/opt/local/include -I/usr/local/cuda/samples/7_CUDALibraries/common/UtilNPP
gcc -o mnistCUDNN mnistCUDNN.o -L/usr/local/cuda/lib -L/usr/local/cuda/cudnn -L/opt/local/lib -lnppi -lnppc -lfreeimage -lcudart -lcublas -lcudnn -lm -lstdc++


$ ./mnistCUDNN 
Loading image data/one_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
4.05186e-07 0.999404 2.21383e-07 1.20837e-08 0.000587085 5.06682e-08 2.80583e-06 1.47965e-06 3.56051e-06 2.46337e-07 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
4.67739e-05 5.83973e-07 1.76501e-06 0.75859 1.06138e-11 0.24133 2.62157e-10 1.11104e-05 3.39113e-07 1.88164e-05 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
3.22452e-10 8.69774e-10 3.73033e-12 3.2219e-07 2.67785e-11 0.999992 4.58862e-06 5.08385e-10 9.35238e-07 1.87656e-06 
Result of classification: 1 3 5
Test passed!

Installing Caffe on Mac OSX 10.10

Here are the instructions I followed for installing Caffe on Mac OSX 10.10


Clone the repository from here:
git clone https://github.com/BVLC/caffe
cp Makefile.config.example Makefile.config


Inside Makefile.config make the following changes:
PYTHON_LIB := $(ANACONDA_HOME)/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /opt/local/include /usr/local/cuda/cudnn
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /opt/local/lib /usr/local/cuda/cudnn

Check the requirements.txt file:
Cython>=0.19.2
numpy>=1.7.1
scipy>=0.13.2
scikit-image>=0.9.3
matplotlib>=1.3.1
ipython>=1.1.0
h5py>=2.2.0
leveldb>=0.191
networkx>=1.8.1
nose>=1.3.0
pandas>=0.12.0
python-dateutil>=1.4,<2 protobuf="">=2.5.0
python-gflags>=2.0
pyyaml>=3.10
Pillow>=2.3.0

If you are using Anaconda:
$ for req in $(cat requirements.txt); do conda install $req; done
Compile and build:
$ make all
$ make py
$ make test
$ make runtest

$ export CAFFE_HOME=${HOME}/caffe