2

When I create a new session and tell the Visual Profiler to launch my python/pycuda scripts I get following error message: Execution run #1 of program '' failed, exit code: 255

These are my preferences:

  • Launch: python "/pathtopycudafile/mysuperkernel.py"
  • Working Directory: "/pathtopycudafile/mysuperkernel.py"
  • Arguments: [empty]

I use CUDA 4.0 under Ubuntu 10.10. 64Bit. Profiling compiled examples works.

p.s. I am aware of SO question How to profile PyCuda code in Linux?, but seems to be an unrelated problem.

Minimal example

pycudaexample.py:

import pycuda.autoinit
import pycuda.driver as drv
import numpy

from pycuda.compiler import SourceModule

mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")

multiply_them = mod.get_function("multiply_them")

a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)

dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))

pycuda.autoinit.context.detach()

Example settings Screenshot of used settings

Error message

Screenshot of error message

Community
  • 1
  • 1
Framester
  • 33,341
  • 51
  • 130
  • 192
  • It isn't unrelated at all, the answer is exactly what needs to be done. The CUDA context needs to be explicitly destroyed at the end of execution so that the buffers holding the profile data are flushed and written to disk. I profile python code in executable files with hash bangs all the time, and it just works, as long `pycuda.autoinit.context.detach()` is called before exit. – talonmies Jul 28 '11 at 10:36
  • possible duplicate of [How to profile PyCuda code in Linux?](http://stackoverflow.com/questions/5317691/how-to-profile-pycuda-code-in-linux) – talonmies Jul 28 '11 at 10:40
  • @talonmies, I added pycuda.autoinit.context.detach() to the end of my script, but still the same error message.'Execution run #1 of program '' failed, exit code: 255' – Framester Jul 28 '11 at 10:51
  • Post a minimal repro case in your question and someone might have time to take a look at it. – talonmies Jul 28 '11 at 11:22

2 Answers2

4

There is something wrong with the way you are specifying the executable to the compute profiler. If I put a hash bang line at the top of your posted code:

#!/usr/bin/env python

and then give the python file executable permissions, the compute profiler runs the code without complaint and I get this:

enter image description here

talonmies
  • 70,661
  • 34
  • 192
  • 269
1

There are two methods that you can use.

Launch the Script Interpreter

Launch    python
Arguments "/pathtopycudafile/mysuperkernel.py"

Launch a Executable Script

Launch    "/pathtopycudafile/mysuperkernel.py"
Arguments [blank]

mysuperkernel.py must be executable (chmod +x)
mysuperkenrel.py must have a #! to specify the path to the interpreter

See @talonmies answer

talonmies
  • 70,661
  • 34
  • 192
  • 269
Greg Smith
  • 11,007
  • 2
  • 36
  • 37