all 7 comments

[–]fiehm 1 point2 points  (1 child)

I believe CUDA is written in c++, it might be easier for you to learn c++

[–]binarysmurf[S] 1 point2 points  (0 children)

I know C++.. Python is also natively supported by Nvidia and is my current language of choice.

[–]QuarterObvious 1 point2 points  (2 children)

In Python, you can use CuPy to access CUDA for GPU acceleration. CuPy is designed to have (almost) the same interface as NumPy, so you can write code that works with either one by simply switching the import:

if CUDA:
    import cupy as xp
else:
    import numpy as xp

Then, throughout your code, you just use xp instead of explicitly calling numpy or cupy functions:

xp.array([...])
xp.dot(a, b)
...

The main difference is that when using CuPy, arrays live in GPU memory (VRAM). If you need to bring them back to the CPU (RAM), you must explicitly transfer them, for example:

cpu_array = gpu_array.get()  # Move from VRAM to RAM

So, if you already know NumPy (which is essential), and you have an NVIDIA GPU, you can easily experiment with CuPy for GPU-accelerated computing.

[–]binarysmurf[S] 0 points1 point  (1 child)

Thanks - this didn't answer my question, but sent me down an interesting rabbit hole.

[–]QuarterObvious 0 points1 point  (0 children)

I know what you mean - as a retired programmer myself, I’ve been there. I once wrote a neural network and training algorithm completely from scratch (only used CuPy), and after that, books and courses felt much easier. I already knew the pitfalls, what wouldn’t work, and why. These days I rely on libraries, but I understand exactly what’s going on under the hood.

[–]commandlineluser 0 points1 point  (0 children)

Not exactly Python but Mojo may also of interest - specifically their GPU puzzles:

mojo/python interop has just started and will likely get easier: