bringtree / question_embedding

这个仓库的issues里记录了许多奇奇怪怪的东西(100+)。
1 stars 1 forks source link

docker 容器 不支持 perf #189

Open bringtree opened 3 years ago

bringtree commented 3 years ago
perf_event_open(…, PERF_FLAG_FD_CLOEXEC) failed with unexpected error 1 (Operation not permitted)
perf_event_open(…, 0) failed unexpectedly with error 1 (Operation not permitted)
Error:
No permission to enable cycles event.
You may not have permission to collect stats.
Consider tweaking /proc/sys/kernel/perf_event_paranoid,
which controls use of the performance events system by
unprivileged users (without CAP_SYS_ADMIN).
The current value is -1:
-1: Allow use of (almost) all events by all users
 Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK
>= 0: Disallow ftrace function tracepoint by users without CAP_SYS_ADMIN
 Disallow raw tracepoint access by users without CAP_SYS_ADMIN
>= 1: Disallow CPU event access by users without CAP_SYS_ADMIN
>= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN
To make this setting permanent, edit /etc/sysctl.conf too, e.g.:
kernel.perf_event_paranoid = -1

安装这个流程 https://medium.com/@geekidea_81313/running-perf-in-docker-kubernetes-7eb878afcd42 就能解决

复制一份 https://raw.githubusercontent.com/moby/moby/master/profiles/seccomp/default.json 然后 在 syscalls这一列的json 数组中 补充 "perf_event_open" 并检查 action是不是 "SCMP_ACT_ALLOW" 最后保存,然后docker run 重新启动一个镜像就可以用了。

docker run --security-opt seccomp=perf.json --name="seccomp" -idt centos