Tuesday, June 2, 2015

Building caffe with OpenBlas on Ubuntu 12.04

After suffering the same installation issue several times, I decided to write a note about how to build caffe with OpenBlas (which makes caffe a lot faster comparing to using the default AtlasBlas) on Ubuntu 12.04.

1. Compiling OpenBlas

$ git clone git://github.com/xianyi/OpenBLAS
$ cd OpenBLAS && make FC=gfortran
$ sudo make PREFIX=/opt/OpenBLAS install
$ sudo ldconfig

2. Compiling numpy and scipy with OpenBlas

We need to re-compile numpy from the source to ensure numpy uses OpenBlas

$ git clone https://github.com/numpy/numpy
$ cd numpy
$ cp site.cfg.example site.cfg
$ vim site.cfg
Look for [openblas] in the site.cfg and uncomment these lines

....
[openblas]
libraries = openblas
library_dirs = /opt/OpenBLAS/lib
include_dirs = /opt/OpenBLAS/include
....
Then setup the configuration file and build numpy

$ python setup.py config 
$ python setup.py build && python setup.py install

Repeat the same thing (2) for scipy

3. Compiling caffe using OpenBlasbuild and install numpy

Copy libopenblas.a to /usr/lib and /usr/local/lib (otherwise caffe gives compile error: usr/lib/ld: cannot find -lopenblas)
$ cp /opt/OpenBlas/lib/libopenblas.a /usr/lib /usr/local/lib/
$ cp /opt/OpenBlas/lib/libopenblas.so* /usr/lib /usr/local/lib
In Makefile.config set
$ BLAS := open
Then, you should be able to build caffe!

Under the caffe directory
$ make all
$ make pycaffe

Wednesday, July 24, 2013

Some facts about winRT

- The DispatcherTimer runs on the UI thread and the ThreadPoolTimer runs on the ThreadPool. If you don't need to update the UI then you should use the second one.

- Asynchronous != multi-thread
Asynchrony means running a job without blocking the Thread where it is working at. Concurrency is actually a special kind of asynchrony where it is achieved by creating a new Thread. 

- Timers
ThreadPoolTimer - submit a job to the thread pool
http://msdn.microsoft.com/en-us/library/windows/apps/jj248676.aspx

DispatcherTimer - run in the UI thread; firing time is not very accurate
http://stackoverflow.com/questions/10493253/controlled-non-ui-timer-in-metro-app-net

 System.Timers.Timer (should be used in server) v.s.System.Threading.Timer
http://stackoverflow.com/questions/1416803/system-timers-timer-vs-system-threading-timer

- Update UI in a different thread
http://stackoverflow.com/questions/9540260/update-ui-from-thread-in-winrt


- Deploy Windows App on Surface
http://www.lhotka.net/weblog/TestingAWinRTAppOnASurfaceRT.aspx

Monday, July 15, 2013

ASP .NET with Emgu CV on Windows Azure VM

  1. Disable "IE Enhanced Security Configuration" in Server Manager>Loval Server
  2. Install IIS Express 8
  3. Modify the configuration to allow connection to a new site
  4. Configure the endpoint on the Azure dashboard
  5. Allow inbound connection in the firewall setting
  6. Install EmguCV (cause it comes with ), put /x86/bin into the path environment variable
  7. Turn off the computer and start it
  8. Download codes/img from dropbox.