uncomplicate / neanderthal

Fast Clojure Matrix Library
http://neanderthal.uncomplicate.org
Eclipse Public License 1.0
1.06k stars 56 forks source link

Under Java 11, cannot access jdk.internal.ref.Cleaner #55

Closed bombaywalla closed 5 years ago

bombaywalla commented 5 years ago

Reproduction steps on Mac OS 10.13.6.

First clone the neanderthal repo. Then cd to the hello-world example directory. Then run the following ...

Dorabs-iMac:hello-world dorab$ lein repl nREPL server started on port 60233 on host 127.0.0.1 - nrepl://127.0.0.1:60233 REPL-y 0.4.3, nREPL 0.6.0 Clojure 1.10.0 OpenJDK 64-Bit Server VM 11.0.1+13 Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) Javadoc: (javadoc java-object-or-class-here) Exit: Control+D or (exit) or (quit) Results: Stored in vars 1, 2, 3, an exception in e

user=> (require '[uncomplicate.commons.core :refer [with-release]]) nil user=> (require '[uncomplicate.neanderthal.native :refer :all]) nil user=> (require '[uncomplicate.neanderthal.core :refer :all]) nil user=> (with-release [x (dv 1.0 2.0)] (println x)) SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

RealBlockVector[double, n:2, offset: 0, stride:1]

[ 1.00 2.00 ]

Execution error (IllegalAccessError) at uncomplicate.commons.core/eval1620$fn (core.clj:69). class uncomplicate.commons.core$eval1620$fn__1621 (in unnamed module @0x7700fe63) cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module @0x7700fe63

user=> Bye for now! Dorabs-iMac:hello-world dorab$

blueberry commented 5 years ago

Under Java 9+, you have to explicitly enable base module.

Add this to :jvm-opts in your leiningen project (or the equivalent if you're using something else): "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"

bombaywalla commented 5 years ago

Thanks. That worked. Perhaps that should be in the installation docs?

kwccoin commented 5 years ago

I still have this problem even I use these lines:

user=> (with-release [x (dv 0.3 0.9)
  #_=>                w1 (dge 4 2 [0.3 0.6
  #_=>                             0.1 2.0
  #_=>                             0.9 3.7
  #_=>                             0.0 1.0]
  #_=>                        {:layout :row})
  #_=>                h1 (dv 4)]
  #_=>   (println (mv! w1 x h1)))
#RealBlockVector[double, n:4, offset: 0, stride:1]
[   0.63    1.83    3.60    0.90 ]

Execution error (IllegalAccessError) at uncomplicate.commons.core/eval1628$fn (core.clj:69).
class uncomplicate.commons.core$eval1628$fn__1629 (in unnamed module @0x7edf5e87) cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module @0x7edf5e87

Project.cli

(defproject hello-world "0.23.1"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [uncomplicate/neanderthal "0.23.1"]]
  :exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
               [org.jcuda/jcublas-natives :classifier "apple-x86_64"]]
  :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true" 
                       #_"--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"]
)
bombaywalla commented 5 years ago

Looks like you have commented out the line that should not be commented. Remove the #_ just before the double-quote. And see if that helps.

kwccoin commented 5 years ago

After 2 weeks and whole weekend finally resolved it.

Problem solved:

Try this set cd C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019\windows\mkl\bin mklvars intel64 where mkl_intel_thread.dll where java set

cd C:\Users\\Documents\GitHub\neanderthal-err\examples\hello-world set LD_LIBRARY_PATH = %PATH% set DYLD_LIBRARY_PATH = %PATH% set

lein repl

(System/getenv "DYLD_LIBRARY_PATH") (System/getenv "LD_LIBRARY_PATH") (System/getenv "PATH")

(require '[uncomplicate.commons.core :refer [with-release]] '[uncomplicate.neanderthal [native :refer [dv dge]] [core :refer [mv!]]]) ;;mtl can be found but needed to use mtlvars.bat in its bin

(with-release [x (dv 0.3 0.9) w1 (dge 4 2 [0.3 0.6 0.1 2.0 0.9 3.7 0.0 1.0] {:layout :row}) h1 (dv 4)] (println (mv! w1 x h1)))

kwccoin commented 5 years ago

Looks like you have commented out the line that should not be commented. Remove the #_ just before the double-quote. And see if that helps.

Thanks but it is not me; it is in the example! I now raise a change to that just a moment ago.

I finally found it during my 36 hours struggle to start the GPU-Clojure series. Waste 36 hour of my life. :=)) :-((

blueberry commented 5 years ago

The option is under the comment because it is specific under Java 9+ and Java 8 would not recognize it and raise an error. All these things are explained in the Getting started guide.