如何在Linux中分析PyCuda代码?
我有一个简单的(已经测试过的)pycuda应用程序,现在想对它进行性能分析。我尝试了NVIDIA的计算可视化分析工具,它会运行程序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 个回答
2
在使用 import pycuda.autoinit 的时候,程序最后一定要加上 pycuda.autoinit.context.detach()。这样可以解决问题。