如何在Linux中分析PyCuda代码?

时间:2011-03-15 20:32:59

标签: 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

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

1 个答案:

答案 0 :(得分:1)

使用import pycuda.autoinit时,在程序结束时使用pycuda.autoinit.context.detach()非常重要。这解决了这个问题。