Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError: org.jblas.NativeBlas? #3

Closed
prismofeverything opened this issue Nov 10, 2012 · 12 comments
Closed

NoClassDefFoundError: org.jblas.NativeBlas? #3

prismofeverything opened this issue Nov 10, 2012 · 12 comments

Comments

@prismofeverything
Copy link

Running the following code on a clean project throws this error (Mac OSX 10.6.8):

(require '[clatrix.core :as m])
(m/pp (m/* (m/rand 2 5) (m/rand 5 2)))

Could not initialize class org.jblas.NativeBlas
[Thrown class java.lang.NoClassDefFoundError]

Backtrace:
0: SimpleBlas.java:245 org.jblas.SimpleBlas.gemm
1: DoubleMatrix.java:1674 org.jblas.DoubleMatrix.mmuli
2: DoubleMatrix.java:3005 org.jblas.DoubleMatrix.mmul
3: core.clj:630 clatrix.core/*

Any ideas?

@prismofeverything
Copy link
Author

Actually, simply cloning the clatrix repo and running lein test gives me this:

java.lang.UnsatisfiedLinkError: Couldn't find the resource libjblas_arch_flavor.jnilib/
/bin/
/lib/static/Mac OS X/x86_64/
/lib/static/Mac OS X/x86_64/
/lib/dynamic/Mac OS X/x86_64/
/lib/dynamic/Mac OS X/x86_64/
/lib/Mac OS X/x86_64/
/Mac OS X/x86_64/
.

    at org.jblas.util.LibraryLoader.loadLibrary(LibraryLoader.java:100)
    at org.jblas.util.ArchFlavor.<clinit>(ArchFlavor.java:50)
    at org.jblas.util.LibraryLoader.loadLibrary(LibraryLoader.java:75)
    at org.jblas.NativeBlas.<clinit>(NativeBlas.java:84)
    at org.jblas.SimpleBlas.gemm(SimpleBlas.java:245)
    at org.jblas.DoubleMatrix.mmuli(DoubleMatrix.java:1674)
    at org.jblas.DoubleMatrix.mmul(DoubleMatrix.java:3005)
    at clatrix.core$_STAR_.invoke(core.clj:615)
    at clatrix.core_test$eval1153.invoke(core_test.clj:16)

I have atlas installed, is this a path issue? Is libjblas_arch_flavor.jnilib/ a directory or a file, (it seems like it would be a file) and if so, is that trailing slash messing it up?

@Quantisan
Copy link
Collaborator

I'm getting the same error when running lein expectations but runs fine when lein repl

@cbilson
Copy link
Contributor

cbilson commented Nov 21, 2012

I get a similar error as well, in a project that uses clatrix:

$ lein repl                                                                                                                                                                
nREPL server started on port 57272                                                                                                                                                  
REPL-y 0.1.0-beta10                                                                                                                                                                 
Clojure 1.4.0                                                                                                                                                                       
...
user=> (require '[clatrix.core :as m])                                                                                                                                              
nil                                                                                                                                                                                 
user=> (m/rnorm 5 5)                                                                                                                                                                
#<Matrix [5 5]>                                                                                                                                                                     
user=> (m/* (m/rnorm 5 5) (m/rnorm 5 5))                                                                                                                                            
-- org.jblas ERROR Couldn't load copied link file: java.lang.UnsatisfiedLinkError: /private/var/folders/p4/ykgp4h_973q9z3j0v_m1r8jc0000gn/T/jblas55269708383826120libjblas_arch_fla\
vor.jnilib:  Library not loaded: /usr/local/lib/libgfortran.3.dylib   Referenced from: /private/var/folders/p4/ykgp4h_973q9z3j0v_m1r8jc0000gn/T/jblas55269708383826120libjblas_arch\
_flavor.jnilib   Reason: image not found.                                                                                                                                           

UnsatisfiedLinkError org.jblas.util.ArchFlavor.SSELevel()I  org.jblas.util.ArchFlavor.SSELevel (ArchFlavor.java:-2)                                                                 

user=> quit                                                                                                                                                                         
Bye for now!$

Is this just a jblas issue that I should talk to them about, or is there some workaround?

@Quantisan
Copy link
Collaborator

I found a solution. If you download and unzip the pre-built jblas native libraries, find the files that it's complaining about, then just copy it into native directory within the project. It works for me on OS X 10.8.2. Note that I already have gfortran and apple developer command line tools installed.

@ejackson
Copy link
Collaborator

This seems to be an OSX issue. On linux, using the standard package, I don't observe the problem :(

@Quantisan
Copy link
Collaborator

Yes, I looked at jblas source and this happens because of an extra IF statement for OSX which loads ArchFlavor.

@cbilson
Copy link
Contributor

cbilson commented Nov 24, 2012

Thanks for the help guys! I was able to get my project working by putting the two files it wanted out of the prebuilt jblas jar (lib/static/Mac OS X/x86_64/libjblas_arch_flavor.jnilib and sse3/libjblas.jnilib) into some place on my project's class path (I just put them in resources for now.)

@cbilson
Copy link
Contributor

cbilson commented Nov 25, 2012

@Quantisan: Where did you see the code in jblas that has an extra IF statement for OSX? I glanced at ArchFlavor and LibraryLoader and it looks right based on the paths in the resources folder. Is it somewhere in the native code?

If you know where the problem is, maybe we can make a pull request for jblas?

It looks like it may actually preferable to have these libraries on the path somewhere (https://github.com/mikiobraun/jblas/blob/master/src/main/java/org/jblas/util/ArchFlavor.java#L47-49) anyway so maybe we should mention this in the clatrix readme?

@Quantisan
Copy link
Collaborator

@cbilson It works for me when I did lein run before. So I'm thinking it might be leiningen not expanding native folder during lein test. I don't know exactly where's the problem so couldn't patch it.

@ejackson
Copy link
Collaborator

ejackson commented Jan 5, 2013

@cbilson: Can you please update the docs with the solution you found and then we can close the issue ?

@Quantisan
Copy link
Collaborator

jblas 1.2.2 fixed this issue

@ejackson
Copy link
Collaborator

ejackson commented Jan 5, 2013

Great, thanks Paul.

@ejackson ejackson closed this as completed Jan 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants