Skip to content

Removing CUDA Runtime Dependency from plugin - #1359

Merged
bwbarrett merged 4 commits into
aws:masterfrom
hershys-aws:fix-cuda-runtime-error
Aug 19, 2026
Merged

Removing CUDA Runtime Dependency from plugin #1359
bwbarrett merged 4 commits into
aws:masterfrom
hershys-aws:fix-cuda-runtime-error

Conversation

@hershys-aws

Copy link
Copy Markdown
Contributor

Description of changes:
Removing CUDA runtime functions introduced by multi-segment host memory functionality as well as EFA DP Direct.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hershys-aws
hershys-aws requested a review from a team as a code owner August 18, 2026 23:20
@hershys-aws hershys-aws self-assigned this Aug 18, 2026
@rauteric

Copy link
Copy Markdown
Contributor

For bisectability, doesn't your first commit (removing the CUDA linking) need to come last, after you have changed everything to the driver API?

@hershys-aws

Copy link
Copy Markdown
Contributor Author

For bisectability, doesn't your first commit (removing the CUDA linking) need to come last, after you have changed everything to the driver API?

Ahh yes. I think you are right. I kept the order of development but I will change that.

amitrad-aws
amitrad-aws previously approved these changes Aug 18, 2026

@amitrad-aws amitrad-aws left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the order change, please do that

@hershys-aws
hershys-aws force-pushed the fix-cuda-runtime-error branch from 2206a83 to 1b9cef6 Compare August 18, 2026 23:53

@bwbarrett bwbarrett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of your commit messages could use some changes. We use subsection prefixes but not the fix/whatever/ type prefixes. It's also not clear why we're making the change in some, and leaving future us some notes would be helpful.

Comment thread src/Makefile.am Outdated
Comment thread src/nccl_ofi_cuda.cpp Outdated
Comment thread src/nccl_ofi_cuda.cpp Outdated
cudaFree(d_cq);
int ret;

if (!d_cq) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't a 1:1 rewrite; why the changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cuMemFree requires a valid pointer from my understanding whilst cudaFree is a no-op.

Comment thread 3rd-party/efa-gda/CUDA/host/efa_cuda_dp.cpp Outdated
Comment thread 3rd-party/efa-gda/CUDA/host/efa_cuda_dp.cpp Outdated
@hershys-aws
hershys-aws force-pushed the fix-cuda-runtime-error branch 2 times, most recently from f1e607c to ada90e5 Compare August 19, 2026 01:37
Comment thread src/nccl_ofi_cuda.cpp Outdated
@hershys-aws
hershys-aws force-pushed the fix-cuda-runtime-error branch from ada90e5 to 03de6be Compare August 19, 2026 05:17
@bibrakc

bibrakc commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Who maintains efa_cuda_dp? Will be patch it every time we update that 3rd party code?

@hershys-aws
hershys-aws force-pushed the fix-cuda-runtime-error branch 5 times, most recently from 7242739 to 9f416f2 Compare August 19, 2026 18:10
Comment thread src/rdma/gin/nccl_ofi_gin.cpp

@bwbarrett bwbarrett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: your commit message subjects should be declartive, so something like:

efa-gda: Translate cuda runtime function calls to cuda driver function calls

not the current

efa-gda: Translating cuda runtime function calls to cuda driver function calls

Comment thread src/Makefile.am
…n calls

The efa-gda host code (libefa_cuda_dp) used the CUDA Runtime API, which
forces the plugin to link the runtime and breaks --enable-cudart-dynamic.
Translate those calls to the CUDA driver API, provided through wrappers in
nccl_ofi_cuda.cpp, so a later commit can drop the runtime link.

cuGetErrorName / cuGetErrorString are wrapped to provide a driver
equivalent of cudaGetErrorString, which efa-gda uses and the driver API
does not offer directly.

Signed-off-by: Hershel Shah <hershys@amazon.com>
The gdrcopy path used the CUDA Runtime (cudaGetDevice/cudaSetDevice) to
bind a device for its lazy signal-segment discovery, which keeps the
runtime linked and breaks --enable-cudart-dynamic. The driver API has no
cudaSetDevice equivalent, so rather than bind a device we now capture the
application's current CUDA context at comm init (cuCtxGetCurrent) and make
it current (cuCtxSetCurrent) on NCCL's context-less GIN progress thread
before cuMemGetAddressRange.

Also replaces the remaining runtime call, cudaMemset, with cuMemsetD8.

Signed-off-by: Hershel Shah <hershys@amazon.com>
$(CUDA_RUNTIME_LIBS) was added to libinternal_plugin only because the
efa-gda GDAKI host code (libefa_cuda_dp.la) used CUDA Runtime APIs. That
code is now on the CUDA driver API, so the extra linkage is unnecessary;
dropping it also avoids a hard libcudart dependency in the plugin under
--enable-cudart-dynamic.

Signed-off-by: Hershel Shah <hershys@amazon.com>
The gdrcopy unit test calls cudaSetDevice and cudaGetErrorString from the
CUDA runtime directly. It previously resolved these transitively through
libinternal_plugin, but the plugin no longer links the CUDA runtime so
that --enable-cudart-dynamic keeps working. Link CUDA_RUNTIME_LIBS into
the gdrcopy target so the test builds without pulling the runtime back
into the plugin.

CUDA_RUNTIME_LIBS is -lcudart for dynamic builds and empty for static
builds, where cudart_static is already provided by CUDA_LIBS.

Signed-off-by: Hershel Shah <hershys@amazon.com>
@hershys-aws
hershys-aws force-pushed the fix-cuda-runtime-error branch from 0120b2e to 9b9b9f3 Compare August 19, 2026 20:00
@bwbarrett
bwbarrett merged commit 98bdc0d into aws:master Aug 19, 2026
297 of 317 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants