python - 如何在 Linux 中分析 PyCuda 代码?

标签 python profiling cuda gpgpu pycuda

我有一个简单的(经过测试的)pycuda 应用程序,我正在尝试对其进行概要分析。我试过 NVidia 的 Compute Visual Profiler,它运行程序 11 次,然后发出此错误:

NV_Warning: Ignoring the invalid profiler config option: fb0_subp0_read_sectors
Error : Profiler data file '/home/jguy/proj/gpu/tdbp/pyArch/temp_compute_profiler_0_0.csv' does not contain profiler output.This can happen when:
a) Profiling is disabled during the entire run of the application.
b) The application does not invoke any kernel launches or memory transfers.
c) The application does not release resources (contexts, events, etc.). The program needs to be modified to properly free up all resources before termination.

我还尝试运行“CUDA_PROFILE python scriptname.py arg1”。它创建了一个包含以下内容的文件:

NV_Warning: Ignoring the invalid profiler config option: instructions
# CUDA_PROFILE_LOG_VERSION 2.0
# CUDA_DEVICE 0 GeForce GTX 560 Ti
# CUDA_PROFILE_CSV 1
# TIMESTAMPFACTOR fffff7003e38fec8
gpustarttimestamp,method,gputime,cputime,occupancy

如果有用,我还设置了这些环境变量:

CUDA_PROFILE_CONFIG=temp_cuda_profiler.conf
CUDA_PROFILE_CSV=1
CUDA_PROFILE_LOG=profile.csv
CUDA_PROFILE=1

和 temp_cuda_profiler.conf 包含

gpustarttimestamp
instructions

谷歌搜索了一个小时左右。没有运气。感谢您提供的任何见解!

最佳答案

当使用 import pycuda.autoinit 时,在程序末尾有 pycuda.autoinit.context.detach() 很重要。这解决了问题。

关于python - 如何在 Linux 中分析 PyCuda 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5317691/

相关文章:

cpu 的 golang no/debug/pprof/profile 端点,同时拥有其他一切

perl - 如何在重负载下对 IO 绑定(bind)的 Perl Web 应用程序进行基准测试和分析?

.net - 如何构建附加到 .NET 进程并监听特定类型事件的自定义调试器?

opengl - CUDA + OpenGl 教程

python 列表理解无效的语法,而 if 语句

python - python加载json时,如何将str转成unicode,才能打印汉字?

python - 如何将字符串中的元组转换为元组对象?

python - 在Windows中使用python获取重启历史记录

cuda - 您可以在虚拟机中编程/测试 CUDA 吗?

c++ - 为什么我的GPU程序可以执行,虽然 block 数超过驻留 block 数?