Getting started with PyOpenCL

I recently discovered the power of a GP-GPU (Generic GPU) and want to use it to perform β€œheavy” scientific and mathematical calculations (which otherwise require large clusters of CPUs) on the same machine.

I know that there are several interfaces on the GPU, the most notable of which are CUDA and OpenCL. The latter has an advantage against CUDA for working on most video cards (NVIDIA, AMD, Intel), and not just with NVIDA cards. In my case, I have a regular Intel 4000 GPU that seems to work well with OpenCL.

Now I need to learn how to work with PyOpenCL to get it further! So the question is:

How can I get started with PyOpenCL? What are the prerequisites? Do I really need to be experienced in Python and / or OpenCL?

My background is in fortran, and in fact I need to translate and parallelize the long fortran code in python (or pyopencl), which mainly deals with PDE solutions and diagonalizing matrices.

I read two relevant websites http://enja.org/2011/02/22/adventures-in-pyopencl-part-1-getting-started-with-python/ and http://documen.tician.de/ pyopencl / , but they are not really useful for beginners (i.e. mannequins).

I just don't know where to start. I do not aspire to become an expert in this field, just to find out how you can parallelize simple math and linear algebra in pyopencl.

Any advice and help is appreciated!

+8
python opencl gpgpu pyopencl
source share
4 answers

You seem to be looking for the fastest and most effective way to learn PyOpenCL. You don't need to know OpenCL (the hard part) at first, but it will be useful to learn Python at startup.

For a quick look at Python syntax, I recommend the Codecademy Python track: http://www.codecademy.com/tracks/python

Then the Udacity parallel programming course is a great place to start GPGPU (although the course is taught in CUDA). https://www.udacity.com/course/cs344 This course will teach you the fundamental concepts of GPGPU very quickly. You do not need an NVIDIA GPU to participate, because all course evaluations are conducted online.

After (or during) the Udacity course, I recommend that you read, run, and configure PyOpenCL code examples: https://github.com/inducer/pyopencl/tree/master/examples

+8
source share

Regardless of the adoption language for GPGPU computing, such as Java, C / C ++, Python, I would recommend that you first start with the basics of GPGPU computing and OpenCL.

You can use the following resources, all of which are oriented to C / C ++, but you should give enough knowledge about the hardware of OpenCL, GPGPU to get started.

PyOpenCL specific

Both books contain an implementation of OpenCL 1.1, but it should be a good starting point for you.

+5
source share

As someone new to GPU programming, I found the related articles that you mentioned are fairly simple, although I found that the sample code works fine from the command line, but not in Eclipse with Anaconda. I think this may be due to the fact that the pyopencl Eclipse from anaconda is different from the command line version, and I still have to decide how to solve this problem.

To learn python, there are a large number of resources on the Internet, including free e-books.

https://wiki.python.org/moin/BeginnersGuide http://codecondo.com/10-ways-to-learn-python/

should be a good starter. If you are using Eclipse, you must install pydev. In any case, install Anaconda https://docs.continuum.io/anaconda/install , as this will save you a lot of trouble.

I take a week or so to reach the level of proficiency that you need in Python if you picj some simple mini-projects. You may also find that with numpy and scipy, and possibly ipython, you may not need to program the GPU

These links can help you avoid GPU programming, or at least delay it. Keep in mind that the cost of switching between cores means that you must assign a significant amount of work to each core.

http://blog.dominodatalab.com/simple-parallelization/ https://pythonhosted.org/joblib/parallel.html

As a rule, I find it more effective, if less fun, to learn only one thing.

Hope this helps.

+1
source share

All Articles