Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spark netlib-java BLAS

i am trying to troubleshoot my non-working apache spark and netlib setup and i don't know what to do next.

Here some info:

  • Spark 1.3.1 (but also tried 1.5.1)
  • Mesos Cluster with 3 Nodes
  • Ubuntu Trusty on every node and installed following BLAS package

    $ dpkg -l | grep 'blas\|atlas\|lapack'
    ii  libopenblas-base                    0.2.8-6ubuntu1                   amd64        Optimized BLAS (linear algebra) library based on GotoBLAS2
    
    $ update-alternatives --get-selections | grep 'blas\|lapack'
    libblas.so.3                   auto     /usr/lib/openblas-base/libblas.so.3
    

I have built a sample jar for testing if netlib-java can detect this libraries, with following code:

object Main extends App {
  println(com.github.fommil.netlib.BLAS.getInstance().getClass().getName())
  println(com.github.fommil.netlib.LAPACK.getInstance().getClass().getName())
}

When i execute this code i get following response:

$ java -jar artifacts/BLAStest-assembly-1.0.jar
Mar 29, 2016 3:43:33 PM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS
Mar 29, 2016 3:43:33 PM com.github.fommil.jni.JniLoader liberalLoad
INFO: successfully loaded /tmp/jniloader6790966128222263615netlib-native_ref-linux-x86_64.so
com.github.fommil.netlib.NativeRefBLAS
Mar 29, 2016 3:43:33 PM com.github.fommil.netlib.LAPACK <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemLAPACK
Mar 29, 2016 3:43:33 PM com.github.fommil.jni.JniLoader load
INFO: already loaded netlib-native_ref-linux-x86_64.so
com.github.fommil.netlib.NativeRefLAPACK

So it seems to work just fine here. But spark can't detect the libraries. I have added this java dependency to my assembly jar

com.github.fommil.netlib:all:1.1.2

also if i try to start a spark shell with this package it doesn't work.

spark-shell --packages com.github.fommil.netlib:all:1.1.2
like image 357
wobu Avatar asked Mar 29 '16 13:03

wobu


1 Answers

It looks like your netlib-java implementation is loading the NativeRefBLAS, but not the NativeSystemBLAS. This means that you're inclusion of "com.github.fommil.netlib:all" is working ok, since without it you would be using the non-native F2J implementation. The issue is that you want to use the system-provided BLAS (OpenBLAS), instead of the reference implementation that came with netlib-java. This probably just is a matter of getting the right shared libraries in a location that's visible to your spark executors.

You said that you linked libblas.so.3, but as described in the netlib-java readme, you need to also configure the libblas.so, liblapack.so, and liblapack.so.3:

sudo apt-get install libatlas3-base libopenblas-base
sudo update-alternatives --config libblas.so
sudo update-alternatives --config libblas.so.3
sudo update-alternatives --config liblapack.so
sudo update-alternatives --config liblapack.so.3
like image 153
Benjamin Herta Avatar answered Nov 03 '22 21:11

Benjamin Herta