Hi Andreas,
I'm noticing that once in a while, the mem_alloc function seems to be
taking a long time (0.46 seconds for me); it doesn't happen in the first
allocation, and seems to occur irrespective of allocation size. Can you tell
me if you notice the same thing in any of your larger projects? Below is
some [maybe excessive for small debugging] code to wrap functions (decorator
@time_fcn(name)) with time.time() (such that the real time is measured
instead of the cpu time; I also found that time.sleep was necessary to get
better measurements).
regards,
Nicholas
stats = { }
running_timers = []
class RealElapsedTimer:
def __init__(self, name):
if not stats.has_key(name):
stats[name] = 0.0
self.name = name
def __repr__(self):
return "RealElapsedTimer[name = '%s', elapsed = %05.2f]" %(
self.name, self.time() - self.start)
def __enter__(self):
self.start = self.time()
running_timers.append(self)
def __exit__(self, type_, value, tb):
elapsed = max(0, self.time() - self.start)
stats[self.name] += elapsed
running_timers.remove(self)
if (elapsed > 0.1):
print("stopping", self)
import traceback
print(*traceback.format_stack(), sep="\n")
@classmethod
def time(cls):
time.sleep(0.0001)
return time.time()
def time_fcn(name = None):
def inner(f):
realname = name or f.__name__
def inner2(*argv, **kwargs):
with RealElapsedTimer(realname):
return f(*argv, **kwargs)
return inner2
return inner
def print_stats():
print("=== stats timers ===")
if running_timers:
print("running timers:", running_timers)
byvalue = [(v, k) for k, v in stats.items()]
byvalue.sort()
for v, k in byvalue:
print(" %20s: %05.2f s" %(k, v))
Hi all,
after 75 downloads of the release candidate (thank you!) and zero problem
reports, I've just now released 0.92. Apart from the version bump, the release
is the same as the candidate. The previous release, 0.91.1, was downloaded
almost 700 times during its lifespan.
The changes in this release can be reviewed at [1]. Please take a look if
you're upgrading.
[1] http://documen.tician.de/pycuda/faq.html#version-0-92
Thanks for being awesome, everybody! Onwards to a successful 0.93 cycle... :)
Andreas
PS: I'm still looking for someone who can verify that the new GL interop code
in current git works. Any help would be much appreciated.
Hi all,
I have two questions about PyCUDA which I have run up against in my
testing to use it for a few applications:
1) Is there any integration between PyOpenGL/PyGame and PyCUDA like
there is between PyCUDA and OpenGL where VBOs can be shared on the
device?
2) Can I poll the GPUs instead of blocking? Right now I have three
python threads which are running three CPUs at 100% to... wait for the
GPUs. Timing isn't too tight and I could easily get away with polling
every second or two (to drop CPU usage), but I haven't figured out a way
to do that yet.
Thanks!
nick
Hi Alexey,
On Montag 16 Februar 2009, JU AV wrote:
> Recently I started using your python bindings for CUDA.
> I would like to know is it possible to save cubin file after
> driver.SourceModule compiles it In my work, I want to create optimized
> computational kernels for one time at first run of my program And then use
> precompiled kernel not to slower execution of my program. I know that
> SourceModule has keep parameter but it is not obvious how to use it in
> precompilation of computational kernels
> I would be grateful if you could help me to solve my problem
Check current git. I've moved SourceModule and its related infrastructure to
pycuda.compiler. Now you can get the cubin that results from compilation by
calling pycuda.compiler.compile with the same arguments as SourceModule. You
can then do with it whatever you want. There's also
pycuda.compiler.compile_plain() that skips a bunch of niceties that compile()
has, such as caching, compute model detection, etc.
Andreas
PS: Don't worry, everybody else. SourceModule in pycuda.driver still exists--
it will print a (silenceable) deprecation warning once per Python interpreter
invocation, though.
Hi Peter,
one request: please keep the list cc'd--maybe somebody there knows something.
On Donnerstag 12 Februar 2009, Peter Berrington wrote:
> Still no dice, there is always an error initializing or making the gl
> context regardless of whatever I make a standard cuda context before, or
> whether I use pycuda.gl.init(), pycuda.gl.make_context(), or importing
> pycuda.gl.autoinit to try and set up a gl context, I always end up with
> these cryptic messages:
>
> pycuda._driver.Error: cuGLInit failed: unknown
>
> or
>
> pycuda._driver.Error: cuGLCtxCreate failed: unknown
Does dmesg say anything?
> Do you have the cuda 2.0 SDK handy by any chance? I'm trying to recreate
> the behaviour of the postProcessGL program which is included, but I noticed
> they do not explicitly set up an opengl context in that code; there is a
> single call to cutilDeviceInit(argc, argv) as the program is initialized
> but I don't know whether that ends up calling cuGLInit or not, as its part
> of the cuda cutil library. Any ideas what might be wrong?
cutil source is included under common/, there's no GL stuff in there. There's
also no explicit GL interop initialization in the SDK--for the runtime API,
that's apparently not necessary.
Check this here, too:
- http://forums.nvidia.com/index.php?showtopic=58779&hl=cuGLInit
If you're still not having any luck, I'll try to get some help from Nvidia.
Andreas
On Mittwoch 11 Februar 2009, Peter Berrington wrote:
> Thanks a lot for working on that Andreas. I'd be more than happy to write a
> tutorial/example and documentation, but I wasn't able to get it working
> when I played around with it earlier today. I assume that I should first
> call import pycuda.gl.autoinit to set up a context, however that throws
> this error:
> pycuda._driver.LogicError: cuGLInit failed: invalid context
>
> If I instead use the standard pycuda autoinit and then try to call
> pycuda.gl.init() directly it instead fails with
> pycuda._driver.Error: cuGLInit failed: unknown
>
> I browsed around in the source but I'm afraid I couldn't see anything that
> looked obviously wrong, although there was apparently a mispelling in the
> gl/autoinit.py file: The function pycuda.gl.make_gl_context(device) is
> called but it looks that module only has a make_context() function, not a
> make_gl_context function.
Fixed, thanks.
> Am I misunderstanding how to go about initializing pycuda? If not, is there
> any more information I can provide that might help you identify why
> cuGLInit function call fails? Thanks!
I've googled around a bit and written up my findings at
http://documen.tician.de/pycuda/gl.html
(Pull recent git to get the updated autoinit.)
Andreas
I didn't see any response on the mailing list so I thought I'd ask again.
Has anyone made any attempt at wrapping the cuda opengl interop functions in
pycuda? I've never used boost before and I'm not sure how to proceed. I'd
really like to be able to use pycuda to post process an opengl pixel buffer
object but without the cudaGLRegisterBufferObject and cudaGLMapBufferObject
functions I don't see how I can do this.
I saw there was a recent release of codepy; would codepy allow one include
and call the C cuda opengl functions directly or am I misunderstanding how
it works? Thanks for your response.
Hi Andreas,
Did you by any chance make changes to memset_d32 any time recently?
I was getting large negative number output from a kernel (which does
atomic adds to a region of memory which should be zeroed); I switched it to
a drv.from_device(numpy.zeros) and it seemed to work; then I updated pycuda
and rebuilt, and the problem seems to have gone away. Apologies in advance
if this is my fault.
Thanks,
Nicholas
That did the trick! But there is still one error when I ran test_driver.py
It says:
da-vinci@da-vinci-desktop:~/pycuda-0.91.1/test$ python test_driver.py
.....E....
======================================================================
ERROR: test_mempool (__main__.TestCuda)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_driver.py", line 239, in test_mempool
queue.append(pool.allocate(1<<e))
MemoryError
Ran 10 tests in 4.168s
FAILED (errors=1)
I ran test_path.py and it says ok:
da-vinci@da-vinci-desktop:~/pycuda-0.91.1/test$ python test_math.py
sample size: 8192
.....................
----------------------------------------------------------------------
Ran 21 tests in 8.284s
OK
Thank you soooo much for all your help!!!!
I really appreciate it.
Jan
2009/2/8 J-Pascal Mercier <jean-pascal.mercier(a)inrialpes.fr>
>
>
> Begin forwarded message:
>
> Date: Sun, 8 Feb 2009 20:37:45 +0100
> From: J-Pascal Mercier <jean-pascal.mercier(a)inrialpes.fr>
> To: jan acosta <acosta.janp(a)gmail.com>
> Subject: Re: [PyCuda] Need help installing Pycuda
>
>
> On Sun, 8 Feb 2009 14:27:54 -0500
> jan acosta <acosta.janp(a)gmail.com> wrote:
>
> > I typed export $ export $PATH=${PATH}:/usr/local/cuda/bin
> >
> > and it says:
> >
> > da-vinci@da-vinci-desktop:~$ export $PATH=${PATH}:/usr/local/cuda/bin
>
> sorry, my bad
>
>
> export PATH=${PATH}:/usr/local/cuda/bin
>
>
>
> J-Pascal
>
>
> --
> J-Pascal MERCIER
> Projet PRIMA - Laboratoire LIG
> INRIA Grenoble Rhone-Alpes Research Centre
> 655, Avenue de l'Europe
> 38 334 Saint-Ismier Cedex, France
>
> Home : +33 (0)6 82 57 5993
> Office : +33 (0)4 76 61 5349
>