Skip to content

Conversation

Andy-Jost
Copy link
Contributor

Both CUDA_HOME (or CUDA_PATH) and LIBRARY_PATH are required to be set in the environment during installation. There was already a check for CUDA_HOME in setup.py, but no check for LIBRARY_PATH. This change adds a check to make sure LIBRARY_PATH is set.

When LIBRARY_PATH is not set, the installation fails at link time and indicates that cudart_static could not be found.

Copy link
Contributor

copy-pr-bot bot commented Aug 14, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

kkraus14
kkraus14 previously approved these changes Aug 14, 2025
@github-project-automation github-project-automation bot moved this from Todo to In Review in CCCL Aug 14, 2025
@kkraus14
Copy link
Collaborator

@Andy-Jost to trigger CI to run you need to comment "/ok to test". More info here: https://docs.gha-runners.nvidia.com/platform/apps/copy-pr-bot/faqs

@Andy-Jost
Copy link
Contributor Author

/ok to test 6b178c1

@Andy-Jost
Copy link
Contributor Author

This breaks Windows builds because LIBRARY_PATH is specific to Linux. While I could place a guard around the check, it's probably better to close this PR without merging.

@Andy-Jost Andy-Jost closed this Aug 14, 2025
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Aug 14, 2025
@rwgk
Copy link
Collaborator

rwgk commented Aug 15, 2025

This breaks Windows builds because LIBRARY_PATH is specific to Linux. While I could place a guard around the check, it's probably better to close this PR without merging.

I think it'd be lovely to complete this PR, I stumbled over this many times.

Under Windows, we need LIB to be set.

This is a good way to test for Windows (we use that in cuda_pathfinder):

IS_WINDOWS = sys.platform == "win32"

@Andy-Jost Andy-Jost reopened this Aug 18, 2025
@github-project-automation github-project-automation bot moved this from Done to Needs Triage in CCCL Aug 18, 2025
@Andy-Jost
Copy link
Contributor Author

This breaks Windows builds because LIBRARY_PATH is specific to Linux. While I could place a guard around the check, it's probably better to close this PR without merging.

I think it'd be lovely to complete this PR, I stumbled over this many times.

Under Windows, we need LIB to be set.

This is a good way to test for Windows (we use that in cuda_pathfinder):

IS_WINDOWS = sys.platform == "win32"

I am looking into a solution that works for Windows as well as Linux.

@leofang leofang added this to the cuda-python parking lot milestone Aug 18, 2025
@leofang leofang linked an issue Aug 18, 2025 that may be closed by this pull request
@leofang
Copy link
Member

leofang commented Aug 18, 2025

Probably just update library_dirs that's passed to setup() in setup.py?

@leofang leofang added enhancement Any code-related improvements P1 Medium priority - Should do cuda.bindings Everything related to the cuda.bindings module labels Aug 18, 2025
@Andy-Jost Andy-Jost force-pushed the fix/add-library-path-check branch from 37e877d to 44579bc Compare August 18, 2025 21:34
@Andy-Jost
Copy link
Contributor Author

Andy-Jost commented Aug 18, 2025

The latest changes eliminate the need to set either LIBRARY_PATH or LIB and should resolve issue #608.

Where can I find the source for the installation instructions? I.e., https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html.

Those can be updated now.

@Andy-Jost
Copy link
Contributor Author

Probably just update library_dirs that's passed to setup() in setup.py?

This did the trick.

@Andy-Jost Andy-Jost force-pushed the fix/add-library-path-check branch 2 times, most recently from d62461d to 96f3514 Compare August 18, 2025 21:52
@Andy-Jost
Copy link
Contributor Author

/ok to test 96f3514

This comment has been minimized.

@Andy-Jost Andy-Jost force-pushed the fix/add-library-path-check branch from 96f3514 to 49ec36d Compare August 18, 2025 23:10
@Andy-Jost Andy-Jost changed the title Adds a check to make sure LIBRARY_PATH is set in setup.py. Adds path for the CUDA static library based on CUDA_HOME Aug 19, 2025
@leofang
Copy link
Member

leofang commented Aug 19, 2025

Thanks, @Andy-Jost! The diff is clean now.

I think to test this properly in the CI, we should delete these two lines

LIBRARY_PATH=/host/${{ env.CUDA_PATH }}/lib

LIB="${CUDA_HOME}\\lib\\x64;${LIB}"

Not sure if I miss any. I hope not 🤔

os.path.dirname(sysconfig.get_path("include")),
] + include_path_list
library_dirs = [sysconfig.get_path("platlib"), os.path.join(os.sys.prefix, "lib")]
cudalib_subdir = r"lib\x64" if sys.platform == "win32" else "lib64"
Copy link
Member

Choose a reason for hiding this comment

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

On the Linux side, one annoying thing is that depending on how CUDA is installed, this could be lib or lib64:

$ ls -l /usr/local/cuda-13.0/lib64/libcudart_static.a 
-rw-r--r-- 1 root root 1361104 Aug  5 09:32 /usr/local/cuda-13.0/lib64/libcudart_static.a
$ ls -l /usr/local/cuda-13.0/targets/x86_64-linux/lib/libcudart_static.a 
-rw-r--r-- 1 root root 1361104 Aug  5 09:32 /usr/local/cuda-13.0/targets/x86_64-linux/lib/libcudart_static.a

https://github.com/conda-forge/cuda-cudart-feedstock/blob/38fb08899691fa53fce33960ef37d48ab58584b0/recipe/meta.yaml#L220

https://github.com/conda-forge/cuda-cudart-feedstock/blob/38fb08899691fa53fce33960ef37d48ab58584b0/recipe/meta.yaml#L251

We probably should support both.

@Andy-Jost
Copy link
Contributor Author

/ok to test 19aaca9

@Andy-Jost
Copy link
Contributor Author

I see a failure in pre-commit.ci due to "ruff format" creating diffs. I think I get the general idea, but I don't see how to get more information (e.g., see the diffs, or run the ruff format locally). I can probably fix the formatting issue by guessing, but in general how can I get the details?

@Andy-Jost
Copy link
Contributor Author

/ok to test 19aaca9

@Andy-Jost
Copy link
Contributor Author

/ok to test 26da853

@Andy-Jost Andy-Jost force-pushed the fix/add-library-path-check branch from 26da853 to 73acddf Compare August 19, 2025 21:42
@Andy-Jost
Copy link
Contributor Author

/ok to test 73acddf

@github-project-automation github-project-automation bot moved this from Needs Triage to In Review in CCCL Aug 19, 2025
@Andy-Jost Andy-Jost merged commit 72e7791 into NVIDIA:main Aug 19, 2025
48 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Aug 19, 2025
@Andy-Jost Andy-Jost deleted the fix/add-library-path-check branch August 19, 2025 22:24
Copy link

Doc Preview CI
Preview removed because the pull request was closed or merged.

@leofang
Copy link
Member

leofang commented Aug 20, 2025

@copilot please backport this PR to the 12.9.x branch. (Since this PR touched some files in the .github folder, the backport bot does not work.)

@leofang leofang mentioned this pull request Aug 20, 2025
@leofang leofang added to-be-backported Trigger the bot to raise a backport PR upon merge and removed enhancement Any code-related improvements labels Aug 20, 2025
Copy link

Git push to origin failed for 12.9.x with exitcode 1

@leofang leofang added the enhancement Any code-related improvements label Aug 20, 2025
Copy link

Git push to origin failed for 12.9.x with exitcode 1

Copilot AI added a commit that referenced this pull request Aug 21, 2025
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
Andy-Jost added a commit that referenced this pull request Aug 21, 2025
…bc-85a8c5353e08

Backport PR #837: Add path for CUDA static library based on CUDA_HOME
@cpcloud cpcloud mentioned this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements P1 Medium priority - Should do to-be-backported Trigger the bot to raise a backport PR upon merge

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Ensure cuda_static's directory is passed to setuptools

4 participants