Hi all 👋 I'm having some difficulty getting neanderthal installed on a new machine. Requiring any of the cuda-related libraries results in this error:
Execution error at (info.clj:9).
No namespace: uncomplicate.clojurecuda.internal.constants
Google search for the error message showed 0 hits. Am I missing anything here?(ns main
(:require
[uncomplicate.clojurecuda.core :as cuda]
[uncomplicate.neanderthal.core :refer [copy copy dot mm mm mm! zero]]
[uncomplicate.commons.core :refer [with-release]]
[uncomplicate.neanderthal.cuda :refer [cuge cuv with-default-engine]]
[uncomplicate.neanderthal.random :refer [rand-uniform!]]))
This was after updating versions to the latest.
I can import the MKL native libraries and work with the CPU but the GPU requires always errors as above.
my :deps are
{ com.fzakaria/slf4j-timbre {:mvn/version "0.4.1"}
com.taoensso/timbre {:mvn/version "6.6.1"}
criterium/criterium {:mvn/version "0.4.6"}
org.bytedeco/mkl-platform-redist {:mvn/version "2025.0-1.5.11"} ;; to run on Intel
org.bytedeco/cuda-platform {:mvn/version "12.6-9.5-1.5.11"}
org.clojure/math.numeric-tower {:mvn/version "0.1.0"}
org.clojure/tools.cli {:mvn/version "1.1.230"}
uncomplicate/commons {:mvn/version "0.16.1"}
uncomplicate/clojurecuda {:mvn/version "0.21.0"} ;; to run on NVIDIA GPU
uncomplicate/neanderthal {:mvn/version "0.52.0"}
}
Please specify the architecture and the OS you're using.
x86_64 with Ubuntu
Have you tried the hello-world example project from the neanderthal repository? (BTW, you have a Nvidia GPU I assume)
Yes, NVIDIA GPU. And I should have specified this is a small program already written against neanderthal 49.1 so I know the code works. Or worked (past tense). I'm trying to port it to a new machine.
I can't run the hello-world example either. The problem occurs on require
(defproject hello-world "0.52.0" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.11.3"] [uncomplicate/neanderthal "0.52.0"] [org.bytedeco/mkl "2025.0-1.5.11" :classifier linux-x86_64-redist] [org.bytedeco/cuda "12.6-9.5-1.5.11" :classifier linux-x86_64-redist] ;; On windows, replace the last two lines with: ;;[org.bytedeco/mkl "2024.0-1.5.10" :classifier windows-x86_64-redist] ;;[org.bytedeco/cuda "12.3-8.9-1.5.10" :classifier windows-x86_64-redist] ] :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true"] ;; We need direct linking for properly resolving types in heavy macros and avoiding reflection warnings! ;; :global-vars {warn-on-reflection true ;; assert false ;; unchecked-math :warn-on-boxed ;; print-length 16} )
Can you please update to the latest versions (or copy/paste this into helo-world's project.clj)? I've just tried it and it works... Maybe you need to configure drivers on your new machine? Does the old version of your project that worked on the old machine works on that new machine? If not, then most probably the problem is in the cuda drivers...
I'm using deps.edn and clojure CLI but I think I can translate.
;; deps.edn
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.3"}
uncomplicate/neanderthal {:mvn/version "0.52.0"}
org.bytedeco/mkl$linux-x86_64-redist {:mvn/version "2025.0-1.5.11"}
org.bytedeco/cuda$linux-x86_64-redist {:mvn/version "12.6-9.5-1.5.11"}}
:aliases {:dev {:extra-paths []
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
"-Djna.debug_load=true"]
:extra-deps {cider/cider-nrepl {:mvn/version "0.52.0"}
com.fzakaria/slf4j-timbre {:mvn/version "0.4.1"}
org.scicloj/clay {:mvn/version "2-beta11"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"
"--interactive"]}}}
then in the repl
user=> (require '[uncomplicate.clojurecuda.core])
Execution error at (info.clj:9).
No namespace: uncomplicate.clojurecuda.internal.constants
same error unfortunately.Is this perhaps hiding some linker errors? I've got my CUDA environment set up for C/C++ projects (I can compile and use llama.cpp for instance). According to ldd all the libjni wrappers link against the correct shared objects. But things might be different in JVM land? Does it respect LD_LIBRARY_PATH? Or should I experiement with jvm options?
Is it a CUDA version thing? I'm on V12.0.140
Let me know if anyone has any ideas.
All CUDA-related things should be bundled in jars and independent of your local installation. However, you have to have the appropriate Nvidia GPU driver compatible with the CUDA version you're using (in this caes, 12.6). Also, don't forget direct-linking (unrelated to your issue, but prevents incidental reflection)
I'm using deps.edn and clojure CLI but I think I can translate.But don't translate, that's just creating more potential failure points. First, use hello-world and update it with these new versions. Once you're sure that everything works on your system, do it any way you want. :)
Sorry, I'm not familiar with leiningen - I've got it installed now but still hitting the same issue
git clone
cd neanderthal/example/hello-world
lein repl
...
user=> (require '[uncomplicate.neanderthal.cuda])
Execution error at (info.clj:9).
No namespace: uncomplicate.clojurecuda.internal.constants but, go to the hello world project, and find the cuda namespace. there's a short cuda example there. evaluate that namespace...
same error when I eval the ns through the nrepl
And maybe a useful addition for context: this is part of an existing codebase that worked as of a few months ago. No code changes. This is on the same physical hardware but upgraded OS and drivers. Considering code and hardware are held constant, I suspect the problem is somewhere with the drivers but I'm just guessing.
Remove ./m2/repository/org/bytedeco/cuda-whatever and run lein deps from the (updated) hello-world project. Run it from the terminal, NOT from whatever IDE you were using. WAIT until it downloads javacpp's cuda redist among other things, which might take a while. Then, try the cuda namespace from the hello-world.
There must be some misunderstanding. I have tried that multiple times and pasted the terminal output. Have you read the thread above? I'll try again since you apparently don't believe me. https://asciinema.org/a/PXUO0NjhPeOjKlEO7lpZLHm6y
> "The definition of insanity is doing the same thing over and over again and expecting different results"
I understand that this is frustrating for you. But we are trying to help. Let's be kind.
I, too, find it difficult to explain the results you're seeing.
There must be something we're missing, and it would be good to get to the bottom of it.
In searching around, I found something that seems to indicate that first library to be loaded uses the java.library.path but the libraries that the first library uses are found using whatever the underlying OS uses. So, try appending /lib/x86_64-linux-gnu to LD_LIBRARY_PATH in the environment before you start up the clojure REPL. Then check in the REPL whether the JVM has the correct env var value. Then try loading the libcuda.
So... Are you using the recent versions that I copy/pasted here? Apparently not, since your screenshot shows cuda 12.3, and the latest neanderhtal uses 12.6. Also, javacpp 1.5.10 vs 1.5.11. Also, did you try to evaluate the cuda namespace from the hello-world, as I suggested? No, you required the cuda namespace in an one-liner that you wrote. That all might or might not be the source of the error, but you could eliminate a lot of guesswork if you tried the project that I shared exactly for these testing purposes. So, look here https://github.com/uncomplicate/neanderthal/tree/master/examples/hello-world, especially here https://github.com/uncomplicate/neanderthal/blob/master/examples/hello-world/src/hello_world/cuda.clj. If it doesn't work, then the problem is almost certainly in the setup of your system (but that should require only the appropriate cuda drivers - make sure they are recent!). Now, that's all I could help with the available information.
Sure, the problem could be also in my system, while everyone other getting mixed results. But then, I should be able to somehow reproduce the error (which I currently can't).
BTW cuda is distributed through javacpp, and should not require any system installation. But, if the CUDA is already on your system, maybe it's trying to pick these binaries before it even tries the javacpp-ones. Can you try to remove the system-provided cuda and try then. You do need Nvidia drivers, but you do not need cuda toolkit installed on your system (and if you do want the system provided cuda toolkit, make sure it's a compatible version to the one used in neanderthal).
also, check that the Nvidia drivers that come with your system support cuda 12.6. If they don't you'll need newer drivers (or older neanderthal/javacpp).
Do you still have access to the old system? Could you first try to upgrade versions on the old, working, system, and then see about the new one?
The error message makes it look like Clojure cannot find the given namespace on the CLASSPATH.
To verify, you might try (require 'uncomplicate.clojurecuda.internal.constants) at the REPL and see if you still get the error.
Other things I can suggest: (a) clj -Stree -A:dev or (b) clj -Spath -A:dev or (c) look at the contents of the jar file under ~/.m2 or (d) try removing everything under ~/.m2 and then running clj -A:dev -P.
You also seem to be running this using clay and nrepl. Perhaps try using just a plain REPL and see if that works first.
I don't have access to the old system, unfortunately. I installed Ubuntu 24.04 over the old 22.04 partition. I can reproduce in the REPL or nREPL, clay is just a namespace->html conversion tool. Nothing to indicate the way I'm invoking the code is to blame, its consistent. I have wiped the ~/.m2 cache, same result. But... I might have a clue. Trying to require the namespace directly gives me a linker error! Progress. Thanks for the suggestion.
user=> (require 'uncomplicate.clojurecuda.internal.constants)
Execution error (UnsatisfiedLinkError) at jdk.internal.loader.NativeLibraries/load (NativeLibraries.java:-2).
/home/mperry/.javacpp/cache/cuda-12.6-9.5-1.5.11-linux-x86_64.jar/org/bytedeco/cuda/linux-x86_64/libjnicudart.so: libcuda.so.1: cannot open shared object file: No such file or directory
I'm a little confused why it's trying to link to a system library. But at least it gives me a new path to investigate :-)This error seems to indicate that either libcuda.so is not there at all, or it is not installed in the expected location.
Take a look at the output of env . Does that show any env variables whose names contain LIB or PATH or both?
If so, those env vars might be overriding the default locations where the linker looks for shared libs.
I've got my modified PATH but no lib-related (ie no LD_LIBRARY_PATH)
libcuda definitely exists - I have several other apps compiled against it and linking works without a problem.
ldd reports that the jarred .so file can find it. Just not via the java runtime
$ ldd /home/mperry/.javacpp/cache/cuda-12.6-9.5-1.5.11-linux-x86_64.jar/org/bytedeco/cuda/linux-x86_64/libjnicudart.so
...
libcuda.so.1 => /lib/x86_64-linux-gnu/libcuda.so.1 (0x000071171f600000)
I'm a bit ignorant about how the JVM works with native linking.Assuming that libcuda.so.1 is at /lib/x86_64-linux-gnu/libcuda.so.1, try the following arg to the java command "-Djava.library.path=/lib/x86_64-linux-gnu". I guess you could add that to :jvm-opts under the :dev alias and see if that helps.
Or, perhaps better, see what the java.library.path currently is and then append /lib/x86_64-linux-gnu to it.
I'm having trouble explaining this:
user=> (System/getProperty "java.library.path")
"/lib/x86_64-linux-gnu"
user=> (require '[ :as io])
nil
user=> (.exists (io/file "/lib/x86_64-linux-gnu/libcuda.so.1"))
true
user=> (require 'uncomplicate.clojurecuda.internal.constants)
Execution error (UnsatisfiedLinkError) at jdk.internal.loader.NativeLibraries/load (NativeLibraries.java:-2).
/home/mperry/.javacpp/cache/cuda-12.6-9.5-1.5.11-linux-x86_64.jar/org/bytedeco/cuda/linux-x86_64/libjnicudart.so: libcuda.so.1: cannot open shared object file: No such file or directory
I must be missing something 😕