python/2_CoreConcepts/pageRank/README.md
Known issue — version-pinned sample. Unlike the other samples in this repository, this sample is pinned to
cuda-core<1.0.0. The reason is thatcudf-cu13transitively requiresnumba-cuda<0.29.0, and everynumba-cudarelease in that range pinscuda-core<1.0.0. Installing this sample'srequirements.txtinto a shared environment will downgradecuda-coreand break the other samples (which use the 1.0 API).The recommended workflow is one of:
- Install this sample's requirements in a dedicated virtual environment, or
- Re-run the other samples'
pip install -r requirements.txtafterwards to upgradecuda-coreback to 1.0.This sample will be re-aligned with the rest of the repository (
cuda-core>=1.0.0) oncecudf-cu13ships a release that lifts itsnumba-cudaupper bound.
Demonstrates GPU-accelerated PageRank computation for graph analysis using RAPIDS cuGraph, with cuda.core for device, stream, and GPU timing. This sample focuses on cuda.core integration with high-level libraries (cuGraph/cuDF); for custom kernel programming (Program, LaunchConfig, launch), see the blockwiseSum sample.
cugraph - RAPIDS GPU-accelerated graph analyticscudf - RAPIDS GPU DataFrame librarycuda.core - Device, stream, and event APIs for GPU timingcupy - GPU array library (Stream.from_external for cuDF/cuGraph)numpy - CPU reference implementationDevice(0) - Create device, device.set_current(), device.create_stream()EventOptions(enable_timing=True) - GPU timing via stream.record()cp.cuda.Stream.from_external(stream).use() - Make cuDF/cuGraph use cuda.core streamcugraph.Graph(directed=True) - Create directed graph structureGraph.from_cudf_edgelist() - Build graph from edge list DataFramecugraph.pagerank() - GPU-accelerated PageRank algorithmcudf.DataFrame() - GPU DataFrame for edge listsThis sample depends on RAPIDS (cugraph-cu13, cudf-cu13, dask-cuda),
which is currently published only as Linux (manylinux) wheels on
pypi.nvidia.com — no Windows wheels exist. On Windows the sample exits
early with a waive message and exit code 2 instead of attempting an
install that cannot succeed.
cd /path/to/cuda-samples/python/2_CoreConcepts/pageRank
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python pageRank.py
The PageRank formula iteratively computes node importance:
PR(v) = (1-d)/N + d * Σ PR(u)/out_degree(u)
Where:
d = damping factor (typically 0.85)N = total number of nodesu that link to v============================================================
PageRank Algorithm (using RAPIDS cuGraph)
============================================================
Device: NVIDIA GeForce RTX ...
Compute Capability: sm_XX
Graph Parameters:
Nodes: 10,000
Avg edges/node: 15
Total edges: ~150,000
Avg in-degree: 14.9
------------------------------------------------------------
GPU PageRank (RAPIDS cuGraph)
------------------------------------------------------------
Time: X.XXX ms
Top 5 nodes by PageRank:
1. Node XXXXX: 0.XXXXXX
...
------------------------------------------------------------
CPU PageRank (Reference)
------------------------------------------------------------
Time: XXXX.XXX ms
Iterations: XX
------------------------------------------------------------
PERFORMANCE SUMMARY
------------------------------------------------------------
GPU (cuGraph): X.XXX ms
CPU (Reference): XXXX.XXX ms
Speedup: XXXX.Xx
------------------------------------------------------------
VERIFICATION
------------------------------------------------------------
GPU vs CPU PageRank scores: Test PASSED
PageRank Properties:
Sum of scores: 1.000000 (should be ~1.0)
Sum check: ✓
Done
pageRank.py - Python implementation using RAPIDS cuGraphREADME.md - This filerequirements.txt - Sample dependenciesRAPIDS cuGraph provides production-grade, GPU-accelerated graph analytics: