cugraph backend for NetworkX
Project description
ย nx-cugraph - GPU Backend for NetworkX
Description
nx-cugraph is a backend to NetworkX to run algorithms with zero code change GPU acceleration.
๐ Try it in Google Colab!
System Requirements
- GPU: NVIDIA Volta architecture or later, with compute capability 7.0+
- CUDA Version: 12.2 or higher
- Python Version: 3.10 - 3.13
- NetworkX Version: minimum 3.2 (version 3.5 or higher recommended)
Note: nx-cugraph is supported only on Linux
See RAPIDS System Requirements for detailed information on OS and Versions.
Installation
nx-cugraph can be installed using either conda or pip with the following commands.
conda
nx-cugraph can be installed with conda (via Miniforge) from the rapidsai channel.
# CUDA 13
conda install -c rapidsai -c conda-forge nx-cugraph cuda-version=13.1
# CUDA 12
conda install -c rapidsai -c conda-forge nx-cugraph cuda-verison=12.9
We also provide nightly Conda packages built from the HEAD of our latest development branch.
# CUDA 13
conda install -c rapidsai-nightly -c conda-forge nx-cugraph cuda-version=13.1
# CUDA 12
conda install -c rapidsai-nightly -c conda-forge nx-cugraph cuda-verison=12.9
pip
nx-cugraph can be installed via pip from the NVIDIA Python Package Index.
For CUDA 13.x:
Latest nightly version
python -m pip install nx-cugraph-cu13 --extra-index-url https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
Latest stable version
python -m pip install nx-cugraph-cu13 --extra-index-url https://pypi.nvidia.com
Notes:
- Try out the RAPIDS Install Selector Tool to install other RAPIDS packages.
For CUDA 12.x:
Latest nightly version
python -m pip install nx-cugraph-cu12 --extra-index-url https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
Latest stable version
python -m pip install nx-cugraph-cu12 --extra-index-url https://pypi.nvidia.com
Notes:
- Try out the RAPIDS Install Selector Tool to install other RAPIDS packages.
Enabling nx-cugraph
NetworkX will use nx-cugraph as the graph analytics backend if any of the following are used:
NX_CUGRAPH_AUTOCONFIG environment variable.
By setting NX_CUGRAPH_AUTOCONFIG=True, NetworkX will automatically dispatch algorithm calls to nx-cugraph (if the backend is supported). This allows users to GPU accelerate their code with zero code change.
Read more on Networkx Backends and How They Work.
Example:
bash> NX_CUGRAPH_AUTOCONFIG=True python my_networkx_script.py
backend= keyword argument
To explicitly specify a particular backend for an API, use the backend=
keyword argument. This argument takes precedence over the
NX_CUGRAPH_AUTOCONFIG environment variable. This requires anyone
running code that uses the backend= keyword argument to have the specified
backend installed.
Example:
nx.betweenness_centrality(cit_patents_graph, k=k, backend="cugraph")
Type-based dispatching
NetworkX also supports automatically dispatching to backends associated with
specific graph types. Like the backend= keyword argument example above, this
requires the user to write code for a specific backend, and therefore requires
the backend to be installed, but has the advantage of ensuring a particular
behavior without the potential for runtime conversions.
To use type-based dispatching with nx-cugraph, the user must import the backend directly in their code to access the utilities provided to create a Graph instance specifically for the nx-cugraph backend.
Example:
import networkx as nx
import nx_cugraph as nxcg
G = nx.Graph()
...
nxcg_G = nxcg.from_networkx(G) # conversion happens once here
nx.betweenness_centrality(nxcg_G, k=1000) # nxcg Graph type causes cugraph backend
# to be used, no conversion necessary
Supported Algorithms
The nx-cugraph backend to NetworkX connects pylibcugraph (cuGraph's low-level python interface to its CUDA-based graph analytics library) and CuPy (a GPU-accelerated array library) to NetworkX's familiar and easy-to-use API.
Below is the list of algorithms that are currently supported in nx-cugraph.
Algorithms
bipartite โโ centrality โ โโ betweenness_centrality โโ generators โ โโ complete_bipartite_graph โโ matrix โโ biadjacency_matrix โโ from_biadjacency_matrix centrality โโ betweenness โ โโ betweenness_centrality โ โโ edge_betweenness_centrality โโ degree_alg โ โโ degree_centrality โ โโ in_degree_centrality โ โโ out_degree_centrality โโ eigenvector โ โโ eigenvector_centrality โโ katz โโ katz_centrality cluster โโ average_clustering โโ clustering โโ transitivity โโ triangles community โโ leiden โ โโ leiden_communities โโ louvain โโ louvain_communities components โโ connected โ โโ connected_components โ โโ is_connected โ โโ node_connected_component โ โโ number_connected_components โโ weakly_connected โโ is_weakly_connected โโ number_weakly_connected_components โโ weakly_connected_components core โโ core_number โโ k_truss dag โโ ancestors โโ descendants isolate โโ is_isolate โโ isolates โโ number_of_isolates link_analysis โโ hits_alg โ โโ hits โโ pagerank_alg โโ pagerank link_prediction โโ jaccard_coefficient lowest_common_ancestors โโ lowest_common_ancestor operators โโ unary โโ complement โโ reverse reciprocity โโ overall_reciprocity โโ reciprocity shortest_paths โโ generic โ โโ has_path โ โโ shortest_path โ โโ shortest_path_length โโ unweighted โ โโ all_pairs_shortest_path โ โโ all_pairs_shortest_path_length โ โโ bidirectional_shortest_path โ โโ single_source_shortest_path โ โโ single_source_shortest_path_length โ โโ single_target_shortest_path โ โโ single_target_shortest_path_length โโ weighted โโ all_pairs_bellman_ford_path โโ all_pairs_bellman_ford_path_length โโ all_pairs_dijkstra โโ all_pairs_dijkstra_path โโ all_pairs_dijkstra_path_length โโ bellman_ford_path โโ bellman_ford_path_length โโ dijkstra_path โโ dijkstra_path_length โโ single_source_bellman_ford โโ single_source_bellman_ford_path โโ single_source_bellman_ford_path_length โโ single_source_dijkstra โโ single_source_dijkstra_path โโ single_source_dijkstra_path_length tournament โโ tournament_matrix traversal โโ breadth_first_search โโ bfs_edges โโ bfs_layers โโ bfs_predecessors โโ bfs_successors โโ bfs_tree โโ descendants_at_distance โโ generic_bfs_edges tree โโ recognition โโ is_arborescence โโ is_branching โโ is_forest โโ is_tree
Generators
classic โโ barbell_graph โโ circular_ladder_graph โโ complete_graph โโ complete_multipartite_graph โโ cycle_graph โโ empty_graph โโ ladder_graph โโ lollipop_graph โโ null_graph โโ path_graph โโ star_graph โโ tadpole_graph โโ trivial_graph โโ turan_graph โโ wheel_graph community โโ caveman_graph ego โโ ego_graph small โโ bull_graph โโ chvatal_graph โโ cubical_graph โโ desargues_graph โโ diamond_graph โโ dodecahedral_graph โโ frucht_graph โโ heawood_graph โโ house_graph โโ house_x_graph โโ icosahedral_graph โโ krackhardt_kite_graph โโ moebius_kantor_graph โโ octahedral_graph โโ pappus_graph โโ petersen_graph โโ sedgewick_maze_graph โโ tetrahedral_graph โโ truncated_cube_graph โโ truncated_tetrahedron_graph โโ tutte_graph social โโ davis_southern_women_graph โโ florentine_families_graph โโ karate_club_graph โโ les_miserables_graph
Other
classes โโ function โโ is_negatively_weighted โโ number_of_selfloops convert โโ from_dict_of_lists โโ to_dict_of_lists convert_matrix โโ from_pandas_edgelist โโ from_scipy_sparse_array โโ to_numpy_array โโ to_scipy_sparse_array drawing โโ layout โโ forceatlas2_layout linalg โโ graphmatrix โโ adjacency_matrix relabel โโ convert_node_labels_to_integers โโ relabel_nodes
To request nx-cugraph backend support for a NetworkX API that is not listed above, file an issue.
Contributing
If you would like to contribute to nx-cugraph, refer to the Contributing Guide
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file nx_cugraph_cu12-26.2.0.tar.gz.
File metadata
- Download URL: nx_cugraph_cu12-26.2.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4c6143b7fd5dc54f474e6beb32c721012cd62368b9c8d1664bfbe589c17d2d
|
|
| MD5 |
e70412708007e8b701babe14eb841735
|
|
| BLAKE2b-256 |
824c14b6ae938b60c57786192bce114827d68128cd1e9fb54caa78238657805e
|