Skip to content

Commit

Permalink
multiprocessing with 2 cpus to not overwhelm RAM in the cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing authored Nov 30, 2023
1 parent 58401ad commit 13fb78d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions notebooks/02-routing-speed-time.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"source": [
"## 4. Multiprocessing\n",
"\n",
"Calculating lots of shortest paths can be slow, but OSMnx has built-in shortest path solver parallelization and multiprocessing. With the `shortest_path` function, you can pass in a single origin-destination pair to solve the one shortest path, or you can pass in lists of origins and destinations to solve each shortest path between the pairs. If you're solving shortest paths for multiple origins/destinations, the `cpus` argument determines how many CPU cores to utilize for parallelized solving. Multiprocessing adds some overhead, so it's only faster if you're solving a lot of paths. It also has substantial RAM requirements (as it must copy the graph into each sub-process), so be carefuly with your RAM when setting the `cpus` argument."
"Calculating lots of shortest paths can be slow, but OSMnx has built-in shortest path solver parallelization and multiprocessing. With the `shortest_path` function, you can pass in a single origin-destination pair to solve the one shortest path, or you can pass in lists of origins and destinations to solve each shortest path between the pairs. If you're solving shortest paths for multiple origins/destinations, the `cpus` argument determines how many CPU cores to utilize for parallelized solving. Multiprocessing adds some overhead, so it's only faster if you're solving a lot of paths. It also has substantial RAM requirements (as it must copy the graph into each sub-process), so be careful with your RAM when setting the `cpus` argument."
]
},
{
Expand All @@ -274,7 +274,7 @@
"%%time\n",
"# it takes 2.3 seconds to solve all the routes using all the cores on my computer\n",
"# I have a 24-thread AMD 5900x: performance will depend on your specific CPU\n",
"routes = ox.shortest_path(G, origs, dests, weight=\"travel_time\", cpus=None)"
"routes = ox.shortest_path(G, origs, dests, weight=\"travel_time\", cpus=2)"
]
},
{
Expand Down

0 comments on commit 13fb78d

Please sign in to comment.