Hello,
I came across a problem and hope that you can help me,
I was trying to run some examples to visualize OpenCL
calculations with OpenGL with shared buffers using
Python 3.3
PyOpenGL 3.1.0
PyOpenGL-accelarate 3.1.0
pyopencl 2014.1
The examples are similar to that one:
https://gitorious.org/openclgltest/openclgltest
Trying to run this throws the error:
Traceback (most recent call last):
File ".\testpyopengl.py", line 234, in <module>
mytest = test()
File ".\testpyopengl.py", line 91, in __init__
self.loadclData()
File ".\testpyopengl.py", line 205, in loadclData
self.arr_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE,
int(self.arrvbo.buffers[0]))
File "vbo.pyx", line 177, in OpenGL_accelerate.vbo.VBO.__getattr__
(D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\vbo.c:2757)
AttributeError: 'numpy.ndarray' object has no attribute 'buffers'
Here are two things I found that might be related to the issue:
1.) PyOpenGL 3.1.0b3; Py_buffer on Python3 unsupported
https://sourceforge.net/p/pyopengl/mailman/message/32385909/
2.) This post that mentions that Python 3 might be the problem. Is that
the case?
http://stackoverflow.com/questions/21821045/numpy-getbuffer-causes-attribut…
Are they related to the issue?
Well, I found that another example
https://github.com/enjalot/adventures_in_opencl/blob/master/python/part2/pa…
was trying to fix this like
<python>
try:
self.pos_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE,
int(self.pos_vbo.buffer))
self.col_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE,
int(self.col_vbo.buffer))
except AttributeError:
self.pos_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE,
int(self.pos_vbo.buffers[0]))
self.col_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE,
int(self.col_vbo.buffers[0]))
</python>
But changing the example above like this results in
Traceback (most recent call last):
File ".\python-3.3.3.amd64\lib\site-packages\OpenGL\GLUT\special.py",
line 130, in safeCall
return function( *args, **named )
File ".\testpyopengl.py", line 182, in draw
gl.glVertexPointer(4, gl.GL_FLOAT, 0, self.arrvbo)
File "latebind.pyx", line 32, in
OpenGL_accelerate.latebind.LateBind.__call__
(D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\latebind.c:992)
File "wrapper.pyx", line 314, in
OpenGL_accelerate.wrapper.Wrapper.__call__
(D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\wrapper.c:6508)
File "wrapper.pyx", line 311, in
OpenGL_accelerate.wrapper.Wrapper.__call__
(D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\wrapper.c:6442)
File
".\python-3.3.3.amd64\lib\site-packages\OpenGL\platform\baseplatform.py", line
402, in __call__
return self( *args, **named )
ctypes.ArgumentError: ("argument 4: <class 'TypeError'>: wrong type",
(4, GL_FLOAT, 0, <OpenGL_accelerate.vbo.VBO object at 0x0000000004752A60>))
GLUT Display callback <bound method test.draw of <__main__.test object
at 0x0000000003A959B0>> with (),{} failed: returning None ("argument 4:
<class 'TypeError'>: wrong type", (4, GL_FLOAT, 0,
<OpenGL_accelerate.vbo.VBO object at 0x0000000004752A60>))
Well, that for now. I hope you have some ideas on how to fix this.
Kind regards,
Joe
Got it. Thanks all.
On Sep 11, 2014 8:48 AM, "CRV§ADER//KY" <crusaderky(a)gmail.com> wrote:
> Segfault smells like having more workers than elements to me.
> You must either pass the length of those two vectors and check i that gid
> doesn't exceed it, or have the length be always exactly divisible by the
> work group size. (the former is much more robust)
> On 11 Sep 2014 16:38, "Gus Peterson" <peterson.gus(a)gmail.com> wrote:
>
>> Oh boy,
>> Yes. My mistake. Now I'm getting a seg fault.
>>
>> Thanks for catching this. Too little sleep.
>>
>> -Gus
>>
>> On Thu, Sep 11, 2014 at 7:21 AM, Bogdan Opanchuk <mantihor(a)gmail.com>
>> wrote:
>>
>>> Hi Gus,
>>>
>>> Did you mean to write "target[gid] = tanh(matrix[gid]);"?
>>>
>>> On Fri, Sep 12, 2014 at 12:15 AM, Gus Peterson <peterson.gus(a)gmail.com>
>>> wrote:
>>>
>>>> Hi all -
>>>>
>>>> I'm building a small set of OpenCL executable math functions with some
>>>> friends. I'm having a hard time getting the "tanh" function to come out.
>>>> When I compile the following code:
>>>>
>>>> *# OpenCL (C99) kernel code, compiled*
>>>> *prg = cl.Program(ctx, """*
>>>> *__kernel void ApplyTanh(__global const float *matrix, __global float
>>>> *target) {*
>>>> * int gid = get_global_id(0);*
>>>> * target[gid] = tanh(matrix);*
>>>> *}*
>>>> *""").build()*
>>>>
>>>> I get this error:
>>>>
>>>> *"/tmp/OCL7750T1.cl", line 4: error: no instance of overloaded function
>>>> "tanh"*
>>>> * matches the argument list*
>>>> * argument types are: (const __global float *)*
>>>> * target[gid] = tanh(matrix);*
>>>>
>>>> What on earth can I do to get the OpenCL kernel code to execute a
>>>> hyperbolic tangent?
>>>>
>>>> Thanks,
>>>> Gus
>>>>
>>>> _______________________________________________
>>>> PyOpenCL mailing list
>>>> PyOpenCL(a)tiker.net
>>>> http://lists.tiker.net/listinfo/pyopencl
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> PyOpenCL mailing list
>> PyOpenCL(a)tiker.net
>> http://lists.tiker.net/listinfo/pyopencl
>>
>>
Segfault smells like having more workers than elements to me.
You must either pass the length of those two vectors and check i that gid
doesn't exceed it, or have the length be always exactly divisible by the
work group size. (the former is much more robust)
On 11 Sep 2014 16:38, "Gus Peterson" <peterson.gus(a)gmail.com> wrote:
> Oh boy,
> Yes. My mistake. Now I'm getting a seg fault.
>
> Thanks for catching this. Too little sleep.
>
> -Gus
>
> On Thu, Sep 11, 2014 at 7:21 AM, Bogdan Opanchuk <mantihor(a)gmail.com>
> wrote:
>
>> Hi Gus,
>>
>> Did you mean to write "target[gid] = tanh(matrix[gid]);"?
>>
>> On Fri, Sep 12, 2014 at 12:15 AM, Gus Peterson <peterson.gus(a)gmail.com>
>> wrote:
>>
>>> Hi all -
>>>
>>> I'm building a small set of OpenCL executable math functions with some
>>> friends. I'm having a hard time getting the "tanh" function to come out.
>>> When I compile the following code:
>>>
>>> *# OpenCL (C99) kernel code, compiled*
>>> *prg = cl.Program(ctx, """*
>>> *__kernel void ApplyTanh(__global const float *matrix, __global float
>>> *target) {*
>>> * int gid = get_global_id(0);*
>>> * target[gid] = tanh(matrix);*
>>> *}*
>>> *""").build()*
>>>
>>> I get this error:
>>>
>>> *"/tmp/OCL7750T1.cl", line 4: error: no instance of overloaded function
>>> "tanh"*
>>> * matches the argument list*
>>> * argument types are: (const __global float *)*
>>> * target[gid] = tanh(matrix);*
>>>
>>> What on earth can I do to get the OpenCL kernel code to execute a
>>> hyperbolic tangent?
>>>
>>> Thanks,
>>> Gus
>>>
>>> _______________________________________________
>>> PyOpenCL mailing list
>>> PyOpenCL(a)tiker.net
>>> http://lists.tiker.net/listinfo/pyopencl
>>>
>>>
>>
>
> _______________________________________________
> PyOpenCL mailing list
> PyOpenCL(a)tiker.net
> http://lists.tiker.net/listinfo/pyopencl
>
>
Oh boy,
Yes. My mistake. Now I'm getting a seg fault.
Thanks for catching this. Too little sleep.
-Gus
On Thu, Sep 11, 2014 at 7:21 AM, Bogdan Opanchuk <mantihor(a)gmail.com> wrote:
> Hi Gus,
>
> Did you mean to write "target[gid] = tanh(matrix[gid]);"?
>
> On Fri, Sep 12, 2014 at 12:15 AM, Gus Peterson <peterson.gus(a)gmail.com>
> wrote:
>
>> Hi all -
>>
>> I'm building a small set of OpenCL executable math functions with some
>> friends. I'm having a hard time getting the "tanh" function to come out.
>> When I compile the following code:
>>
>> *# OpenCL (C99) kernel code, compiled*
>> *prg = cl.Program(ctx, """*
>> *__kernel void ApplyTanh(__global const float *matrix, __global float
>> *target) {*
>> * int gid = get_global_id(0);*
>> * target[gid] = tanh(matrix);*
>> *}*
>> *""").build()*
>>
>> I get this error:
>>
>> *"/tmp/OCL7750T1.cl", line 4: error: no instance of overloaded function
>> "tanh"*
>> * matches the argument list*
>> * argument types are: (const __global float *)*
>> * target[gid] = tanh(matrix);*
>>
>> What on earth can I do to get the OpenCL kernel code to execute a
>> hyperbolic tangent?
>>
>> Thanks,
>> Gus
>>
>> _______________________________________________
>> PyOpenCL mailing list
>> PyOpenCL(a)tiker.net
>> http://lists.tiker.net/listinfo/pyopencl
>>
>>
>
Hi Gus,
Did you mean to write "target[gid] = tanh(matrix[gid]);"?
On Fri, Sep 12, 2014 at 12:15 AM, Gus Peterson <peterson.gus(a)gmail.com>
wrote:
> Hi all -
>
> I'm building a small set of OpenCL executable math functions with some
> friends. I'm having a hard time getting the "tanh" function to come out.
> When I compile the following code:
>
> *# OpenCL (C99) kernel code, compiled*
> *prg = cl.Program(ctx, """*
> *__kernel void ApplyTanh(__global const float *matrix, __global float
> *target) {*
> * int gid = get_global_id(0);*
> * target[gid] = tanh(matrix);*
> *}*
> *""").build()*
>
> I get this error:
>
> *"/tmp/OCL7750T1.cl", line 4: error: no instance of overloaded function
> "tanh"*
> * matches the argument list*
> * argument types are: (const __global float *)*
> * target[gid] = tanh(matrix);*
>
> What on earth can I do to get the OpenCL kernel code to execute a
> hyperbolic tangent?
>
> Thanks,
> Gus
>
> _______________________________________________
> PyOpenCL mailing list
> PyOpenCL(a)tiker.net
> http://lists.tiker.net/listinfo/pyopencl
>
>
Hi all -
I'm building a small set of OpenCL executable math functions with some
friends. I'm having a hard time getting the "tanh" function to come out.
When I compile the following code:
*# OpenCL (C99) kernel code, compiled*
*prg = cl.Program(ctx, """*
*__kernel void ApplyTanh(__global const float *matrix, __global float
*target) {*
* int gid = get_global_id(0);*
* target[gid] = tanh(matrix);*
*}*
*""").build()*
I get this error:
*"/tmp/OCL7750T1.cl", line 4: error: no instance of overloaded function
"tanh"*
* matches the argument list*
* argument types are: (const __global float *)*
* target[gid] = tanh(matrix);*
What on earth can I do to get the OpenCL kernel code to execute a
hyperbolic tangent?
Thanks,
Gus
Thanks guys! I'll try to integrate this info into our project forthwith.
Gus
On Sep 2, 2014 8:56 AM, "Toby St Clere Smithe" <pyviennacl(a)tsmithe.net>
wrote:
> Hey all,
>
> Andreas Kloeckner <lists(a)informa.tiker.net> writes:
> > Relatedly, there's Toby StClere Smithe's PyViennaCL [1] which provides a
> > Python binding for ViennaCL. Toby--what's the status of the PyOpenCL
> > integration? I know I still owe you the .get() patch...
>
> Yeah, PyOpenCL integration is pretty complete right now, at least in git
> master. There should be a stable release with all the new functionality
> in the next month or two. You can create PyViennaCL objects from
> PyOpenCL Buffer or Array objects, and you can get PyOpenCL Buffer or
> Array objects from PyViennaCL objects; all without incurring copy
> operations. There is still a bit of missing functionality for sparse
> matrices, but for dense matrices it's all there. It's also pretty easy
> to execute custom kernels on PyViennaCL objects, and even to integrate
> your custom kernels into the PyViennaCL expression graph.
>
> There are a couple of simple examples demonstrating this latter
> functionality[1][2], but the documentation is somewhat sparse right now
> (I'm working on it!). If you're interested and stuck, do get in
> touch.
>
> Briefly, if you want the PyOpenCL Buffer for a given PyViennaCL Matrix
> ``mat``, you need to look at ``mat.handle[0]`` (there is only one
> element in Matrix.handle, because there is only one underlying
> buffer). Also: if you have a PyOpenCL Array object, you can pass that to
> the Matrix class constructor to get a PyViennaCL Matrix; look at the
> documentation for Matrix for this (in git master). The constructor from
> a PyOpenCL Buffer is just slightly more complicated.
>
> As for PyViennaCL performance, it's pretty good, and can get close to
> peak performance for the hardware[3]. The one caveat is that, in order
> to get peak performance, your hardware has to have been 'auto-tuned'; if
> it has not already been tuned, there is code you can run to determine
> the most performant parameters for the various algorithms.
>
> [1]
> https://github.com/viennacl/pyviennacl-dev/blob/platform-support/examples/s…
> [2]
> https://github.com/viennacl/pyviennacl-dev/blob/custom-kernels/examples/sim…
> [3] http://viennacl.sourceforge.net/pyviennacl/benchmarks/
>
> Cheers,
>
> Toby
>
>
>
> > [1] https://github.com/viennacl/pyviennacl-dev
> >
> > HTH,
> > Andreas
> >
>
> --
> Toby St Clere Smithe
> http://tsmithe.net
>
Hi Gus,
Gus Peterson <peterson.gus(a)gmail.com> writes:
> When I run configure.py during PyOpenCL setup, the only libs to direct to
> are boost and OpenCL. Is it possible to Install CLMath (from AMD) and use
> that instead of uBLAS/BOOST?
>
> I realize that BOOST is no longer required since V0.92, yet the config
> paths are only labelled for BOOST.
>
> I would like PyOpenCL to make calls through a BLAS that is fast and yet
> friendly with openCL. AMD has the CLMath library posted on their site
> alongside the APP (OpenCL) SDK. Perhaps I'm obtuse, but shouldn't we be
> able to use this?
>
> Just this question for now. Wow, It was hard to find you guys.
PyOpenCL doesn't use boost for uBLAS (in fact, it doesn't use uBLAS at
all), it uses it for boost.python. (There's also an alpha-quality port
using cffi in the cffi branch that doesn't use boost at all.)
There has variously been interest in producing a wrapper for the AMD's
math libraries, but I'm not sure if any of those have gone anywhere.
Relatedly, there's Toby StClere Smithe's PyViennaCL [1] which provides a
Python binding for ViennaCL. Toby--what's the status of the PyOpenCL
integration? I know I still owe you the .get() patch...
[1] https://github.com/viennacl/pyviennacl-dev
HTH,
Andreas
When I run configure.py during PyOpenCL setup, the only libs to direct to
are boost and OpenCL. Is it possible to Install CLMath (from AMD) and use
that instead of uBLAS/BOOST?
I realize that BOOST is no longer required since V0.92, yet the config
paths are only labelled for BOOST.
I would like PyOpenCL to make calls through a BLAS that is fast and yet
friendly with openCL. AMD has the CLMath library posted on their site
alongside the APP (OpenCL) SDK. Perhaps I'm obtuse, but shouldn't we be
able to use this?
Just this question for now. Wow, It was hard to find you guys.
Thanks, Gus