Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

processing an image using CUDA implementation, python (pycuda) or C++?

I am in a project to process an image using CUDA. The project is simply an addition or subtraction of the image.

May I ask your professional opinion, which is best and what would be the advantages and disadvantages of those two?

I appreciate everyone's opinions and/or suggestions since this project is very important to me.

like image 588
ardiyu07 Avatar asked Dec 22 '22 18:12

ardiyu07


2 Answers

General answer: It doesn't matter. Use the language you're more comfortable with.

Keep in mind, however, that pycuda is only a wrapper around the CUDA C interface, so it may not always be up-to-date, also it adds another potential source of bugs, …

Python is great at rapid prototyping, so I'd personally go for Python. You can always switch to C++ later if you need to.

like image 158
Alexander Gessler Avatar answered Jan 25 '23 23:01

Alexander Gessler


If the rest of your pipeline is in Python, and you're using Numpy already to speed things up, pyCUDA is a good complement to accelerate expensive operations. However, depending on the size of your images and your program flow, you might not get too much of a speedup using pyCUDA. There is latency involved in passing the data back and forth across the PCI bus that is only made up for with large data sizes.

In your case (addition and subtraction), there are built-in operations in pyCUDA that you can use to your advantage. However, in my experience, using pyCUDA for something non-trivial requires knowing a lot about how CUDA works in the first place. For someone starting from no CUDA knowledge, pyCUDA might be a steep learning curve.

like image 40
tkerwin Avatar answered Jan 26 '23 00:01

tkerwin