Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Perl GPGPU Modules

by kcott (Bishop)
on Jun 30, 2021 at 07:24 UTC ( #11134476=perlquestion: print w/replies, xml ) Need Help??

kcott has asked for the wisdom of the Perl Monks concerning the following question:

G'day All,

I've been hunting around for (production-grade) modules providing GPGPU bindings or interface.

I've tried searching CPAN and "Super Search" (here). So far, I've come up with the following.

This installed via cpan without any problems (admittedly, a tad surprisingly given all of the FAIL and UNKNOWN results on CPAN Testers Matrix: OpenCL 1.01). The description starts with "This is an early release which might be useful, but hasn't seen much testing." and the module appears to be abandonware (last update 2012). Probably not the production-grade I'm looking for.
This provides a front-end to NVIDIA's CUDA. I'm currently in the process of installing this: there's a few dependencies, so that may take a while. There was a patch for Bug #83396 provided in 2013; the module's author responded (so was aware of this) but apparently did nothing about it. This also appears to be abandonware (last update 2011).

Does anyone know about any other GPGPU modules?

— Ken

Replies are listed 'Best First'.
Re: Perl GPGPU Modules
by eyepopslikeamosquito (Bishop) on Jun 30, 2021 at 10:28 UTC

      G'day eyepopslikeamosquito,

      Although I've never installed or used it, I was aware of PDL's existence, and vaguely knew it could be used for matrix arithmetic, among other things; I didn't know about the machine learning aspect. It's a prerequisite for AI::MXNet (see my last post) so I've just installed it, probably only minutes before you posted.

      OpenGL is an optional prerequisite for PDL; which I just failed to install. It looks like I need to install some libraries for that, so that's on my ever growing TODO list.

      Thanks for the links to the other articles. A bit dated but still informative: I'll definitely have to look more closely at OpenGL. The last line of the last article made me laugh; I wondered if, 14 years later, poor old brian is still waiting. :-)

      — Ken

        > I wondered if, 14 years later, poor old brian is still waiting. :-)
        Yes, I too have enormous respect for brian d foy, a bona fide Perl pioneer hero, a fantastic and consistent contributor to Perl for over twenty years, using Perl since Physics grad school, and founding Perl Mongers in New York way back in 1998. Unlike most of Perl's early pioneers from the 1990s, brian is still going strong today. A true believer.

        BTW, though I know what the "L" stands for in Randal L Schwartz, I don't know what the "d" stands for in brian d foy, nor why the name is always rendered in lower case.

Re: Perl GPGPU Modules
by bliako (Monsignor) on Jun 30, 2021 at 08:11 UTC

    I don't know your use-case but a roundabout way of utilising GPUs via Perl can be with AI::MXNet

    The other way would be to try and Inline::C a Cuda-C program. I am curious if their hello world would work. Warning: my last attempt to inline calls to external libraries with specific header-file naming conventions, failed because of naming clashes, see Inline::CPP + OpenCV = problems

    bw, bliako

      G'day bliako,

      I did come across AI::MXNet earlier during my searching; via a fairly circuitous route, if I recall, after following a series of links. I think I took the AI:: and the abstract ("Perl interface to MXNet machine learning library") to indicate this was not what I wanted.

      I now see, several screenfuls down, "The MXNet Perl package brings flexible and efficient GPU computing and state-of-art deep learning to Perl." (my emphasis). If only the abstract had been a bit more informative. I'm currently in the processing of installing the module.

      The ExtUtils::nvcc module also has an Inline::C example. A dependency of a dependency needs a reboot to complete installation; that's not convenient right now but I'll get to it in a day or two. When that's done, I can try your suggested CUDA example; CUDA is in that dependency chain currently stuck in a traffic jam. :-)

      — Ken

Re: Perl GPGPU Modules
by bliako (Monsignor) on Jul 02, 2021 at 08:52 UTC

      ++ Thanks for that — it's quite an impressive post.

      Yesterday evening, I managed to sort out the "dependency chain currently stuck in a traffic jam". Amongst other things, I now have nvcc installed. So that's a good start.

      This has been a very busy week with some ~16hr days. I have real world tasks piling up which require my attention. I should be able to get back to the Cuda code, and your very interesting post, early next week.

      — Ken

Re: Perl GPGPU Modules
by perlfan (Vicar) on Jun 30, 2021 at 15:42 UTC
    Perl suffers from an extreme lack of access to HPC and other exotic offloading because people just expect production grade support to exist. R U SRSLY? If you can't find what you're looking for via PDL or SPVM. Even Alien::OpenMP can be used nicely in conjunction with Inline::C to leverage GCC/libgomp some accelerator offloading for simple cases. rperl may even be an option for you, though I am unfamiliar. Ultimately, we are in great need of people who are simultaneously specialists in these areas and are willing to contribute the fruits of their own labor. Perl is not like Python or R, backed by gov't monies and corporate monopolies - everything we have is overwhelmingly provided for free by individuals just wanting to share and help one another - which is how it should be.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11134476]
Approved by Athanasius
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2022-01-22 11:16 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (62 votes). Check out past polls.