[JAVA] jblas on Arch Linux

I want to calculate the matrix even in Arch Linux! With Clojure (Java)!

procedure

  1. Create an arch linux environment (latest java environment (openjdk), install Ruby as well) (https://qiita.com/elect/items/328c28c310b385de7d23)

  2. Next, download the jblas jar file. (From Getting Started-> Download the jar from the downloads page)

  3. Try java -server -jar jblas-1.4.2.jar normally.

  4. An error like this is returned

    java -jar jblas-1.2.4.jar 
    -- org.jblas INFO jblas version is 1.2.4
    Simple benchmark for jblas
    Running sanity benchmarks.

    checking vector addition... ok
    -- org.jblas CONFIG BLAS native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
    -- org.jblas CONFIG ArchFlavor native library not found in path. Copying native library libjblas_arch_flavor from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
    -- org.jblas CONFIG Loading libjblas_arch_flavor.so from /lib/static/Linux/amd64/, copying to libjblas_arch_flavor.so.
    -- org.jblas ERROR Couldn't load copied link file: java.lang.UnsatisfiedLinkError: /tmp/jblas5239787082843388211/libjblas_arch_flavor.so: libgfortran.so.3: cannot open shared object file: No such file or directory.

    On Linux 64bit, you need additional support libraries.
    You need to install libgfortran3.

    For example for debian or Ubuntu, type "sudo apt-get install libgfortran3"

    For more information, see 
    https://github.com/mikiobraun/jblas/wiki/Missing-Libraries
    Exception in thread "main" java.lang.UnsatisfiedLinkError: org.jblas.NativeBlas.dgemm(CCIIID[DII[DIID[DII)V
	at org.jblas.NativeBlas.dgemm(Native Method)
	at org.jblas.SimpleBlas.gemm(SimpleBlas.java:247)
	at org.jblas.DoubleMatrix.mmuli(DoubleMatrix.java:1781)
	at org.jblas.DoubleMatrix.mmul(DoubleMatrix.java:3138)
	at org.jblas.util.SanityChecks.checkMatrixMultiplication(SanityChecks.java:91)
	at org.jblas.util.SanityChecks.main(SanityChecks.java:182)
	at org.jblas.benchmark.Main.main(Main.java:114)
    -- org.jblas INFO Deleting /tmp/jblas5239787082843388211/libjblas_arch_flavor.so
    -- org.jblas INFO Deleting /tmp/jblas5239787082843388211

In short, it means that libgfortran.so.3 cannot be found.

  1. Install gcc-6. (yaourt -S gcc6) You will need the libgfortran.so.3 included in this

  2. Link with sudo ln -s /usr/lib/gcc/x86_64-pc-linux-gnu/6.XX/libgfortran.so.3 /usr/lib/ (6.XX is the version name) / Paste it under usr / lib (write it with an absolute path)

  3. Try java -server -jar jblas-1.2.4.jar again and it works fine

    java -server -jar jblas-1.2.4.jar
    -- org.jblas INFO jblas version is 1.2.4
    Simple benchmark for jblas
    Running sanity benchmarks.
    checking vector addition... ok
    -- org.jblas CONFIG BLAS native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
    -- org.jblas CONFIG ArchFlavor native library not found in path. Copying native library libjblas_arch_flavor from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
    -- org.jblas CONFIG Loading libjblas_arch_flavor.so from /lib/static/Linux/amd64/, copying to libjblas_arch_flavor.so.
    -- org.jblas CONFIG Loading libjblas.so from /lib/static/Linux/amd64/sse3/, copying to libjblas.so.
    checking matrix multiplication... ok
    checking existence of dsyev...... ok
    [-0.210656, -0.640445, -0.451188; -0.509085, -0.116445, 0.796815; -0.807515, 0.407556, -0.398408; 0.210656, 0.640445, -0.052780]
    [17.233688; 1.414214; 0.000000]
    [-0.470605, 0.782218, 0.408248; -0.571449, 0.082339, -0.816497; -0.672293, -0.617540, 0.408248]
    [17.233688; 1.414214; 0.000000]
    checking existence of dgesvd...... ok
    Checking complex return values... (z = -21.0 + 88.0i)
    Check whether we're catching XERBLA errors. If you see something like "** On entry to DGEMM  parameter number  4 had an illegal value", it didn't work!
    checking XERBLA... ok
    Sanity checks passed.

    Each benchmark will take about 5 seconds...

    Running benchmark "native matrix multiplication, single precision".
    n = 10   :  1.281 GFLOPS (3203374 iterations in 5.0 seconds)
    n = 100  : 11.192 GFLOPS (27980 iterations in 5.0 seconds)
    n = 1000 : 18.981 GFLOPS (48 iterations in 5.1 seconds)
    -- org.jblas INFO Deleting /tmp/jblas6793705967272229922/libjblas.so
    -- org.jblas INFO Deleting /tmp/jblas6793705967272229922/libjblas_arch_flavor.so
    -- org.jblas INFO Deleting /tmp/jblas6793705967272229922

Now you can use jblas.

Example using jblas (Clojure)

-clatrix Library -incanter Library etc. Matrix operations will be faster, and statistical processing, machine learning, etc. will be possible at higher speeds! Although neandertharl can calculate faster, it is a great advantage to be able to use Incanter, which has functions similar to R. I will.

Advertising? : Clojure for Data Science is good!

I want to start machine learning, but I don't want to start from a place I don't understand! This is a book for people who say. You can learn a wide range from deriving the average to classification and regression. Also, the source code can be found at here, so if you want to see what you can do for the time being, you may want to touch it here.

Recommended Posts

jblas on Arch Linux
Install Minecraft on Arch Linux
Downgrade Mcomix on Arch Linux
Setting up OpenSSH on Arch Linux
Install Arch Linux on DeskMini A300
Rip Music CDs on Arch Linux
Arch Linux Recommendation
Build an NFS server on Arch Linux
Basic usage of Btrfs on Arch Linux
Build a Samba server on Arch Linux
Until you install Arch Linux on VMware
Daemonizing processes on Linux
Linux (WSL) on Windows
NAT router on Linux
Cross-compile windows version from nim on arch | linux
Develop .NET on Linux
Wake on lan on Linux
Deliver OBS footage to Zoom on Arch Linux
Monitor traffic on Linux
Update vscode on linux
Try NeosVR on Linux
Check capacity on Linux
Arch Linux installation notes
LiveUSB creation on Linux
Build an Arch Linux environment on Raspberry Pi
Linux operation on Win10
How to use C216 Audio Controller on Arch Linux
Install Docker on Arch Linux and run it remotely
NTP configuration memo on Linux
Install Linux on your Chromebox
Monitor disk usage on Linux
Use Github Desktop on Linux
Install the JDK on Linux
Elixir = Comfortable on Linux Mint
Recording and playback on Linux
Check TTL on Linux router
Read core voltage on Linux
Put jenv on Amazon Linux
Easy df command on Linux
Linux on Windows -1-: debian introduction
Install tomcat 5.5 on Amazon Linux.
Introducing Elixir on Linux Mint
Use sshpass on Amazon linux2
Install Homebrew on Amazon Linux 2
Paste the link on linux
Install strongSwan 5.9.1 on Amazon Linux 2
Linux environment construction (on WSL environment)
Run FreeBSD on Linux + qemu
Use Linux on Windows 10 (WSL2)
Game distribution to YouTube Live on Arch Linux (Nintendo Switch)
Use host.docker.internal on linux (docker-compose required)
Install Python Pillow on Amazon Linux
Easy copy to clipboard on Linux
Full-human self-made Arch Linux memorandum # 1 installation
Install oracle java8 on amazon linux2
Try installing OpenAM on Amazon Linux
WSL2 ~ Linux on Windows ~ (Part 1: Introduction)
Install CUDA on Linux Mint Mate 20
Completion of docker command on Linux
Run a Linux server on GCP
How to install VMware-Tools on Linux