Skip to content

Commit

Permalink
fixed timing output
Browse files Browse the repository at this point in the history
  • Loading branch information
acostadon committed May 28, 2024
1 parent eb7faa1 commit 2f830cb
Showing 1 changed file with 58 additions and 28 deletions.
86 changes: 58 additions & 28 deletions notebooks/cugraph_benchmarks/nx_cugraph_codeless_switching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,26 @@
"* Bredth first Search\n",
"* Louvain community detection\n",
"\n",
"and collect times. it is completely unaware of cugraph or GPU-based tools.\n",
"and report times. it is completely unaware of cugraph or GPU-based tools.\n",
"[NetworkX configurations](https://networkx.org/documentation/stable/reference/utils.html#backends) can determine how they are run."
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def run_algos(G):\n",
" print()\n",
" print (\"Betweenness Centrality time\")\n",
" %time\n",
" runtime = time.time()\n",
" result = nx.betweenness_centrality(G, k=10)\n",
" print()\n",
" print (\"Breadth First Search time\")\n",
" %time\n",
" print (\"Betweenness Centrality time: \" + str(round(time.time() - runtime))+ \" seconds\")\n",
" runtime = time.time()\n",
" result = nx.bfs_tree(G,source=1)\n",
" print()\n",
" print (\"Louvain time\")\n",
" %time\n",
" print (\"Breadth First Search time: \" + str(round(time.time() - runtime))+ \" seconds\")\n",
" runtime = time.time()\n",
" result = nx.community.louvain_communities(G,threshold=1e-04)\n",
" print()\n",
" print (\"Louvain time: \" + str(round(time.time() - runtime))+ \" seconds\")\n",
" return"
]
},
Expand Down Expand Up @@ -160,8 +156,8 @@
"source": [
"Setting the NetworkX dispatcher with an environment variable or in code using NetworkX config package which is new to [NetworkX 3.3 config](https://networkx.org/documentation/stable/reference/backends.html#networkx.utils.configs.NetworkXConfig).\n",
"\n",
"These convenience settinge allow turning off caching and cugraph dispatching if you want to see how long cpu-only would take.\n",
"In this example using an AMD Ryzen Threadripper PRO 3975WX 32-Cores cpu raised the run time to over 40 minutes."
"These convenience settinge allow turning off caching and cugraph dispatching if you want to see how long cpu-only takes.\n",
"This example using an AMD Ryzen Threadripper PRO 3975WX 32-Cores cpu completed in slightly over 40 minutes."
]
},
{
Expand Down Expand Up @@ -209,28 +205,40 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"name": "stderr",
"output_type": "stream",
"text": [
"/home/dacosta/anaconda3/envs/cugraph_24_06_nx_run/lib/python3.11/site-packages/networkx/utils/backends.py:1128: UserWarning: Using cached graph for 'cugraph' backend in call to betweenness_centrality.\n",
"\n",
"For the cache to be consistent (i.e., correct), the input graph must not have been manually mutated since the cached graph was created. Examples of manually mutating the graph data structures resulting in an inconsistent cache include:\n",
"\n",
" >>> G[u][v][key] = val\n",
"\n",
"and\n",
"\n",
"Betweenness Centrality time\n",
"CPU times: user 6 µs, sys: 1e+03 ns, total: 7 µs\n",
"Wall time: 9.3 µs\n",
" >>> for u, v, d in G.edges(data=True):\n",
" ... d[key] = val\n",
"\n",
"Breadth First Search time\n",
"CPU times: user 3 µs, sys: 0 ns, total: 3 µs\n",
"Wall time: 7.15 µs\n"
"Using methods such as `G.add_edge(u, v, weight=val)` will correctly clear the cache to keep it consistent. You may also use `G.__networkx_cache__.clear()` to manually clear the cache, or set `G.__networkx_cache__` to None to disable caching for G. Enable or disable caching via `nx.config.cache_converted_graphs` config.\n",
" warnings.warn(warning_message)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Betweenness Centrality time - 1 seconds\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/dacosta/anaconda3/envs/cugraph_24_06_nx_run/lib/python3.11/site-packages/networkx/utils/backends.py:1101: UserWarning: Using cached graph for 'cugraph' backend in call to bfs_edges.\n",
"/home/dacosta/anaconda3/envs/cugraph_24_06_nx_run/lib/python3.11/site-packages/networkx/utils/backends.py:1128: UserWarning: Using cached graph for 'cugraph' backend in call to bfs_edges.\n",
"\n",
"For the cache to be consistent (i.e., correct), the input graph must not have been manually mutated since the cached graph was created. Examples of manually mutating the graph data structures resulting in an inconsistent cache include:\n",
"\n",
Expand All @@ -249,14 +257,36 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Breadth First Search time - 47 seconds\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/dacosta/anaconda3/envs/cugraph_24_06_nx_run/lib/python3.11/site-packages/networkx/utils/backends.py:1101: UserWarning: Using cached graph for 'cugraph' backend in call to louvain_communities.\n",
"\n",
"For the cache to be consistent (i.e., correct), the input graph must not have been manually mutated since the cached graph was created. Examples of manually mutating the graph data structures resulting in an inconsistent cache include:\n",
"\n",
" >>> G[u][v][key] = val\n",
"\n",
"and\n",
"\n",
"Louvain time\n",
"CPU times: user 4 µs, sys: 0 ns, total: 4 µs\n",
"Wall time: 8.34 µs\n",
" >>> for u, v, d in G.edges(data=True):\n",
" ... d[key] = val\n",
"\n",
"Using methods such as `G.add_edge(u, v, weight=val)` will correctly clear the cache to keep it consistent. You may also use `G.__networkx_cache__.clear()` to manually clear the cache, or set `G.__networkx_cache__` to None to disable caching for G. Enable or disable caching via `nx.config.cache_converted_graphs` config.\n",
" warnings.warn(warning_message)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Louvain time - 10 seconds\n",
"Total Algorithm run time\n",
"CPU times: user 1min 26s, sys: 6.63 s, total: 1min 33s\n",
"Wall time: 1min 33s\n"
"CPU times: user 52.6 s, sys: 5.78 s, total: 58.3 s\n",
"Wall time: 58.3 s\n"
]
}
],
Expand Down

0 comments on commit 2f830cb

Please sign in to comment.