A lot of non subject matter experts are replying, and while I typically don't use numba for my python projects using cuda, I know a lot about GPUs, CUDA, and python, there are a few things that stand out to me and definitely show that your question is worth downvoting.
I took a program that makes a mandelbrot plot and made it run on a CPU thread using njit.
Okay, so you want to display the mandelbrot set? Cool makes sense. And you used numbas' njit utility to perform jit compilation. Cool
Now I want to generate a 32k image
Here is where I'm like, okay, now this is starting to get annoying. What do you mean by 32k image? You could mean 32k phyiscal pixels, 32k x 32k, or any number of other things. Your code you show does not help either. My first guess was a 32k x 32k image, but your code actually doesn't signal that at all, WIDTH = 15360 HEIGHT = 8640
implies that actually you made a mistake and you meant 16k, and you meant it in terms of display vendor marketing 2k,4k,8k nomenclature. That's a lot of garbage you've made me parse, and it isn't because of a MVCE or what ever, it's because of negligence. and I'm probably still wrong about my conclusion, I've had to try to mind read afterall. What's more, it likely has nothing to do with your issue, and that's something you should have been able to figure out before hand. Your error clearly says nothing about a "memory" overflow or what ever. Your mandebrot set could have been 2 times as large or a 100th of the size and it wouldn't matter to your question.
but even a whole thread is too slow.
What do you mean by a whole thread? A single thread? One thread? Okay, so why did you jump straight into CUDA then? The first use case I find on google for njit
, something I've literally never used before was automatic CPU parrallelization. Fine that's irrelevant to your specific problem, but this kind of error, which apparently was strange enough that multiple revisions of your post by other people left it unchanged, added more mental overload, and we haven't even gone through two sentences of your post yet.
So I tried to make the code run on a GPU. Here is the code:
At first this code looks fine, especially to someone who is not familiar with python or the concept of "vectorization". But you clearly don't understand what vectorize
does, and much of the basic information in numba. Again, I'm not an expert in numba, I've never used numba extensively, I didn't even know what vectorize did before today. Vectorize doesn't make sense when you aren't, you know, vectorizing. Vectorizing needs a vector of inputs. You straight up don't do this. You clearly didn't follow any tutorials or documentation before attempting this.
You also provide an error that clearly has nothing to do with your proposed "solution" and comes from some sort of configuration error completely irrelevant to the specific problem you're working on.
You also talk about performance problems, your question is full of smaller questions an quirks too broad for SO, even if you don't ask about them directly.
Then you answer your own question, and even that answer is completely wrong in terms of performance and will probably confuse new users rather than help them. The only thing you got right was realizing the ignored the basic instructions for installing numba https://numba.pydata.org/numba-doc/latest/user/installing.html ie you didn't even install the cudatoolkit...