Hi,
I'm trying to access GL textures from pyopencl. Here is my test program:
import sys, os, pygame
from OpenGL.GL import *
sys.path.append("extern/pyopencl/build/lib.linux-x86_64-2.6")
import pyopencl
pygame.init()
screen = pygame.display.set_mode((1024, 768), pygame.HWSURFACE |
pygame.OPENGL | pygame.DOUBLEBUF)
if pyopencl.have_gl():
context = pyopencl.create_some_context()
tex = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, tex)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA,
GL_UNSIGNED_BYTE, None)
cltex = pyopencl.GLTexture(context, pyopencl.mem_flags.READ_ONLY,
GL_TEXTURE_2D, 0, tex, 2)
It fails with error:
Traceback (most recent call last):
File "cl.py", line 14, in <module>
cltex = pyopencl.GLTexture(context, pyopencl.mem_flags.READ_ONLY,
GL_TEXTURE_2D, 0, tex, 2)
pyopencl.LogicError: clCreateFromGLTexture2D failed: invalid context
I thought that the problem might be in pyopencl's context creation,
which doesn't take the GL context into account. I tried to fix it by
adding appropriate CL_GL_CONTEXT_KHR, CL_GLX_DISPLAY_KHR and
CL_CONTEXT_PLATFORM props to the context, but then I got another error
"pyopencl.LogicError: clCreateFromGLTexture2D failed: invalid value". I
can run kernels just fine with my setup, but this GL stuff won't work.
What am I doing wrong?
Hi
We have recently acquired an NVIDIA Tesla s2050 device for image processing
at work.
I have used PyOpenCL before on my laptop and know the basics. After
installing PyOpenCL on the host server (hosting the s2050 device)
successfully I get the following result when trying to create a context:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyopencl as cl
>>> cl.create_some_context()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/pyopencl/__init__.py", line
327, in create_some_context
platforms = get_platforms()
pyopencl.LogicError: clGetPlatformIDs failed: invalid/unknown error code
As a sanity check I installed PyCUDA as well on the same machine and again I
get an error:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycuda.autoinit
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/usr/local/lib/python2.6/dist-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/autoinit.py",
line 4, in <module>
cuda.init()
pycuda._driver.RuntimeError: cuInit failed: no device
Does anyone know what else I can try, other than installing the latest
NVIDIA development drivers and the latest CUDA toolkit? (which I have done)
Riaan
I don't know what got done, but I did a git pull:
C:\Users\Keith\Desktop\pyopencl\pyopencl>git pull
>From http://git.tiker.net/trees/pyopencl
c91a092..cffa356 master -> origin/master
Updating c91a092..cffa356
Fast-forward
pyopencl/__init__.py | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
and rebuilt my pyopencl on my ATI HD5870 computer, and it works now!
If it really isn't a pyopencl thing, is it possible that I installed some
windows update that I don't know about that somehow magically helped me?
--Keith Brafford
Hello,
first off I would like to say PyOpenCL rocks! I <3 python and I've already
converted one of my C++ OpenCL tutorials over and its so much cleaner :)
My problem is that I use the Mac a lot, and PyOpenCL doesn't support OpenGL
context sharing, so I decided to add it. I don't think my way of adding it
is the cleanest, because I just added a #ifdef __APPLE__ in create_context
which will go ahead and create from an OpenGL context if no devices are
passed in (instead of using createContextFromType) as demonstrated in this
pdf:
http://sa10.idav.ucdavis.edu/docs/sa10-dg-opencl-gl-interop.pdf
In my limited (and 1.0) experience the two cases on a mac are where you
choose a device (either gpu or cpu) and don't share with GL, or you do this
very specific command for creating from GL context (no other combination of
standard createContext calls seem to work for GL sharing)
I have attached my git diff (only a few lines in wrap_cl.hpp and
gl_interop_demo.py) and the demo works on my mac!
Also as a side note, when building from git doing
git submodule init
git submodule update
did not seem to get all of the dependencies for pyopencl (it was missing
ptr_container) so I manually pulled from bpl-subset.git and replaced the
bpl-subset folder inside pyopencl
--
Ian Johnson
http://enja.org
Dear mailing list recipients,
I'm currently working on my bachelor project where I am to do heavy
calculations that are very suited for parallel computation (quantum field
theory using path integrals and markov chain montecarlo). This will be done
with OpenCL in Python, thus using PyOpenCL. This is a quite problematic
approach though since I'm new to both OpenCL and Python. Why? Because
PyOpenCL is a shortcut that blocks me from directly applying 99% of all the
material/tutorials online, since they follow implementation of OpenCL in a C
environment. For every thing I learn about OpenCL, I have to "translate" it
to PyOpenCL. It is possible with this approach, however it feels like a very
slow progress that takes a lot of effort. Since I can't seem to find any
tutorials on learning OpenCL through PyOpenCL on the web, I wonder if anyone
on the mailing list knows of such tutorials? Learning Python isn't the issue
here, and the approach isn't up for change. The question is HOW I'm going to
learn/do this approach in an efficient way.
Thank you for your time!
Yours sincerely,
Patric
Hey guys,
I want to say I'm glad I joined the mailing list and this is a cool
community :)
I've ported my C/C++ OpenCL tutorials to PyOpenCL, the code is not much
different from the example on the front page of the documentation, but
hopefully my writeup helps those trying to get started:
http://enja.org/2011/02/22/adventures-in-pyopencl-part-1-getting-started-wi…
any corrections/feedback would be appreciated!
I'll be working on porting my Part 2 tutorial involving CL/GL interop and a
simple particle system, but for those interested the code is already
available:
https://github.com/enjalot/adventures_in_opencl/tree/master/python/part2
It does require pygame (I should probably switch to tkinter to remove a
dependency) and numpy at least version 1.4 (altho I may remove the code that
depends on this since it is not that important). I'll do those things before
I write it up.
PyOpenCL takes the a lot of pain and tedium out of OpenCL <3
--
Ian Johnson
http://enja.org
My trouble getting PyOpenCL to work on either of my two PCs had me wondering if
I am the only person to try it on the type of machines that I have. So, has
anyone out there actually gotten PyOpenCL to run the gl_interop example with the
following configuration:
1) ATI OpenCL (cpu or gpu device)
2) Windows 7 64-bit
--Keith Brafford
Hello,
I followed http://wiki.tiker.net/PyOpenCL/Installation/Linux/Ubuntu and
seemed to sucessufully install pyopencl.
Numpy and boost are also installed and I am running Ubuntu 9.10.
However, when writing :
import pyopencl._cl as _cl
I get the following error message :
...ImportError: libOpenCL.so: cannot open shared object file: No such file
or directory
- My LD_LIBRARY_PATH seems to be ok :
/usr/local/lib:/home/froloe/tools/opencl/ati-stream-sdk-v2.2-lnx32/lib/x86:
- ldd _cl.so indicates :
libOpenCL.so =>
/home/froloe/tools/opencl/ati-stream-sdk-v2.2-lnx32/lib/x86/libOpenCL.so
(0xb7772000)
Many thanks in advance for any clue you can give me,
François