Skip to content

Commit 41117bc

Browse files
myli5claude
authored andcommitted
Chapter 9 cuGraph: update install pins and add CUDA library preload
The notebook pinned cudf-cu12 and cugraph-cu12 to 24.10, which has no wheels for current Python versions, and nx-cugraph-cu12 was unpinned so it could resolve to a version out of step with the rest of RAPIDS. - Pin cudf-cu12 / cugraph-cu12 to 26.8.* and nx-cugraph-cu12 to 26.8.*. - Add a cell that pre-loads the RAPIDS nvidia/* CUDA math libraries with RTLD_GLOBAL before importing cugraph, avoiding "ImportError: libnvrtc.so.12: cannot open shared object file" on pip wheel installs. It is a no-op on a correctly configured environment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e189b55 commit 41117bc

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

Accelerated_Python_User_Guide/notebooks/Chapter_09_Intro_to_cuGraph.ipynb

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@
9090
},
9191
"outputs": [],
9292
"source": [
93+
"# Install a cudf / cugraph build that matches this environment's CUDA and Python.\n",
94+
"# The 24.10 pin in the original notebook is far too old (no wheels for recent\n",
95+
"# Python); use a current RAPIDS release instead.\n",
9396
"!pip install \\\n",
9497
" --extra-index-url=https://pypi.nvidia.com \\\n",
95-
" cudf-cu12==24.10.* cugraph-cu12==24.10.* "
98+
" \"cudf-cu12==26.8.*\" \"cugraph-cu12==26.8.*\""
9699
]
97100
},
98101
{
@@ -153,6 +156,39 @@
153156
"Node 2 connects back to Node 0"
154157
]
155158
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": null,
162+
"id": "b629fc39",
163+
"metadata": {},
164+
"outputs": [],
165+
"source": [
166+
"# --- Environment workaround -------------------------------------------------\n",
167+
"# Some RAPIDS pip wheels ship their CUDA math libraries (libnvrtc, cuBLAS, ...)\n",
168+
"# inside `nvidia/*` packages but don't always register them with the dynamic\n",
169+
"# loader before cuGraph's compiled extensions are imported. That shows up as\n",
170+
"# `ImportError: libnvrtc.so.12: cannot open shared object file`.\n",
171+
"# Pre-loading those libraries into the global symbol namespace fixes it.\n",
172+
"# This is a no-op on a correctly configured environment.\n",
173+
"import ctypes, glob, os, sysconfig\n",
174+
"\n",
175+
"_sp = sysconfig.get_paths()[\"purelib\"]\n",
176+
"_lib_dirs = [\n",
177+
" \"nvidia/cuda_nvrtc/lib\", \"nvidia/nvjitlink/lib\", \"nvidia/cublas/lib\",\n",
178+
" \"nvidia/cusparse/lib\", \"nvidia/cusolver/lib\", \"nvidia/curand/lib\",\n",
179+
" \"nvidia/cufft/lib\",\n",
180+
"]\n",
181+
"for _rel in _lib_dirs:\n",
182+
" for _so in sorted(glob.glob(os.path.join(_sp, _rel, \"*.so*\"))):\n",
183+
" try:\n",
184+
" ctypes.CDLL(_so, mode=ctypes.RTLD_GLOBAL)\n",
185+
" except OSError:\n",
186+
" pass\n",
187+
"\n",
188+
"import cugraph\n",
189+
"print(\"cugraph\", cugraph.__version__)"
190+
]
191+
},
156192
{
157193
"cell_type": "code",
158194
"execution_count": null,
@@ -307,7 +343,7 @@
307343
},
308344
"outputs": [],
309345
"source": [
310-
"!pip install nx-cugraph-cu12 --extra-index-url=https://pypi.nvidia.com"
346+
"!pip install \"nx-cugraph-cu12==26.8.*\" --extra-index-url=https://pypi.nvidia.com"
311347
]
312348
},
313349
{

0 commit comments

Comments
 (0)