2

This question is almost the same as How to profile PyCuda code with the Visual Profiler? except about the new NVIDIA Nsight IDE with CUDA 5 for Linux.

I have a PyCUDA Python script that I'd like to profile using fancy Nsight.

I set up a Build External Tools Configuration, pointing to the example script (with executable permissions, included below). I can then run this, and see the printouts in the Console. Then I go to Profile mode and click Run -> Profile---I see the printouts in the Console but no profiler information visible. How do I get the timing plots and occupancy calculators and NVIDIA's suggestions for my code that appear when I run a C/CUDA program in Nsight?

Total IDE noob here (mostly command-line), sorry if my question doesn't include key information. Ubuntu 11.10, PyCUDA 2012.1.

Nsight screenshot

example.py:

#!/usr/bin/env python
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))

print "error:", numpy.sum(numpy.abs(dest - a*b).ravel())
print "Done"
#pycuda.autoinit.context.detach() # seems to break PyCUDA 2012.1
Community
  • 1
  • 1
Ahmed Fasih
  • 6,458
  • 7
  • 54
  • 95
  • 1
    what happens if you run nvvp from the command line and then enter the command to run your pyCUDA app that way (in the visual profiler startup wizard/dialog)? Just trying to understand if this is an eclipse issue or a visual profiler issue. – Robert Crovella Nov 02 '12 at 05:11
  • nvvp is what I need! It is able to profile my code and show me everything I wanted to see. I'll use nvvp instead of nsight. – Ahmed Fasih Nov 02 '12 at 05:30

3 Answers3

1

Nsight Eclipse Edition currently do not support debugging PyCUDA applications.

One thing you could try though (I have not tried it myself):

  1. On the main menu, select Run->Profile Configurations...
  2. Enter your Python interpreter (e.g. '/usr/bin/python') as "C/C++ Application"
  3. Specify any existing project in the "Project" list.
  4. On the "Arguments" tab specify path to your script file.
  5. Press "Profile" in the bottom-right corner.

I don't have pycuda installed so profiling your script failed as expected...

Eugene
  • 9,242
  • 2
  • 30
  • 29
1

I used nvvp to get the timeline and the program analysis. Just chmod 755 the script and add a #!/usr/bin/env python at the top and give it to nvvp.

Ahmed Fasih
  • 6,458
  • 7
  • 54
  • 95
0

Nvidia Visual Profiler

  • Go to your script path
# If you using conda:
conda activate env_name
# Run the Nvidia Visual Profiler:
nsight-sys
  • Command line with parameters: python3 script_name.py
  • Working directory: Script path
  • Press: Start

Nvidia Nsight Compute

  • Go to your script path
# If you using conda:
conda activate env_name

# To get the current python path:
which python3

# Run the Nvidia Nsight Compute:
nv-nsight-cu
  • Application executable: Set the current python path
  • Working directory: Script path
  • Command line arguments: Script file name
  • Press: Launch