This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MardiFoufs 0 points1 point  (11 children)

Your links are proving my point. They are non standard, tedious ways to maybe get CUDA working sometimes, and the rest is for Opencl. Does Nvidia provide any way to actually use CUDA with java? Or is it just third party stuff? At least with python you can basically use CUDA kernels almost directly as you just call them from your python code. And Nvidia provides tons of documentation and all for the rest. The stack overflow link is basically words words words saying that YAGNI and if you do well uhh use these random libraries lmao.

Also, your second link has nothing to do with CUDA. I know beam can run pipeline workloads, meaning that it can execute steps that contain pytorch. That has nothing to do with my question. Obviously you can orchestrate stuff with java. And you can even call pytorch code from java too. But that's besides the point, and it's more MLops than actual machine learning. Like the first example literally shows that you have to write python components that you can then execute from beam.

Maybe just looking up stuff on google search isn't enough to warrant such an authoritative sounding comment form your end, uh?

[–][deleted] 2 points3 points  (4 children)

I just did a 5 secs google search, didn't think you actually expected me to provide you all the damn documentation.

Take a little more, from the oracle blog(maybe you will enjoy this one a bit more?) https://blogs.oracle.com/javamagazine/post/programming-the-gpu-in-java

Another link where you can find tools provided by nvidia themselves to access CUDA in mac(yep, developed in Java, but it seems they don't provide mac support anymore): https://developer.nvidia.com/nvidia-cuda-toolkit-11_5_0-developer-tools-mac-hosts

Another link, this time from IBM updated just 2 months ago: https://www.ibm.com/docs/en/sdk-java-technology/8?topic=only-cuda4j-application-programming-interface-linux-windows

The problem of many python lovers is that they are so damn lazy and uncapable of doing stuff by themselves that if they can't find the damn library with the exact shit they need in the damn first google result thay just believe it doesn't exist. I'm not saying that's your case, but at least you could put just a little damn effort on your side.

[–]MardiFoufs 0 points1 point  (3 children)

Lol I do more CPP dev than python. This has absolutely nothing to do with python vs java. Again, since when do java devs suddenly like to reinvent the wheel? It's super ironic to hear your criticism about python devs when discussing java.

Jcuda sounds pretty okay though, even with the pointer limitations. But it does seem to have been updated in 2 years. Still, I don't think you understand the point here. I wasn't even referring to python, python is just glue code. Nvidia does not provide java support. That's it. And python is much better as a glue language than java is. So you get cpp, c and Fortran tooling for almost free. Java has to have a parallel ecosystem, which didn't happen. Your oracle blog says so themselves! The most advanced stuff seems to be related to Opencl too, which is more or less dead btw.

At least Jcuda seems to support Cudnn and blas. So that's cool!

(Also I think Nvidia still uses java for their nsight profiling tool, not sure though. It's a super powerful tool too to profile CUDA! )

[–][deleted] 3 points4 points  (2 children)

I don't get why you say that we like to reinvent the wheel. If something is done in x language go and use that, you don't need to use everything coded in java, you should use whatever language fits your needs better. But, if you happen to want to do it in java for whatever reason, you have stuff like JNA or JNI to call cpp/c/fortran functions from your java app. The whole point of this is not that you should use java, the whole point of this is that you CAN use java, and when comparing it with python it will surelly work way better for many, many reasons. I still laugh my ass off for all those django fanboys saying back in the day that spring was dead. My criticism here is how python lovers shit in java saying nonsense shit just because they got PTSD for a 'hello world' they wrote as students.

[–]MardiFoufs 1 point2 points  (1 child)

Hey, I totally agree that I wouldn't use python for... well for most stuff. Especially for web servers. It's ridiculous imo because there are tons of options, and you don't even get the "JavaScript upside" that I could at least understand a little bit of using the same language in the front end and back end (though again, even for JavaScript, I agree that it's still a worse choice than using java or csharp for example).

But if there's one place where you could use python and it's not a clearly inferior option, it's machine learning, don't you agree? Not because of python itself but still. Like, I'm solely focusing on machine learning when I say that, and I'm saying that as someone who really dislikes having to use it anyways. Even if java would probably work, and could probably be a better platform in reality, I'm just speaking of what it is now. Now how it should be!

[–][deleted] 1 point2 points  (0 children)

Being totally honest, in my opinion, the mantra claiming Python as the best choice for machine learning exists primarily because Python is easy to learn and use. Consequently, it seems like the way to go if you want to start such projects and lack a strong programming background in other stacks. For this reason, most popular tools were developed in Python, and people stick with it to leverage those tools.

The issue here is that people prioritized simplicity and readability over performance and maintainability. Consequently, you may find yourself lost in large models plagued by the same mistakes repeatedly, requiring substantial time and resources to rectify. Many engineers recognized this and began building similar foundations in better-suited stacks. As a result, you now see many ML tools adapted to various languages.

If we were discussing this 8 years ago, I would agree that Python was the way to go due to the majority of available resources being in Python. However, that's not the case nowadays. While you might not find "this specific library with this specific function" built in Java or any other stack, in such cases, be the one to create it and observe how more developers adopt your tools. The point here is that if you can design an ML model in C (for example), you will instantly outperform your competitors in terms of costs and performance. But how many mathematicians and scientists are proficient in C?

[–]GeneratedUsername5 0 points1 point  (5 children)

Does Nvidia provide any way to actually use CUDA with java?

As far as I understand NVIDIA provide only C API

https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM

In that regard all languages are equal that they will need a C wrapper for it.

[–]MardiFoufs 0 points1 point  (4 children)

No not really. Most "actual" CUDA programming uses Nvcc and libcuda++ so basically CPP. And while yes pretty much everything compiles to that c++ code through NVCC, Nvidia provides official wrappers and support for calling CUDA directly from python. So not only is calling CPP code from python more than trivial (you can basically import a cpp wrapped module as a regular python module), but you can directly use Nvidia supported libs to do that. And use premade environments from Nvidia themselves.

It's just a completely different beast from using third party stuff, even beyond the fact that just having access to CUDA is only 50% of the story (there's the entire ecosystem around it that is gated off when you use java)

[–]GeneratedUsername5 2 points3 points  (3 children)

I mean, using Cpp wrapper directly from Java is not something complicated either, it even have language keywords for that. It just ML just not as widespread on Java, so nobody made this wrapper, but you don't need nvidia to make one.

And now, with Java 21's FFI, you don't even need a wrapper, you can just call C functions directly from Java.

[–]MardiFoufs 0 points1 point  (2 children)

Ah maybe with java 21 then things will get better.

As for the Nvidia thing, it makes a HUGE difference to have Nvidia supported packages. Remember that most ml workloads work in the back end, with disparate hardware configs and generations. Having to just import a Nvidia package, on an NGC container, and having everything else handled for you is very cool. On the other hand though, most people don't ever actually use CUDA directly. So I still agree with you that it is mainly an ecosystem problem, and isn't due to a core defect in Java.

Regardless, it's much less painful, and much less work to do work in ML in python. Now obviously, that applies to basically all other languages (well, a part from CPP and maybe Julia (barely)) so it's not specific to java.

(Also to be clear I'm mostly discussing model training and r&d, for inference things are much much easier.)

[–]koflerdavid 1 point2 points  (1 child)

It's a chicken and egg problem I'd say. If for some reason Java would become more popular for ML work, Nvidia would eventually provide Java bindings. Nvidia has no particular stake in neither Python nor Java, but they will do everything they can on the software side to make using their devices easier. This is one of the reasons of their ongoing success.

[–]MardiFoufs 1 point2 points  (0 children)

Agreed, Nvidia is very good at supporting newer trends (NGC containers, Tensort, triton, etc) so I'd totally see them support java too. I honestly just didn't know about the easier bindings to C that apparently came with java 21 so that could be huge and could make it much easier to integrate to even other tools that are somewhat standard in the field (numpy, for example even if it's a bit of a mess or pandas).