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!

5 comments:

  1. Is this the example provided by NVIDIA? I have a problem in linking library and I'm not able to solve it. Are there other examples about the use of cuDNN?

    ReplyDelete
  2. @Maria: yes, this is the example given by Nvidia. I got this while attending the Nvidia GTC 2015 workshops. Originally this was meant for Linux and I was able to get it working for Mac OSX. Let me know if you have questions. (@vivekv80)

    ReplyDelete
  3. I tried import the example, but it doesn't run. I tried to import the example creating a "Makefile project with existing code" but when I compile I have a library error (libfreeimage.a produce a symbol(s) not found for architecture x86_64).
    If i change the -lfreeimage in -lfreeimage-3.13.1 I can compile without errors but when I run the project I have the error:
    dyld: Library not loaded: libfreeimage-3.13.1.dylib-x86_64
    Referenced from: mnistCUDNN path
    Reason: image not found
    Any idea on how can I solve this linking problem?

    ReplyDelete
  4. @Maria: I installed FreeImage using macports into /opt/local and linked to it. Can you try that?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete