如何配置PyCuda代码与Visual Profiler? [英] How to profile PyCuda code with the Visual Profiler?

查看:298
本文介绍了如何配置PyCuda代码与Visual Profiler?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个新的会话,并告诉Visual Profiler启动我的python / pycuda脚本时,我得到以下错误信息:程序执行#1失败,退出代码:255



这些是我的偏好:




  • 发布: python/pathtopycudafile/mysuperkernel.py

  • 工作目录:/ pathtopycudafile / mysuperkernel.py code>

  • 参数: [empty]



我在Ubuntu 10.10下使用CUDA 4.0。 64位。分析编译示例的工作原理。



p.s。我知道这个问题如何在Linux中剖析PyCuda代码? ,但似乎是一个不相关的问题。



最少例



pycuda示例。 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()

示例设置



错误消息



解决方案

将可执行文件指定给compute profiler的方式有问题。如果我在你发布的代码的顶部放置一个哈希bang线:

 #!/ usr / bin / env python 

然后给python文件可执行权限,计算profiler运行代码而不投诉,我得到这样: / p>

>


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

Error message

解决方案

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:

这篇关于如何配置PyCuda代码与Visual Profiler?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆