Skip to content

fix(deps): add explicit cufile dependency#1552

Closed
gforsyth wants to merge 1 commit into
NVIDIA:mainfrom
gforsyth:explicit_cufile_dep
Closed

fix(deps): add explicit cufile dependency#1552
gforsyth wants to merge 1 commit into
NVIDIA:mainfrom
gforsyth:explicit_cufile_dep

Conversation

@gforsyth

Copy link
Copy Markdown
Contributor

Description

Testing a smaller base CI image for wheel tests in #1548 -- that image does not have cuda toolkit installed and we rely on installing all dependencies from wheels.
That test bubbled up a missing cufile dependency (which was previously satisfied by the libcufile.so that was present on the CI image already).

I've also added in a workaround for a bug with the cufile wheels on ARM64, where they fail to load required dynamic libraries.

We had to make the same changes in rapidsai/kvikio#1000

xref rapidsai/build-planning#143

CI run before this change: https://github.com/NVIDIA/cuopt/actions/runs/29044331506/job/86218256034?pr=1548

And after this change: https://github.com/NVIDIA/cuopt/actions/runs/29054246782/job/86246625279?pr=1548

Checklist

  • I am familiar with the Contributing Guidelines.
  • Testing
    • New or existing tests cover these changes
    • Added tests
    • Created an issue to follow-up
    • NA
  • Documentation
    • The documentation is up to date with these changes
    • Added new documentation
    • NA

@gforsyth gforsyth requested a review from a team as a code owner July 10, 2026 13:05
@gforsyth gforsyth added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Jul 10, 2026
@gforsyth gforsyth requested a review from a team as a code owner July 10, 2026 13:05
@gforsyth gforsyth requested a review from KyleFromNVIDIA July 10, 2026 13:05
@gforsyth gforsyth added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Jul 10, 2026
@gforsyth gforsyth requested a review from tmckayus July 10, 2026 13:05
@gforsyth gforsyth linked an issue Jul 10, 2026 that may be closed by this pull request
@gforsyth

Copy link
Copy Markdown
Contributor Author

Ah, this is not necessary -- I just clocked that the cufile loading error is bubbling up from libkvikio, so I'll go put in additional fixes there

@gforsyth gforsyth closed this Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The dependency matrix now includes cuFile packages and CUDA toolkit components, while the Python package declares cuda-pathfinder. Library initialization loads the cuFile dynamic library and globally opens librt.so.1.

cuFile support

Layer / File(s) Summary
Configure cuFile dependencies
dependencies.yaml, python/libcuopt/pyproject.toml
Adds cuda-pathfinder, includes cufile in CUDA 12 and CUDA 13 toolkit wheels, and defines the test_cufile dependency group.
Load cuFile at runtime
python/libcuopt/libcuopt/load.py
Loads the cuFile dynamic library and explicitly opens librt.so.1 with global symbol visibility during library initialization.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: msarahan, ramakrishnap-nv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding an explicit cufile dependency.
Description check ✅ Passed The description directly matches the changeset and explains the cufile dependency addition and ARM64 workaround.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/libcuopt/libcuopt/load.py`:
- Around line 49-53: Scope the librt.so.1 preload workaround in load_library()
to aarch64 only, using platform architecture detection, and wrap
ctypes.CDLL("librt.so.1", mode=ctypes.RTLD_GLOBAL) in a dedicated try/except
OSError. Allow loading to continue through existing fallbacks when the preload
is unavailable, while retaining the subsequent load_nvidia_dynamic_lib("cufile")
behavior.
- Around line 41-54: Separate the cuda.pathfinder import and cufile-specific
loading from the main core-library load block in the module’s load routine. Keep
rapids_logger, librmm, and libraft imports and load_library calls in the
existing guarded block, then add a subsequent guarded block for
load_nvidia_dynamic_lib, the librt workaround, and cufile loading so a missing
cuda-pathfinder does not prevent core libraries from loading.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cdc462e5-8865-4b5c-9b91-88306ae2dc2e

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4ea7e and fa151bb.

📒 Files selected for processing (3)
  • dependencies.yaml
  • python/libcuopt/libcuopt/load.py
  • python/libcuopt/pyproject.toml

Comment on lines 41 to 54
import libraft
import librmm
import rapids_logger
from cuda.pathfinder import load_nvidia_dynamic_lib

rapids_logger.load_library()
librmm.load_library()
libraft.load_library()
# We manually load librt.so.1 here to workaround a bad dynamic link
# in nvidia_cufile-1.15.1.6-py3-none-manylinux_2_27_aarch64.whl
# https://nvbugspro.nvidia.com/bug/6425783
ctypes.CDLL("librt.so.1", mode=ctypes.RTLD_GLOBAL)
load_nvidia_dynamic_lib("cufile")
except ModuleNotFoundError:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: check if cuda-pathfinder is referenced anywhere outside dependencies.yaml (e.g. conda recipes)
rg -n "cuda-pathfinder|cuda_pathfinder" --type=yaml -g '!dependencies.yaml'
fd -a meta.yaml -x cat {}

Repository: NVIDIA/cuopt

Length of output: 150


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== load.py ==\n'
sed -n '1,140p' python/libcuopt/libcuopt/load.py

printf '\n== dependencies.yaml matches ==\n'
rg -n -C 3 "cuda-pathfinder|cuda_pathfinder|requirements|pyproject|conda" dependencies.yaml

printf '\n== any packaging files mentioning cuda-pathfinder ==\n'
rg -n "cuda-pathfinder|cuda_pathfinder" -g '!dependencies.yaml' .

Repository: NVIDIA/cuopt

Length of output: 21481


Move the cuda.pathfinder import out of the core load block. In python/libcuopt/libcuopt/load.py:41-54, a missing cuda-pathfinder turns the whole try into a no-op, so rapids_logger, librmm, and libraft never load on conda installs. Split the cufile-specific import/workaround into its own guarded block after the core loads.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/libcuopt/libcuopt/load.py` around lines 41 - 54, Separate the
cuda.pathfinder import and cufile-specific loading from the main core-library
load block in the module’s load routine. Keep rapids_logger, librmm, and libraft
imports and load_library calls in the existing guarded block, then add a
subsequent guarded block for load_nvidia_dynamic_lib, the librt workaround, and
cufile loading so a missing cuda-pathfinder does not prevent core libraries from
loading.

Comment on lines +49 to +53
# We manually load librt.so.1 here to workaround a bad dynamic link
# in nvidia_cufile-1.15.1.6-py3-none-manylinux_2_27_aarch64.whl
# https://nvbugspro.nvidia.com/bug/6425783
ctypes.CDLL("librt.so.1", mode=ctypes.RTLD_GLOBAL)
load_nvidia_dynamic_lib("cufile")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Unscoped, unguarded librt.so.1 preload.

The comment explains this workaround is for nvidia_cufile-1.15.1.6-py3-none-manylinux_2_27_aarch64.whl, but ctypes.CDLL("librt.so.1", mode=ctypes.RTLD_GLOBAL) runs unconditionally on every architecture, and its OSError is not caught (only ModuleNotFoundError is handled by the surrounding except). If librt.so.1 is absent on some system, this raises out of load_library() uncaught, whereas before this change library loading degraded gracefully via the various fallbacks (system installation / wheel installation) elsewhere in this function.

Consider gating this preload to aarch64 (matching the referenced bug) and wrapping it in its own try/except OSError so a missing librt.so.1 doesn't hard-fail library loading.

🛠️ Proposed fix to scope and guard the workaround
-        # We manually load librt.so.1 here to workaround a bad dynamic link
-        # in nvidia_cufile-1.15.1.6-py3-none-manylinux_2_27_aarch64.whl
-        # https://nvbugspro.nvidia.com/bug/6425783
-        ctypes.CDLL("librt.so.1", mode=ctypes.RTLD_GLOBAL)
-        load_nvidia_dynamic_lib("cufile")
+        if platform.machine() in ("aarch64", "arm64"):
+            # We manually load librt.so.1 here to workaround a bad dynamic link
+            # in nvidia_cufile-1.15.1.6-py3-none-manylinux_2_27_aarch64.whl
+            # https://nvbugspro.nvidia.com/bug/6425783
+            try:
+                ctypes.CDLL("librt.so.1", mode=ctypes.RTLD_GLOBAL)
+            except OSError:
+                pass
+        load_nvidia_dynamic_lib("cufile")

(requires import platform at the top of the file)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/libcuopt/libcuopt/load.py` around lines 49 - 53, Scope the librt.so.1
preload workaround in load_library() to aarch64 only, using platform
architecture detection, and wrap ctypes.CDLL("librt.so.1",
mode=ctypes.RTLD_GLOBAL) in a dedicated try/except OSError. Allow loading to
continue through existing fallbacks when the preload is unavailable, while
retaining the subsequent load_nvidia_dynamic_lib("cufile") behavior.

@github-actions

Copy link
Copy Markdown

CI Test Summary

✅ All 31 test job(s) passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant