问题描述
当我创建一个新会话并告诉 Visual Profiler 启动我的 python/pycuda 脚本时,我收到以下错误消息:Execution run #1 of program '' failed, exit code: 255
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
这些是我的偏好:
- 启动:
python "/pathtopycudafile/mysuperkernel.py"
- 工作目录:
"/pathtopycudafile/mysuperkernel.py"
- 参数:
[empty]
我在 Ubuntu 10.10 下使用 CUDA 4.0.64位.分析编译的示例工作.
I use CUDA 4.0 under Ubuntu 10.10. 64Bit. Profiling compiled examples works.
附言我知道 SO 问题 如何在 Linux 中分析 PyCuda 代码?,但似乎是一个不相关的问题.
p.s. I am aware of SO question How to profile PyCuda code in Linux?, but seems to be an unrelated problem.
小例子
pycudaexample.py:
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()
示例设置
错误信息
推荐答案
您为计算分析器指定可执行文件的方式有问题.如果我在您发布的代码的顶部放了一条井号线:
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
然后给python文件可执行权限,计算分析器运行代码没有抱怨,我得到这个:
and then give the python file executable permissions, the compute profiler runs the code without complaint and I get this:
这篇关于如何使用 Visual Profiler 分析 PyCuda 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!