cuda_buffer: device identity is the per-process CUDA ordinal, not the GPU UUID (wrong IPC decision under CUDA_VISIBLE_DEVICES)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- backend, distributed-systems
Research direction
Start with cuda_buffer/src/host_endpoint_manager.cpp and cuda_buffer_backend/src/cuda_buffer_backend_plugin.cpp, then trace device identity through cuda_buffer_ipc_manager.cpp and the shared memory registry. Check how endpoint and descriptor device IDs are chosen, compared, and used for cuMemSetAccess; the issue describes two multi-GPU cases but notes they have not been reproduced. Done means IPC decisions use physical device identity and mismatches fall back without dropping message data.
Written by the indexing model from the issue text.
Description
Generated by Generative AI: drafted with Claude (Anthropic) from a human-reviewed code reading; the code references below were checked against main @ c0c9df3.
Operating System: Ubuntu 24.04.4 LTS, x86_64
ROS version or commit hash: Lyrical; ros-lyrical-cuda-buffer / cuda-buffer-backend 0.1.2, and source main @ c0c9df3
RMW implementation: any (observed paths are in the backend, not the RMW)
Hardware / CUDA: RTX 5090, driver 580.167.08, CUDA 13.2 runtime (minor-version compatibility)
Summary
cuda_buffer identifies a process's GPU by its CUDA runtime ordinal, and compares ordinals across processes to decide whether a peer can import a VMM descriptor. Ordinals are per-process: they depend on each process's CUDA_VISIBLE_DEVICES (and CUDA_DEVICE_ORDER), so the same ordinal can name different physical GPUs in two processes, and the same GPU can have different ordinals.
Note: this comes from code reading. I have not reproduced it, because I only have a single-GPU machine.
Code
cuda_buffer/src/host_endpoint_manager.cpp:171-175stores the endpoint's device ascudaGetDevice(). The calling thread gets that value when the firstHostEndpointManageris created, and it is then published in the shared-memory registry asdevice_id.cuda_buffer_backend/src/cuda_buffer_backend_plugin.cpp:77gives the same-host import decision:peer.device_id == manager.get_device_id() && peer.uid == manager.get_uid().cuda_buffer_backend_plugin.cpp:194setsdescriptor->device_id = cuda_impl->get_device_id(), which is also an ordinal.:271then compares it to the importer'scudaGetDevice().cuda_buffer_ipc_manager.cpp:553-563callscuMemSetAccessfor the importer's current ordinal.
Steps to reproduce (expected; needs 2 GPUs)
- On a 2-GPU host, start a publisher of a message with a CUDA-backed
uint8[]underCUDA_VISIBLE_DEVICES=1, and a subscriber in another process (same uid) underCUDA_VISIBLE_DEVICES=0. Both report ordinal 0, but they are on different GPUs. - Start a publisher with
CUDA_VISIBLE_DEVICES=0,1that callscudaSetDevice(1)before creating its node, and a subscriber withCUDA_VISIBLE_DEVICES=1. The GPU is the same, but the ordinals are 1 and 0.
Expected behavior
The backend sends a CUDA descriptor only when both endpoints are on the same physical GPU (or on GPUs that can actually map each other's memory), and it falls back to CPU only when they cannot.
Actual behavior (from code)
- Case 1 (different GPUs, both ordinal 0):
can_import_descriptorreturns true, so the publisher sends a descriptor. On the subscriber,descriptor->device_id == local_device_idalso passes. The import then maps memory that belongs to the other GPU and callscuMemSetAccessfor the local GPU. Without P2P this should fail. Thecatchatcuda_buffer_backend_plugin.cpp:321-332then logsIPC import failed, falling back to CPU/Dropping stale descriptorand hands the subscriber an empty buffer, so the message arrives with no data. With P2P it may instead succeed and silently read over the interconnect. - Case 2 (same GPU, different ordinals):
:77returns false, socreate_descriptor_with_endpointreturnsnullptr. Every message then takes the CPU wire format, with no warning. That is a full device-to-host copy per message, which for multi-camera 4K uint8 frames is tens of MB per message. - A related ambiguity: because the endpoint device is captured from the thread that first creates an endpoint, a process that publishes from buffers on several GPUs (or calls
cudaSetDeviceafter node creation) advertises one ordinal that may not match the buffers it sends.
Suggested fix
Identify devices by GPU UUID (cudaDeviceProp::uuid / cuDeviceGetUuid) rather than by ordinal:
- Store the UUID in the endpoint registry slot and in
CudaBufferDescriptor, which can keepdevice_idfor the local ordinal. - In
can_import_descriptor, compare UUIDs, and map the descriptor's UUID to a local ordinal on import. Use that ordinal forcuMemSetAccess, or fall back cleanly when no local device matches. - Derive the descriptor's device from the buffer's allocation (
pool->get_device_id()→ UUID), not from the thread's current device. - Consider logging a one-time WARN when a same-host peer is downgraded to CPU because of a device mismatch, so that case 2 is visible.
The existing CUDA_BUFFER_DEVICE_ID_OVERRIDE test hook overrides the ordinal that is being compared, so it does not exercise either case. A UUID override hook would let both cases be tested on one GPU.
- Dominant language
- C++
- Stars
- 27
- Forks
- 13
- Avg merge
- 21d 23h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/rosidl_buffer_backends
-
cuda_buffer: late import of a reused VMM block passes the UID staleness check and reads the next frameMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
-
cuda_buffer: please release #12 (0.1.2 segfaults in get_endpoint_manager after a context restart)Possibly taken @yuanknv claimed this 3 days ago. Open
Difficulty 4/5 1-2 days Newbie friendliness 15/100
ros2/rosidl_buffer_backends#42 · 1 reaction · 1 assignee ·
-
Subscription accepting the cuda backend receives no messages when the cuda_buffer_backend plugin is not available in its processMay be free again @nvcyc claimed this 28 days ago, and no pull request is open. Open
ros2/rosidl_buffer_backends#34 · 1 assignee ·
-
Add ONNX Runtime tensor conversionsMay be free again @yuanknv claimed this 90 days ago, and no pull request is open. Openenhancement
ros2/rosidl_buffer_backends#14 · 2 assignees ·
All issues in ros2/rosidl_buffer_backends
Similar issues
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
EchoTools/nevr-runtime#2912 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug-unconfirmed
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
libc++
Difficulty 1/5 Under an hour Newbie friendliness 88/100
llvm/llvm-project#246508 ·
Maintainers usually reply within 1 day