Sunday, January 17, 2016

Multi-threading in JavaScript with ParallelJS

Parallel.js is a simple library for parallel computing in Javascript (in node.js or in the modern web browsers). Paralleljs takes advantage of Web Workers for the web, and child processes for Node.

What is web workers

Web Workers are a mechanism by which a script operation can be made to run in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.

Multi-Threading in JavaScript

JavaScript is executed in a single thread by an event loop. With the Worker interface, a solution to this single-thread limitation problem has been found. With web workers Messages Api is used to communicate.

Note that, multi-threaded programming is parallel, but parallel programming is not necessarily multi-threaded. Unless the multi-threading occurs on a single core, in which case it is only concurrent.


ParallelJS  provides a great easy to useAPI for web workers with many helpers. A sample usage :

var p = new Parallel([1, 2, 3, 4, 5]);console.log(

The instance p contains a set of helper methods, for example spawn, map, reduce.
Here is a simple example of map function usage. It returns a Promise with the result. This is not the right solution for multi-threading with parallel.js but only a simple example. (number) {
 return number * number;
}).then(function (data) {

Tuesday, January 12, 2016

Install Caffe with GPU support without pain

This is my cheatsheet to install caffe with gpu support on an ubuntu machine.

apt-get update && apt-get install -q -y \
  wget \
  build-essential \

cd /opt && \
  wget && \
  chmod +x *.run && \
  mkdir nvidia_installers && \
  ./ -extract=`pwd`/nvidia_installers && \
  cd nvidia_installers && \
  ./ -s -N --no-kernel-module && \
  ./ -noprompt

#ENV LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.0/lib64

#ENV PYTHONPATH=/opt/caffe/python

#ENV PATH $PATH:/opt/caffe/.build_release/tools

apt-get update && apt-get install -y \
  bc cmake curl git
  gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib \
  gfortran unzip wget \
  libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev \
  libboost-all-dev \
  libhdf5-serial-dev \
  liblmdb-dev libjpeg62 libfreeimage-dev libatlas-base-dev \
  pkgconf protobuf-compiler \
  python-dev python-pip python-yaml python-numpy

# you may not need to change your gcc version
# update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-4.6 30 && \
  update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-4.6 30 && \
  update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 30 && \
  update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 30

# Allow it to find CUDA libs
echo "/usr/local/cuda/lib64" > /etc/ && \
# Clone caffe
cd /opt && git clone

# you may not need to install glog. but caffe will log warnings until you've glog installed.
cd /opt && wget && \
  tar zxvf glog-0.3.3.tar.gz && \
  cd /opt/glog-0.3.3 && \
  ./configure && \
  make && \
  make install


cd /opt && \
  wget && \
  unzip && \
  cd /opt/gflags-master && \
  mkdir build && \
  cd /opt/gflags-master/build && \
  export CXXFLAGS="-fPIC" && \
  cmake .. && \
  make VERBOSE=1 && make && make install

cd /opt/caffe && \
  cp Makefile.config.example Makefile.config

# echo "CXX := /usr/bin/g++-4.6" >> Makefile.config && sed -i 's/CXX :=/CXX ?=/' Makefile && \
make all -j8

# link caffe-ld-so.conf under /etc/


# you can install pillow from apt python-pil
easy_install pillow 

# You can find apt alternatives for these python deps.
cd /opt/caffe/python ; \
      for req in $(cat requirements.txt); do pip install $req; done

cd /opt/caffe && make py

# Done

Monday, January 11, 2016

If You are Dealing with Data, You will Like Anaconda

With Python at its core, Anaconda is a platform for connecting your expertise and curiosity with data to explore and deploy innovative analytic apps that solve challenging problems with ease and agility. Processing multi-workload data analytics – from batch through interactive to real-time – the platform is used for both ad hoc and production deployments. Anaconda is tuned to take advantage of modern computing environments – everything from multi-core servers, to Spark and Hadoop, to GPUs – delivering flexibility and allowing you to maximize your infrastructure investment. All of this plus the key capabilities required of an open source modern analytics platform – spanning advanced analytics, interactive visualizations, governance, security and operational support.

    Anaconda Stack


  • Notebooks 
  • Embeddable Dashboards 
  • Data Services 
  • Visual Apps 
  • VIZ 
  • Plots
  • Interactive Viz
  • Big Data
  • Maps & GIS
  • 3D
  • Streaming
  • Graphs 


  • Notebooks
  • Interactive Exploration
  • Visual Programming
  • Data IDEs 


  • DataPrep
  • Stats
  • ML & Ensembles
  • Deep Learning
  • Simulation & Optimization
  • Geospatial
  • Text & NLP
  • Video/Image/Audio Mining
  • Graph & Network 


  • Hadoop & Hive
  • Spark
  • NoSQL
  • DW & SOL
  • Files & Web Services


  • Servers
  • Clusters
  • GPUs & High End Workstations