NetworkX Introduces Zero Code Change Acceleration Using NVIDIA cuGraph

NetworkX accelerated by NVIDIA cuGraph is a newly released backend co-developed with the NetworkX team. NVIDIA cuGraph provides GPU acceleration for popular graph algorithms such as PageRank, Louvain, and betweenness centrality. Depending on the algorithm and graph size, it can significantly accelerate NetworkX workflows, up to 50x, even 500x over NetworkX on CPU. 

In this post, we share details about NetworkX and its new backend accelerator powered by cuGraph. We also discuss how to use the cuGraph backend for NetworkX, speed up your graph analytic workflows, and overcome the limitations NetworkX presents when working with large-scale graphs. 

If you’re even remotely familiar with the field of graph data science, then you’ve probably used NetworkX.  NetworkX is one of the most widely known open-source graph analytics libraries today and has over 80M downloads a month (as of 10/24). Since its initial release in 2005, NetworkX has built a reputation for its easy-to-use, intuitive API, friendly and supportive community, and wide breadth of algorithms that address almost every graph analytics use case imaginable.

However, if you’re responsible for production workflows operating on real-world–sized data, then you’ve probably realized that when a graph reaches a certain size, NetworkX must be replaced with a more performant but also more complex graph solution. 

NetworkX’s pure-Python, single-threaded implementation restricts its ability to scale. Many workflows using graphs typically larger than 100K nodes and 1M edges can result in significant slowdowns that often justify abandoning NetworkX altogether. These workloads are common with high data volumes and comparisons between millions of entities and relationships, as done in fraud detection, recommendation systems, social network analysis, supply chain optimization, and others.

Since its initial release in 2019, the cuGraph open-source project has been building solutions for data scientists looking for an easy-to-use Python graph analytics library similar to NetworkX. Now, with the addition of the cuGraph backend for NetworkX, which is the first production-ready GPU backend, you don’t have to leave NetworkX to experience material speedups. 

Video 1. Achieve Up to 500x Faster NetworkX with Zero Code Changes Using cuGraph

Unlocking speed and scale

The backend for NetworkX is powered by cuGraph, a CUDA-based library, and enables NetworkX workflows running cuGraph-supported algorithms to see a range of speedups depending on the algorithm and the graph size.

You can see up to 10x, and for other algorithms and larger graphs up to 500x faster processing. The resulting speedups not only generate results faster but unlock use cases previously considered unrealistic for NetworkX.  

Now graph data scientists can finally have both ease of use and speed at scale using NetworkX accelerated by NVIDIA cuGraph.

Zero-code-change GPU acceleration

NVIDIA cuGraph accelerates NetworkX through its backend dispatching system, which provides a standard mechanism for NetworkX to use third-party accelerators. 

Install the cuGraph backend nx-cugraph using the pip or conda package managers or from the source on a system with an NVIDIA GPU. The backend is activated through an environment variable that enables NetworkX automatic function dispatching, enabling NetworkX to send supported algorithms to the GPU backend and all others to the default NetworkX implementation on the CPU.

The result is automatic GPU acceleration for many of the most common graph algorithms used by data scientists without code changes, and without workarounds for missing functionality:

pagerank

betweenness_centrality

louvain_communities

shortest_path

And many more, approximately 60 in total

You don’t need to modify your workflows to see massive speedups on large graph data that would normally make unaccelerated NetworkX virtually unusable. Those same workflows can also be used on non-GPU systems, where smaller data and longer runtimes can be tolerated for prototyping and experimentation.

From a command line, you can experience GPU speedup by setting an environment variable in your shell, where the same algorithm call runs nearly 87x faster when cuGraph is enabled.

File: demo.ipy

import pandas as pd
import networkx as nx

url = “https://data.rapids.ai/cugraph/datasets/cit-Patents.csv”
df = pd.read_csv(url, sep=” “, names=[“src”, “dst”], dtype=”int32″)
G = nx.from_pandas_edgelist(df, source=”src”, target=”dst”)

%time result = nx.betweenness_centrality(G, k=10)

Output:

user@machine:/# ipython demo.ipy
CPU times: user 7min 36s, sys: 5.22 s, total: 7min 41s
Wall time: 7min 41s

user@machine:/# NX_CUGRAPH_AUTOCONFIG=True ipython demo.ipy
CPU times: user 4.14 s, sys: 1.13 s, total: 5.27 s
Wall time: 5.32 s

Software: NetworkX 3.4.1, cuGraph/nx-cugraph 24.10

CPU: Intel Xeon Gold 6128 CPU @ 3.40GHz 45GB RAM

GPU: NVIDIA Quadro RTX 8000 50GB RAM

In a notebook, set the environment variable using the %env magic anywhere before the initial networkx import:

%env NX_CURGAPH_AUTOCONFIG=True
import networkx as nx

Graph workloads big and small

The flexibility of NetworkX is unmatched among other graph analytics libraries, and the resulting performance is acceptable for smaller graph data used for teaching, prototyping, and generally smaller problems. 

But graphs exceeding 100K nodes and 1M edges are becoming much more common as the volume of data generated continues to grow, with enterprises expected to produce 20 ZB of data by 2027.  The cuGraph backend for NetworkX lets you have both ease of use for rapid development and the performance needed for modern workloads.

High volumes, along with multimodal data in modern workloads can be used by graphs to enrich the context and depth of analysis. Use cases where NetworkX accelerated by cuGraph is an ideal choice, involve large-scale graphs and fast processing requirements, outside the bounds of NetworkX on CPUs. 

Graph algorithms boosted by GPU acceleration can be applied to use cases such as community or fraud detection systems or recommendation systems based on millions of consumers and their relationships to tens of millions of consumer profiles, transaction patterns, and inventory data points.

The following examples show the speedups using NetworkX accelerated by cuGraph.

Louvain community detection run on a large network graph of Hollywood actors to find those appearing in movies together (1M nodes, 58M edges) is 60x faster than NetworkX on CPU.

Figure 1. Louvain community detection algorithm run on a large network graph of Hollywood actors to find those appearing in movies together

PageRank algorithm used to compute values for a citation graph of U.S. patents (4M nodes, 16M edges) is 70x faster than NetworkX on CPU

Figure 2. PageRank algorithm used to compute values for a citation graph of U.S. patents

Betweenness-centrality algorithm used to compute values for the Live Journal social network (5M nodes, 69M edges, k=100) is 485x faster than NetworkX on CPU.

Figure 3. Betweenness centrality algorithm used to compute values for the Live Journal social network

All benchmarks in this post used the following configuration:

Software: NetworkX 3.4.1, cuGraph/nx-cugraph 24.10

CPU: Intel Xeon w9-3495X (56 cores) 250GB

GPU: NVIDIA A100 80-GB

For more information about the code for the benchmarks, see the /rapidsai/cugraph GitHub repo.

Conclusion

While NetworkX has earned a reputation for being the most popular graph analytics library available, you still need performance that keeps pace with modern workflows, especially as they get more complex and datasets continue to grow rapidly.

With a single environment variable, you can use the cuGraph/nx-cugraph package to accelerate NetworkX up to 500x using NVIDIA cuGraph to tackle modern workloads without leaving the flexibility and ease of use of NetworkX.

Experience it for yourself now in the NetworkX – Easy Graph Analytics test notebook hosted on Google Colab or explore the Running Pagerank on Wikipedia with vs. without nx-cugraph end-to-end demo.

For more information, see the following resources:

NetworkX accelerated by NVIDIA cuGraph is a newly released backend co-developed with the NetworkX team. NVIDIA cuGraph provides GPU acceleration for popular graph algorithms such as PageRank, Louvain, and betweenness centrality. Depending on the algorithm and graph size, it can significantly accelerate NetworkX workflows, up to 50x, even 500x over NetworkX on CPU. 

In this post, we share details about NetworkX and its new backend accelerator powered by cuGraph. We also discuss how to use the cuGraph backend for NetworkX, speed up your graph analytic workflows, and overcome the limitations NetworkX presents when working with large-scale graphs. 

If you’re even remotely familiar with the field of graph data science, then you’ve probably used NetworkX.  NetworkX is one of the most widely known open-source graph analytics libraries today and has over 80M downloads a month (as of 10/24). Since its initial release in 2005, NetworkX has built a reputation for its easy-to-use, intuitive API, friendly and supportive community, and wide breadth of algorithms that address almost every graph analytics use case imaginable.

However, if you’re responsible for production workflows operating on real-world–sized data, then you’ve probably realized that when a graph reaches a certain size, NetworkX must be replaced with a more performant but also more complex graph solution. 

NetworkX’s pure-Python, single-threaded implementation restricts its ability to scale. Many workflows using graphs typically larger than 100K nodes and 1M edges can result in significant slowdowns that often justify abandoning NetworkX altogether. These workloads are common with high data volumes and comparisons between millions of entities and relationships, as done in fraud detection, recommendation systems, social network analysis, supply chain optimization, and others.

Since its initial release in 2019, the cuGraph open-source project has been building solutions for data scientists looking for an easy-to-use Python graph analytics library similar to NetworkX. Now, with the addition of the cuGraph backend for NetworkX, which is the first production-ready GPU backend, you don’t have to leave NetworkX to experience material speedups. 

Video 1. Achieve Up to 500x Faster NetworkX with Zero Code Changes Using cuGraph

Unlocking speed and scale

The backend for NetworkX is powered by cuGraph, a CUDA-based library, and enables NetworkX workflows running cuGraph-supported algorithms to see a range of speedups depending on the algorithm and the graph size.

You can see up to 10x, and for other algorithms and larger graphs up to 500x faster processing. The resulting speedups not only generate results faster but unlock use cases previously considered unrealistic for NetworkX.  

Now graph data scientists can finally have both ease of use and speed at scale using NetworkX accelerated by NVIDIA cuGraph.

Zero-code-change GPU acceleration

NVIDIA cuGraph accelerates NetworkX through its backend dispatching system, which provides a standard mechanism for NetworkX to use third-party accelerators. 

Install the cuGraph backend nx-cugraph using the pip or conda package managers or from the source on a system with an NVIDIA GPU. The backend is activated through an environment variable that enables NetworkX automatic function dispatching, enabling NetworkX to send supported algorithms to the GPU backend and all others to the default NetworkX implementation on the CPU.

The result is automatic GPU acceleration for many of the most common graph algorithms used by data scientists without code changes, and without workarounds for missing functionality:

pagerank

betweenness_centrality

louvain_communities

shortest_path

And many more, approximately 60 in total

You don’t need to modify your workflows to see massive speedups on large graph data that would normally make unaccelerated NetworkX virtually unusable. Those same workflows can also be used on non-GPU systems, where smaller data and longer runtimes can be tolerated for prototyping and experimentation.

From a command line, you can experience GPU speedup by setting an environment variable in your shell, where the same algorithm call runs nearly 87x faster when cuGraph is enabled.

File: demo.ipy

import pandas as pd
import networkx as nx

url = “https://data.rapids.ai/cugraph/datasets/cit-Patents.csv”
df = pd.read_csv(url, sep=” “, names=[“src”, “dst”], dtype=”int32″)
G = nx.from_pandas_edgelist(df, source=”src”, target=”dst”)

%time result = nx.betweenness_centrality(G, k=10)

Output:

user@machine:/# ipython demo.ipy
CPU times: user 7min 36s, sys: 5.22 s, total: 7min 41s
Wall time: 7min 41s

user@machine:/# NX_CUGRAPH_AUTOCONFIG=True ipython demo.ipy
CPU times: user 4.14 s, sys: 1.13 s, total: 5.27 s
Wall time: 5.32 s

Software: NetworkX 3.4.1, cuGraph/nx-cugraph 24.10

CPU: Intel Xeon Gold 6128 CPU @ 3.40GHz 45GB RAM

GPU: NVIDIA Quadro RTX 8000 50GB RAM

In a notebook, set the environment variable using the %env magic anywhere before the initial networkx import:

%env NX_CURGAPH_AUTOCONFIG=True
import networkx as nx

Graph workloads big and small

The flexibility of NetworkX is unmatched among other graph analytics libraries, and the resulting performance is acceptable for smaller graph data used for teaching, prototyping, and generally smaller problems. 

But graphs exceeding 100K nodes and 1M edges are becoming much more common as the volume of data generated continues to grow, with enterprises expected to produce 20 ZB of data by 2027.  The cuGraph backend for NetworkX lets you have both ease of use for rapid development and the performance needed for modern workloads.

High volumes, along with multimodal data in modern workloads can be used by graphs to enrich the context and depth of analysis. Use cases where NetworkX accelerated by cuGraph is an ideal choice, involve large-scale graphs and fast processing requirements, outside the bounds of NetworkX on CPUs. 

Graph algorithms boosted by GPU acceleration can be applied to use cases such as community or fraud detection systems or recommendation systems based on millions of consumers and their relationships to tens of millions of consumer profiles, transaction patterns, and inventory data points.

The following examples show the speedups using NetworkX accelerated by cuGraph.

Louvain community detection run on a large network graph of Hollywood actors to find those appearing in movies together (1M nodes, 58M edges) is 60x faster than NetworkX on CPU.

Figure 1. Louvain community detection algorithm run on a large network graph of Hollywood actors to find those appearing in movies together

PageRank algorithm used to compute values for a citation graph of U.S. patents (4M nodes, 16M edges) is 70x faster than NetworkX on CPU

Figure 2. PageRank algorithm used to compute values for a citation graph of U.S. patents

Betweenness-centrality algorithm used to compute values for the Live Journal social network (5M nodes, 69M edges, k=100) is 485x faster than NetworkX on CPU.

Figure 3. Betweenness centrality algorithm used to compute values for the Live Journal social network

All benchmarks in this post used the following configuration:

Software: NetworkX 3.4.1, cuGraph/nx-cugraph 24.10

CPU: Intel Xeon w9-3495X (56 cores) 250GB

GPU: NVIDIA A100 80-GB

For more information about the code for the benchmarks, see the /rapidsai/cugraph GitHub repo.

Conclusion

While NetworkX has earned a reputation for being the most popular graph analytics library available, you still need performance that keeps pace with modern workflows, especially as they get more complex and datasets continue to grow rapidly.

With a single environment variable, you can use the cuGraph/nx-cugraph package to accelerate NetworkX up to 500x using NVIDIA cuGraph to tackle modern workloads without leaving the flexibility and ease of use of NetworkX.

Experience it for yourself now in the NetworkX – Easy Graph Analytics test notebook hosted on Google Colab or explore the Running Pagerank on Wikipedia with vs. without nx-cugraph end-to-end demo.

For more information, see the following resources:

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

Spotlight: TCS Increases Automotive Software Testing Speeds by 2x Using NVIDIA Generative AI

Generative AI is transforming every aspect of the automotive industry, including software development, testing, user experience, personalization, and safety. With the automotive industry shifting...

An Open World RPG Launches on Xbox Series After Long Wait!

And this game will take up quite a bit of space, so...

AMD crafts custom EPYC CPU with HBM3 memory for Microsoft Azure – CPU with 88 Zen 4 cores and 450GB of HBM3 may be...

Microsoft announced its latest high performance computing (HPC) Azure virtual machines powered by a custom AMD CPU that may have once been called MI300C.The...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!