解决 Intel VTune 报错 Sampling driver is not available 采样驱动缺失修复
排查 使用 Intel VTune Profiler 深度分析异构计算性能时报错 Collection failed. The sampling driver is not available 或 PMU cannot be accessed,分析 sep 硬件性能监控驱动与 Linux 内核隔离。
问题现象
启动 VTune 进行微架构高级分析(Microarchitecture Exploration)时,采集瞬间终止并报错:
[Error]: Cannot enable hardware event-based sampling collection.
Error: The sampling driver is not available. Please install the SEP driver or check permissions.
触发根因
- 硬件级事件采样必须依赖 Intel 专有的
sep(Sampling Enabling Product)内核模块直接读取 CPU/GPU 的 PMU(Performance Monitoring Unit)硬件计数器; - 当前运行环境未编译加载
sep5.ko内核驱动; - 系统配置了过严的
perf_event_paranoid安全限制(限制了普通用户访问硬件计数器)。
解决步骤
进入 VTune 安装目录手动构建并加载专有采样驱动
执行驱动安装脚本:
cd /opt/intel/oneapi/vtune/latest/sepdk/src
sudo ./build-driver
sudo ./insmod-sep -g vtune # 将 vtune 用户组授权
放宽 Linux 内核对通用硬件性能计数器的访问级别
在线临时放宽:
sudo sysctl -w kernel.perf_event_paranoid=0
sudo sysctl -w kernel.kptr_restrict=0
验证驱动是否成功加载
运行:/opt/intel/oneapi/vtune/latest/bin64/vtune -collect hotspots -- ./my_app。
验证确认
重新拉起 VTune 性能分析:
硬件 PMU 采样以纳秒级精度全速捕获指令执行瓶颈,直观输出 CPU 缓存未命中与异构内存流水线热点图。


