RuntimeError: pidfd_getfd: Operation not permitted
while running script with:
bash ./examples/qwen2.5-1.5B-distill_ds/run_distill_pipeline.sh
The pipeline crashed during student training (StudentWorker.train_step()).
And the crash happened while deserializing teacher logits that were sent over multiprocessing CUDA IPC.
This is the traceback with privacy hidden below:
Traceback (most recent call last):
File "/home/<user>/ROLL/examples/start_distill_pipeline.py", line 36, in <module>
main()
File "/home/<user>/ROLL/examples/start_distill_pipeline.py", line 32, in main
pipeline.run()
File "<venv>/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/home/<user>/ROLL/roll/pipeline/distill/distill_pipeline.py", line 219, in run
student_train_metrics = DataProto.materialize_concat(data_refs=student_train_metrics_refs)
File "/home/<user>/ROLL/roll/distributed/scheduler/protocol.py", line 732, in materialize_concat
data_get = ray.get(data_obj_refs, timeout=timeout)
File "<venv>/lib/python3.10/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
return fn(*args, **kwargs)
File "<venv>/lib/python3.10/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
return func(*args, **kwargs)
File "<venv>/lib/python3.10/site-packages/ray/_private/worker.py", line 2822, in get
values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
File "<venv>/lib/python3.10/site-packages/ray/_private/worker.py", line 930, in get_objects
raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(RuntimeError): ray::StudentWorker.train_step() (pid=<pid>, ip=<private-ip>, actor_id=<redacted>, repr=StudentWorker(student-0))
File "/home/<user>/ROLL/roll/distributed/scheduler/decorator.py", line 308, in inner
raise e
File "/home/<user>/ROLL/roll/distributed/scheduler/decorator.py", line 296, in inner
result = func(*args, **kwargs)
File "/home/<user>/ROLL/roll/pipeline/distill/distill_worker.py", line 63, in train_step
self.teacher_logits = MultiprocessingSerializer.deserialize(
File "/home/<user>/ROLL/roll/utils/cuda_ipc_utils.py", line 46, in deserialize
return ForkingPickler.loads(data)
File "<venv>/lib/python3.10/site-packages/torch/multiprocessing/reductions.py", line 181, in rebuild_cuda_tensor
storage = storage_cls._new_shared_cuda(
File "<venv>/lib/python3.10/site-packages/torch/storage.py", line 1452, in _new_shared_cuda
return torch.UntypedStorage._new_shared_cuda(*args, **kwargs)
RuntimeError: pidfd_getfd: Operation not permitted
seems to be a permission issue. Please try running process with sudo
Rerun with
sudo -E PATH=/pathto/miniconda3/envs/roll/bin:$PATH /pathto/miniconda3/envs/roll/bin/python3 -m examples.start_distill_pipeline --config_path ./qwen2.5-1.5B-distill_ds --config_name distill_zero3
but encountered the same error
[2025-08-21 02:29:37] [distill_pipeline.py (202)] [INFO] [DRIVER 0 / 1][PID 1160] epoch 0 start...
[2025-08-21 02:29:37] [distill_pipeline.py (207)] [INFO] [DRIVER 0 / 1][PID 1160] pipeline step 1 start...
(TeacherWorker(teacher-0) pid=11299) [2025-08-21 02:29:37] [platform.py (88)] [WARNING] [teacher-0 0 / 2][PID 11299] Current platform cuda does not have '_cuda_clearCublasWorkspaces' attribute.
(TeacherWorker(teacher-0) pid=11299) [2025-08-21 02:29:37] [context_managers.py (38)] [INFO] [teacher-0 0 / 2][PID 11299] teacher/teacher_forward_start_offload, memory allocated (GB): 1.430511474609375e-06, memory reserved (GB): 0.001953125, memory max reserved (GB): 0.001953125, rss (GB): 3.2619857788085938
... warnings about `torch.cuda.reset_max_memory_allocated` and `torch.cuda.reset_max_memory_cached` ...
(TeacherWorker(teacher-0) pid=11299) [2025-08-21 02:29:37] [context_managers.py (38)] [INFO] [teacher-0 0 / 2][PID 11299] teacher/teacher_forward_start_onload, memory allocated (GB): 1.437697410583496, memory reserved (GB): 1.447265625, memory max reserved (GB): 1.447265625, rss (GB): 3.2619857788085938
(TeacherWorker(teacher-0) pid=11299) Elapsed time: 0.1337 seconds
(TeacherWorker(teacher-0) pid=11299) [2025-08-21 02:29:37] [distill_worker.py (182)] [INFO] [teacher-0 0 / 2][PID 11299] global_step: 1
Traceback (most recent call last):
File "runpy.py", line 196, in _run_module_as_main
File "runpy.py", line 86, in _run_code
File "start_distill_pipeline.py", line 36, in <module>
main()
File "start_distill_pipeline.py", line 32, in main
pipeline.run()
File "torch/utils/_contextlib.py", line 116, in decorate_context
File "distill_pipeline.py", line 219, in run
student_train_metrics = DataProto.materialize_concat(data_refs=student_train_metrics_refs)
File "protocol.py", line 732, in materialize_concat
data_get = ray.get(data_obj_refs, timeout=timeout)
File "ray/_private/worker.py", line 2822, in get
File "ray/_private/worker.py", line 930, in get_objects
raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(RuntimeError): ray::StudentWorker.train_step() (pid=10626, actor_id=...)
File "decorator.py", line 308, in inner
raise e
File "decorator.py", line 296, in inner
result = func(*args, **kwargs)
File "distill_worker.py", line 63, in train_step
self.teacher_logits = MultiprocessingSerializer.deserialize(
File "cuda_ipc_utils.py", line 46, in deserialize
return ForkingPickler.loads(data)
File "torch/multiprocessing/reductions.py", line 181, in rebuild_cuda_tensor
storage = storage_cls._new_shared_cuda(
File "torch/storage.py", line 1452, in _new_shared_cuda
return torch.UntypedStorage._new_shared_cuda(*args, **kwargs)
RuntimeError: pidfd_getfd: Operation not permitted
(StudentWorker(student-0) pid=10626) [2025-08-21 02:29:37] [decorator.py (306)] [ERROR] pidfd_getfd: Operation not permitted
(StudentWorker(student-0) pid=10626) [2025-08-21 02:29:37] [decorator.py (307)] [ERROR] Traceback (most recent call last):
File "decorator.py", line 296, in inner
result = func(*args, **kwargs)
File "distill_worker.py", line 63, in train_step
self.teacher_logits = MultiprocessingSerializer.deserialize(
File "cuda_ipc_utils.py", line 46, in deserialize
return ForkingPickler.loads(data)
File "torch/multiprocessing/reductions.py", line 181, in rebuild_cuda_tensor
storage = storage_cls._new_shared_cuda(
File "torch/storage.py", line 1452, in _new_shared_cuda
return torch.UntypedStorage._new_shared_cuda(*args, **kwargs)
RuntimeError: pidfd_getfd: Operation not permitted
(StudentWorker(student-1) pid=11046) [2025-08-21 02:29:37] [decorator.py (306)] [ERROR] pidfd_getfd: Operation not permitted
(StudentWorker(student-1) pid=11046) [2025-08-21 02:29:37] [decorator.py (307)] [ERROR] Traceback (most recent call last):
File "decorator.py", line 296, in inner
result = func(*args, **kwargs)
File "distill_worker.py", line 63, in train_step
self.teacher_logits = MultiprocessingSerializer.deserialize(
File "cuda_ipc_utils.py", line 46, in deserialize
return ForkingPickler.loads(data)
File "torch/multiprocessing/reductions.py", line 181, in rebuild_cuda_tensor
storage = storage_cls._new_shared_cuda(
File "torch/storage.py", line 1452, in _new_shared_cuda
return torch.UntypedStorage._new_shared_cuda(*args, **kwargs)
RuntimeError: pidfd_getfd: Operation not permitted
...
(TeacherWorker logs continue with forward pass, DeepSpeed initialization, and model definition)
Are you running inside a Docker container?
If so, please check whether you started it with --cap-add=SYS_PTRACE, or run capsh --print | grep cap_sys_ptrace inside the container to see if it has ptrace capability.
Actually we have tested the same script through bare machine, rather than within a docker container, yet still encountered the similar error.
It appears that this issue is caused by a lack of permissions to execute the pidfd_getfd system call. Internally, torch.UntypedStorage._new_shared_cuda invokes this system call, so we need to verify whether your system has the required permissions.
Here are a few things to check:
-
Verify ptrace capability
Even on a bare-metal machine, you can run:capsh --print | grep cap_sys_ptraceto see if your process has the
CAP_SYS_PTRACEcapability.
The permission check forpidfd_getfdfollows the exact same path as forptrace. -
Check your kernel version
Thepidfd_getfdsyscall requires Linux kernel 5.6 or newer. You can verify your kernel version with:uname -r -
Reference similar issues
There’s a related discussion here that you might find helpful: https://stackoverflow.com/questions/75045206/eperm-on-pidfd-getfd-with-socket
To help us diagnose the problem more accurately, please provide additional details about your machine and runtime environment — such as OS distribution/version, Python version, CUDA setup, etc.
We have also tested this on bare metal and observed that the same issue still persists. As an alternative, we tried removing MultiprocessingSerializer and using ray.get/put for data transfer. Since it avoids the container capability issue, would this be considered a reasonable approach? We have further validated the changes on both GPU and NPU. The code is provided here — could you please help review whether this modification is appropriate? https://github.com/alibaba/ROLL/pull/161
Our ptrace check returns like below:
(roll) [root@node1 ROLL]# capsh --print | grep cap_sys_ptrace
Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read,cap_perfmon,cap_bpf,cap_checkpoint_restore
(roll) [root@node1 ROLL]# uname -r
5.10.0-136.12.0.86.h1258.eulerosv2r12.aarch64
Transferring via Ray is a workable solution, but it is relatively inefficient, so we use IPC for transmitting the logits instead.
You can run getenforce to check whether any security policies are enabled on your system, which might be causing pidfd_getfd to be disabled.
If that does not resolve the problem, it is recommended to run the program inside Docker with sufficiently elevated privileges to ensure that pidfd_getfd can be executed.
Thanks a lot for your help and detailed explanations— we’ve finally identified the root cause of our issue. Since our machines typically run with security enforcement enabled, would it be acceptable to introduce an environment variable as a fallback mechanism? By default, we would continue using multiprocessing with ForkingPickler, while setting the variable would seamlessly switch the transfer to Ray when needed.
If permissible, you can temporarily disable the security policy by running setenforce 0 to enable the use of IPC.
For the fallback mechanism, you could implement a try–catch block to detect whether IPC is available, or add configuration parameters that allow switching between different methods for transferring logits under varying conditions. Contributions in the form of a pull request are welcome.
In addition, we are currently developing support for transferring logits via NCCL, which offers higher performance than using Ray alone.