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

2021 versions of MKL do not work on Windows #119

Open
empperi opened this issue Nov 7, 2021 · 10 comments
Open

2021 versions of MKL do not work on Windows #119

empperi opened this issue Nov 7, 2021 · 10 comments

Comments

@empperi
Copy link

empperi commented Nov 7, 2021

Intel changed MKL to be part of the oneAPI in the 2021 version. With that change the dll files within MKL changed somewhat. The most notable change is that mkl_rt.dll has been renamed to mkl_rt.1.dll. This breaks compatibility with org.bytedeco/mkl-platform-redist since the neanderthal-mkl-0.33.013762547502008737550.dll generated into temp folder has a dependency to mkl_rtt.dll. This causes Neanderthal Native bootstrap to fail with java.lang.UnsatisfiedLinkError.

When reverting to [org.bytedeco/mkl-platform-redist "2020.3-1.5.4"] problems go away since that version still contains mkl_rt.dll.

@speakerToSystems
Copy link

The 2022 version
org.bytedeco/mkl-platform-redist {:mvn/version "2022.0-1.5.7"}
fails to load on Linux, reporting:
No namespace: uncomplicate.neanderthal.internal.host.mkl

2020.3-1.5.4 loads properly.

@behrica
Copy link

behrica commented Jun 22, 2022

The 2022 version org.bytedeco/mkl-platform-redist {:mvn/version "2022.0-1.5.7"} fails to load on Linux, reporting: No namespace: uncomplicate.neanderthal.internal.host.mkl

2020.3-1.5.4 loads properly.

I have the same issue it seems:
uncomplicate/deep-diamond#15

It was a bit hidden, as I had a systemwide MKL installation, which was then found, but gave other errors.
Removing MKL results the in teh same issue.

@behrica
Copy link

behrica commented Jun 22, 2022

I cannot get 2020.3-1.5.4 working neither. See #127

@blueberry
Copy link
Member

I have just released 0.46.0, which is now compiled with oneAPI MKL 2022.2 on Windows and Linux, and 2021.1 on Mac.

All versions of 2022 should work, including the natives bundled with appropriate versions of bytedeco mkl-platform-redist

(please see the example project in https://github.com/uncomplicate/neanderthal/blob/master/examples/hello-world/project.clj)

So, you should either:

  • include bytedeco, or
  • have the 2022 version of the MKL natives somewhere in your path. You can just extract the relevant dlls from any source, including the bytedeco distribution. You do not have to install MKL from Intel's installer)

Please check whether this works for you now.

@yangchenyun
Copy link

yangchenyun commented Apr 16, 2023

I am running into similar issues on Mac OSX/Intel chips with

(ns ml-clj.core
  (:use [uncomplicate.neanderthal core native]))

Loading the module yields the following error and it seems the MLK library is not loaded properly.

java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class uncomplicate.neanderthal.internal.host.MKL

Caused by: java.lang.NoClassDefFoundError: Could not initialize class uncomplicate.neanderthal.internal.host.MKL

Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/d6/nf1dx1n526v5727gmbxb6zw00000gn/T/libneanderthal-mkl-0.46.04580469173035992241.jnilib [in thread "nREPL-session-4bee9757-2f43-4f6b-b21d-9743e4f2aa12"]

Here is my lein setup, following the helloworld

(defproject ml_clj "0.1.0-SNAPSHOT"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.11.1"]
                 [uncomplicate/neanderthal "0.46.0"]

                 ;; macOS requires MKL 2021, either global, or via bytedeco; for example:
                 ;; [org.bytedeco/mkl-platform-redist "2022.2-1.5.8"]
                 [org.bytedeco/mkl-platform-redist "2021.1-1.5.5"]
                 ]
  
  ;; Nvidia doesn't ship CUDA for macOS; you have to add this to your project
  :exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
               [org.jcuda/jcublas-natives :classifier "apple-x86_64"]]

  ;; If on Java 9+, you have to uncomment the following JVM option.
  :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true" 
                       "-XX:MaxDirectMemorySize=16g" 
                       "-XX:+UseLargePages" 
                       "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED" 
                       "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"]

  :repl-options {:init-ns ml-clj.core})

@yangchenyun
Copy link

After installing the Intel MLK on Mac OSX (2023.1) version, the files are there, but I have to manually created symbolic link files in order to let the library finds it:

The module expects *.1.dylib, how ever the default installation only give *.dylib or *.2.dylib form.

total 2703984
drwxr-xr-x  64 root  wheel       2048 Apr 16 00:30 .
drwxr-xr-x  11 root  wheel        352 Apr 16 00:20 ..
drwxr-xr-x   3 root  wheel         96 Apr 16 00:20 cmake
-rwxr-xr-x   1 root  wheel   53073120 Mar  7 09:32 libmkl_avx.2.dylib
-rwxr-xr-x   1 root  wheel   50218736 Mar  7 09:32 libmkl_avx2.2.dylib
-rwxr-xr-x   1 root  wheel   66766320 Mar  7 09:32 libmkl_avx512.2.dylib
lrwxr-xr-x@  1 root  wheel         30 Apr 16 00:25 libmkl_blacs_mpich_ilp64.1.dylib -> libmkl_blacs_mpich_ilp64.dylib
-rwxr-xr-x   1 root  wheel     518592 Mar  7 09:32 libmkl_blacs_mpich_ilp64.2.dylib
-rw-r--r--   1 root  wheel     952328 Mar  7 09:32 libmkl_blacs_mpich_ilp64.a
lrwxr-xr-x   1 root  wheel         32 Mar  8 10:13 libmkl_blacs_mpich_ilp64.dylib -> libmkl_blacs_mpich_ilp64.2.dylib
lrwxr-xr-x@  1 root  wheel         29 Apr 16 00:25 libmkl_blacs_mpich_lp64.1.dylib -> libmkl_blacs_mpich_lp64.dylib
-rwxr-xr-x   1 root  wheel     306944 Mar  7 09:32 libmkl_blacs_mpich_lp64.2.dylib
-rw-r--r--   1 root  wheel     579168 Mar  7 09:32 libmkl_blacs_mpich_lp64.a
lrwxr-xr-x   1 root  wheel         31 Mar  8 10:13 libmkl_blacs_mpich_lp64.dylib -> libmkl_blacs_mpich_lp64.2.dylib
-rw-r--r--   1 root  wheel     545120 Mar  7 09:32 libmkl_blas95_ilp64.a
-rw-r--r--   1 root  wheel     546280 Mar  7 09:32 libmkl_blas95_lp64.a
lrwxr-xr-x@  1 root  wheel         22 Apr 16 00:25 libmkl_cdft_core.1.dylib -> libmkl_cdft_core.dylib
-rwxr-xr-x   1 root  wheel     182784 Mar  7 09:32 libmkl_cdft_core.2.dylib
-rw-r--r--   1 root  wheel     188056 Mar  7 09:32 libmkl_cdft_core.a
lrwxr-xr-x   1 root  wheel         24 Mar  8 10:13 libmkl_cdft_core.dylib -> libmkl_cdft_core.2.dylib
lrwxr-xr-x@  1 root  wheel         17 Apr 16 00:25 libmkl_core.1.dylib -> libmkl_core.dylib
-rwxr-xr-x   1 root  wheel   69805696 Mar  7 09:32 libmkl_core.2.dylib
-rw-r--r--   1 root  wheel  415735328 Mar  7 09:32 libmkl_core.a
lrwxr-xr-x   1 root  wheel         19 Mar  8 10:13 libmkl_core.dylib -> libmkl_core.2.dylib
lrwxr-xr-x@  1 root  wheel         24 Apr 16 00:25 libmkl_intel_ilp64.1.dylib -> libmkl_intel_ilp64.dylib
-rwxr-xr-x   1 root  wheel   35226784 Mar  7 09:32 libmkl_intel_ilp64.2.dylib
-rw-r--r--   1 root  wheel   53287632 Mar  7 09:32 libmkl_intel_ilp64.a
lrwxr-xr-x   1 root  wheel         26 Mar  8 10:13 libmkl_intel_ilp64.dylib -> libmkl_intel_ilp64.2.dylib
lrwxr-xr-x@  1 root  wheel         25 Apr 16 00:23 libmkl_intel_lp64.1.dylib -> libmkl_intel_lp64.2.dylib
-rwxr-xr-x   1 root  wheel   38800288 Mar  7 09:32 libmkl_intel_lp64.2.dylib
-rw-r--r--   1 root  wheel   58687232 Mar  7 09:32 libmkl_intel_lp64.a
lrwxr-xr-x   1 root  wheel         25 Mar  8 10:13 libmkl_intel_lp64.dylib -> libmkl_intel_lp64.2.dylib
lrwxr-xr-x@  1 root  wheel         25 Apr 16 00:25 libmkl_intel_thread.1.dylib -> libmkl_intel_thread.dylib
-rwxr-xr-x   1 root  wheel   68143376 Mar  7 09:32 libmkl_intel_thread.2.dylib
-rw-r--r--   1 root  wheel   77499760 Mar  7 09:32 libmkl_intel_thread.a
lrwxr-xr-x   1 root  wheel         27 Mar  8 10:13 libmkl_intel_thread.dylib -> libmkl_intel_thread.2.dylib
-rw-r--r--   1 root  wheel    6683200 Mar  7 09:32 libmkl_lapack95_ilp64.a
-rw-r--r--   1 root  wheel    6593504 Mar  7 09:32 libmkl_lapack95_lp64.a
-rwxr-xr-x   1 root  wheel   49775168 Mar  7 09:32 libmkl_mc3.2.dylib
lrwxr-xr-x@  1 root  wheel         15 Apr 16 00:25 libmkl_rt.1.dylib -> libmkl_rt.dylib
-rwxr-xr-x   1 root  wheel   18221552 Mar  7 09:32 libmkl_rt.2.dylib
lrwxr-xr-x   1 root  wheel         17 Mar  8 10:13 libmkl_rt.dylib -> libmkl_rt.2.dylib
lrwxr-xr-x@  1 root  wheel         28 Apr 16 00:25 libmkl_scalapack_ilp64.1.dylib -> libmkl_scalapack_ilp64.dylib
-rwxr-xr-x   1 root  wheel    7770640 Mar  7 09:32 libmkl_scalapack_ilp64.2.dylib
-rw-r--r--   1 root  wheel   10573696 Mar  7 09:32 libmkl_scalapack_ilp64.a
lrwxr-xr-x   1 root  wheel         30 Mar  8 10:13 libmkl_scalapack_ilp64.dylib -> libmkl_scalapack_ilp64.2.dylib
lrwxr-xr-x@  1 root  wheel         27 Apr 16 00:25 libmkl_scalapack_lp64.1.dylib -> libmkl_scalapack_lp64.dylib
-rwxr-xr-x   1 root  wheel    7655088 Mar  7 09:32 libmkl_scalapack_lp64.2.dylib
-rw-r--r--   1 root  wheel   10431784 Mar  7 09:32 libmkl_scalapack_lp64.a
lrwxr-xr-x   1 root  wheel         29 Mar  8 10:13 libmkl_scalapack_lp64.dylib -> libmkl_scalapack_lp64.2.dylib
lrwxr-xr-x@  1 root  wheel         23 Apr 16 00:25 libmkl_sequential.1.dylib -> libmkl_sequential.dylib
-rwxr-xr-x   1 root  wheel   33416832 Mar  7 09:32 libmkl_sequential.2.dylib
-rw-r--r--   1 root  wheel   34146200 Mar  7 09:32 libmkl_sequential.a
lrwxr-xr-x   1 root  wheel         25 Mar  8 10:13 libmkl_sequential.dylib -> libmkl_sequential.2.dylib
lrwxr-xr-x@  1 root  wheel         23 Apr 16 00:25 libmkl_tbb_thread.1.dylib -> libmkl_tbb_thread.dylib
-rwxr-xr-x   1 root  wheel   44803312 Mar  7 09:32 libmkl_tbb_thread.2.dylib
-rw-r--r--   1 root  wheel   75968648 Mar  7 09:32 libmkl_tbb_thread.a
lrwxr-xr-x   1 root  wheel         25 Mar  8 10:13 libmkl_tbb_thread.dylib -> libmkl_tbb_thread.2.dylib
-rwxr-xr-x   1 root  wheel   15636624 Mar  7 09:32 libmkl_vml_avx.2.dylib
-rwxr-xr-x   1 root  wheel   14763536 Mar  7 09:32 libmkl_vml_avx2.2.dylib
-rwxr-xr-x   1 root  wheel   14113120 Mar  7 09:32 libmkl_vml_avx512.2.dylib
-rwxr-xr-x   1 root  wheel   14333008 Mar  7 09:32 libmkl_vml_mc3.2.dylib
drwxr-xr-x   3 root  wheel         96 Apr 16 00:20 locale
drwxr-xr-x  15 root  wheel        480 Apr 16 00:20 pkgconfig

@blueberry
Copy link
Member

Yes. Mac OS build of Neanderthal requires MKL 2021, since that's the last that could be installed on my old Macbook Air. If you need newer MKL, you'd need to build neandertal-native yourself through leiningen.

@jjttjj
Copy link

jjttjj commented Apr 16, 2023

Hi I'm sorry if this isn't on topic but since there is a range of dependency issues discussed here I thought it would be a good place for mine, when using linux. I have no issues with this setup on windows. Let me know if you would prefer a seperate issue.

Using Arch Linux, when I attempt to require

[uncomplicate.neanderthal.cuda :refer [cuda-float]]

with the latest neanderthal dependencies:

uncomplicate/neanderthal {:mvn/version "0.46.0"}
  org.bytedeco/mkl-platform-redist {:mvn/version "2022.2-1.5.8"}

I get the following error

Execution error (UnsatisfiedLinkError) at jcuda.LibUtils/loadLibrary (LibUtils.java:218).
Error while loading native library "JCublas2-11.8.0-linux-x86_64"
Operating system name: Linux
Architecture         : amd64
Architecture bit size: 64
---(start of nested stack traces)---
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: no JCublas2-11.8.0-linux-x86_64 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib

Is there an obvious step I'm missing?

@yangchenyun
Copy link

Yes. Mac OS build of Neanderthal requires MKL 2021, since that's the last that could be installed on my old Macbook Air. If you need newer MKL, you'd need to build neandertal-native yourself through leiningen.

Thanks. There are a few difference between my setup experience and the documentation:

  1. [org.bytedeco/mkl-platform-redist "2021.1-1.5.5"] is not sufficient to use native. From my understanding, some JAR is downloaded for JNI, but the lein wasn't able to find it.
  2. If installing MKL from intel only has 2023 version at the moment, and it would requires manually setup symbolic links for individual dylib files. (The path is right).

@yangchenyun
Copy link

I did a big more digging. Indeed, bytedeco didn't setup the look up path or it is being ignored.

After lein deps I fixed it by manually creating the expected folder for dylib:

sudo mkdir -p /opt/intel/oneapi/mkl/latest/
sudo ln -s $HOME/.javacpp/cache/mkl-2021.1-1.5.5-macosx-x86_64-redist.jar/org/bytedeco/mkl/macosx-x86_64/ /opt/intel/oneapi/mkl/latest/lib

This solution is not elegant and not portable, a proper way would be inside this library and query bytedeco to load the library. @blueberry you might be interested.

(require '[org.bytedeco.javacpp.Loader :refer [loadLibrary]])

; Load the module's Dylib
(loadLibrary "my-module")

; Get the path to the Dylib
(def dylib-path (-> (Loader.load "my-module") .path))

; Get the list of native functions provided by the Dylib
(def native-functions (-> (Loader.load "my-module") .info .getDeclaredMethods))

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

6 participants