2011-07-28 38 views
2

當我創建一個新的會話,並告訴視覺探查推出我的Python/pycuda腳本我得到以下錯誤消息:Execution run #1 of program '' failed, exit code: 255如何使用Visual Profiler剖析PyCuda代碼?

這些都是我的喜好:

  • 啓動:python "/pathtopycudafile/mysuperkernel.py"
  • 工作目錄:"/pathtopycudafile/mysuperkernel.py"
  • 參數:[empty]

我在Ubuntu 10.10下使用CUDA 4.0。 64位。分析編譯的例子。

p.s.我知道SO問題How to profile PyCuda code in Linux?,但似乎是一個無關的問題。

最小示例

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() 

示例設置Screenshot of used settings

錯誤消息

Screenshot of error message

+0

它是不無關係可言,答案是什麼需要完成。 CUDA上下文需要在執行結束時明確銷燬,以便保存配置文件數據的緩衝區被刷新並寫入磁盤。我始終在可執行文件中使用hash bangs概要分析python代碼,只要在退出之前調用'pycuda.autoinit.context.detach()',它就可以工作。 – talonmies

+0

[如何在Linux中簡介PyCuda代碼?](http://stackoverflow.com/questions/5317691/how-to-profile-pycuda-code-in-linux) – talonmies

+0

@talonmies,我加了pycuda.autoinit .context.detach()到我的腳本結尾,但仍然是相同的錯誤消息。'程序執行運行#1'失敗,退出代碼:255' – Framester

回答

4

您指定可執行文件到計算分析器的方式有些問題。如果我把一個散列砰線在您發佈的代碼的頂部:

#!/usr/bin/env python 

,然後給蟒蛇文件可執行權限,計算探查器運行時不抱怨的代碼,我得到這個:

enter image description here

1

有兩種方法可以使用。

啓動腳本解釋

Launch python 
Arguments "/pathtopycudafile/mysuperkernel.py" 

啓動一個可執行腳本

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 

見@talonmies回答