question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FreeBSD] `mmul` and Execution error (UnsatisfiedLinkError) at org.jblas.NativeBlas/dgemm

See original GitHub issue

I am aware this seems to be a recurring issue but after spending couple of days trying most of the proposed solutions (here in Wiki and issues as well as in other forums) I have not been able to fix the problem.

Before I describe the problem here is some context:

OS: FreeBSD 12.1-RELEASE r354233 GENERIC amd64 jblas: 1.2.5

What/How I am using jblas?

Clojure is the primary language. I am calling jblas functions via Clojure’s Java Interop

Error using mmul

I can successfully (without error) use the matrix multiplication function mmul when I am multiplying a row vector (1 x n) and a column vector (n x 1).

But when I use mmul to multiply a column vector (m x 1) and a row vector (1 x n) or among two compatible matrices I get

Execution error (UnsatisfiedLinkError) at org.jblas.NativeBlas/dgemm (NativeBlas.java:-2).
org.jblas.NativeBlas.dgemm(CCIIID[DII[DIID[DII)V

Because row * column can be performed using mmul I can use this to fill out the product (matrix) for column * row and matrix * matrix. But I’d prefer not to do this. Can somebody help me how to fix this dependency in FreeBSD?

Since jblas 1.2.5 has moved to openblas I have installed this and other potential dependencies

  • pkg install openblas
  • pkg install gcc
  • pkg install linux-c7-libgfortran

The installed openblas libraries (pkg info -lx openblas) are in

openblas-0.3.10,1:
        /usr/local/include/cblas.h
        /usr/local/include/f77blas.h
        /usr/local/include/lapack.h
        /usr/local/include/lapacke.h
        /usr/local/include/lapacke_config.h
        /usr/local/include/lapacke_mangling.h
        /usr/local/include/lapacke_utils.h
        /usr/local/include/openblas_config.h
        /usr/local/lib/cmake/openblas/OpenBLASConfig.cmake
        /usr/local/lib/cmake/openblas/OpenBLASConfigVersion.cmake
        /usr/local/lib/libopenblas.a
        /usr/local/lib/libopenblas.so
        /usr/local/lib/libopenblas.so.0
        /usr/local/lib/libopenblasp-r0.3.10.a
        /usr/local/lib/libopenblasp-r0.3.10.so
        /usr/local/libdata/pkgconfig/openblas.pc
        /usr/local/share/licenses/openblas-0.3.10,1/BSD3CLAUSE
        /usr/local/share/licenses/openblas-0.3.10,1/LICENSE
        /usr/local/share/licenses/openblas-0.3.10,1/catalog.mk

Looking at the source code ~/.m2/repository/org/jblas/jblas/1.2.5/jblas-1.2.3.jar/org//jblas/NativeBlastLibraryLoader.class I am wondering if I need to change this to fix the problem (I would prefer not to use this approach).

package org.jblas;

import org.jblas.exceptions.UnsupportedArchitectureException;
import org.jblas.util.LibraryLoader;
import org.jblas.util.Logger;

class NativeBlasLibraryLoader {
    NativeBlasLibraryLoader() {
    }

    static void loadLibraryAndCheckErrors() {
        try {
            try {
                System.loadLibrary("jblas");
            } catch (UnsatisfiedLinkError var3) {
                Logger.getLogger().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).");
                loadDependentLibraries();
                (new LibraryLoader()).loadLibrary("jblas", true);
            }

            double[] a = new double[1];
            NativeBlas.dgemm('N', 'N', 1, 1, 1, 1.0D, a, 0, 1, a, 0, 1, 1.0D, a, 0, 1);
        } catch (UnsatisfiedLinkError var4) {
            String arch = System.getProperty("os.arch");
            String name = System.getProperty("os.name");
            if (name.startsWith("Windows") && var4.getMessage().contains("Can't find dependent libraries")) {
                System.err.println("On Windows, you need some additional support libraries.\nFor example, you can install the two packages in cygwin:\n\n   mingw64-x86_64-gcc-core   mingw64-x86_64-gfortran\n\nand add the directory <cygwin-home>\\usr\\x86_64-w64-mingw32\\sys-root\\mingw\\bin to your path.\n\nFor more information, see http://github.com/mikiobraun/jblas/wiki/Missing-Libraries");
            }
        } catch (UnsupportedArchitectureException var5) {
            System.err.println(var5.getMessage());
        }

    }

    public static void loadDependentLibraries() {
        String arch = System.getProperty("os.arch");
        String name = System.getProperty("os.name");
        LibraryLoader loader = new LibraryLoader();
        if (name.startsWith("Windows") && arch.equals("amd64")) {
            loader.loadLibrary("libgcc_s_sjlj-1", false);
            loader.loadLibrary("libgfortran-3", false);
        } else if (name.startsWith("Windows") && arch.equals("x86")) {
            loader.loadLibrary("libgcc_s_dw2-1", false);
            loader.loadLibrary("libgfortran-3", false);
        } else if (name.equals("Linux") && arch.equals("amd64")) {
            loader.loadLibrary("quadmath-0", false);
            loader.loadLibrary("gfortran-4", false);
        }

    }
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
mikiobrauncommented, Nov 28, 2020

Ah wait, that’s a bug. There was a typo in the definition of supported flags. I just pushed a commit that fixes that to main. 🤦🏻‍♂️

0reactions
mikiobrauncommented, Nov 28, 2020

You’re very welcome, and thanks for putting in so much work to make jblas work for you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: [Nodeld: CreateStack] org.jblas.NativeBlas.dgemm ...
Hi, I'm trying to coregister one image of ALOS1 with another image of COSMO Skymed. Both images are enough similar between them.
Read more >
Unsatisfied link error when running on FreeBSD #302 - GitHub
I'm calling Native.loadLibrary("c", BSDCLibrary.class) from my FreeBSD (amd64) machine. Running with jna.debug_load set, ...
Read more >
java.lang.UnsatisfiedLinkError within one Java environment ...
Hello, jblas world: I'm trying to run jblas in some unit tests within Teamcity (a build server). There is something about the environment ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found