如何使用 Visual Profiler 分析 PyCuda 代码?

2023-01-25Python开发问题
5

本文介绍了如何使用 Visual Profiler 分析 PyCuda 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

当我创建一个新会话并告诉 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 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11