uncomplicate / neanderthal

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

No namespace: uncomplicate.neanderthal.internal.host.mkl #95

Closed devurandom closed 4 years ago

devurandom commented 4 years ago

I am trying to run the OpenCL2 hello world example. However the ns declaration already fails:

(in-ns 'hello-world.opencl2)
=> #object[clojure.lang.Namespace 0x764accdb "hello-world.opencl2"]
(ns hello-world.opencl2
  (:require [uncomplicate.commons.core :refer [with-release]]
            [uncomplicate.clojurecl.core :refer [with-default set-default! release-context!]]
            [uncomplicate.neanderthal
             [core :refer [asum]]
             [opencl :refer [clv with-default-engine set-engine!]]]))
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.
Execution error (UnsatisfiedLinkError) at java.lang.ClassLoader$NativeLibrary/load0 (ClassLoader.java:-2).
/tmp/libneanderthal-mkl-0.30.015214742619927315764.so: libmkl_rt.so: cannot open shared object file: No such file or directory

I tried to venture on manually anyway. Since the first OpenCL platform on my system appears to be unusable, I use the other one (thus I cannot use set-default!, but have to copy parts of it):

(uncomplicate.clojurecl.core/set-platform! (second (uncomplicate.clojurecl.core/platforms)))
=> #object[org.jocl.cl_platform_id 0x29a1a2f8 "cl_platform_id[0x7f1904fd89e0]"]
(let [dev (first (uncomplicate.clojurecl.core/sort-by-cl-version (uncomplicate.clojurecl.core/devices)))]
  (uncomplicate.clojurecl.core/set-context! (uncomplicate.clojurecl.core/context [dev]))
  (uncomplicate.clojurecl.core/set-queue! (uncomplicate.clojurecl.core/command-queue dev)))
=> #object[uncomplicate.clojurecl.internal.impl.CLCommandQueue 0x3a8e0cd0 "#CLCommandQueue[0x7f1a2061b278]"]

That seems to have worked quite well. :)

Now let's try again to require the Neanderthat functions:

(ns hello-world.opencl2
  (:require [uncomplicate.commons.core :refer [with-release]]
            [uncomplicate.clojurecl.core :refer [with-default set-default! release-context!]]
            [uncomplicate.neanderthal
             [core :refer [asum]]
             [opencl :refer [clv with-default-engine set-engine!]]]))
Syntax error compiling at (uncomplicate/neanderthal/native.clj:1:1).
No namespace: uncomplicate.neanderthal.internal.host.mkl

The reason might be that I simply do not have MKL installed on my system. I do have an AMD system with a proper GPU, so I do not see why I would need the MKL. How do I prevent Neanderthal from trying to use the MKL and make it use OpenCL instead?

P.S. I come from https://dragan.rocks/articles/19/Deep-Learning-in-Clojure-From-Scratch-to-GPU-1-Representing-Layers-and-Connections#orgc22d894 so maybe I missed something that describes how to configure Neanderthal?

blueberry commented 4 years ago

MKL works on both Intel and AMD CPUs. You need to install it because some fundamental data transferring functions use it. Otherwise, how would you move any data to the GPU? Anyway, if for some reason you'd wish to avoid MKL, you could provide another implementation of a CPU engine, but I can't see why you'd ever want that on an x86_64 CPU.