Galapagos only using single core

When running Galapagos on my Windows PC it only utilizes one single core. The same script on my MacBook uses all cores. What am I missing here?

This is what my CPU utilization looks like on my Mac:

Rhino 8 SR3 2024-1-9 (Rhino 8, 8.3.24009.15001, Git hash:master @ 3541fa287a013b0f17849f0740f1e43a44031bfc)
License type: Educational Lab License, build 2024-01-09
License details: LAN Zoo Network Node

Windows 11 (10.0.22631 SR0.0) or greater (Physical RAM: 64Gb)
.NET 7.0.0

Computer platform: DESKTOP 

Standard graphics configuration.
  Primary display and OpenGL: NVIDIA RTX A4000 (NVidia) Memory: 16GB, Driver date: 10-18-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 537.70
    > Accelerated graphics device with 4 adapter port(s)
        - Windows Main Display attached to adapter port #0

Secondary graphics devices.
  Intel(R) UHD Graphics 770 (Intel) Memory: 1GB, Driver date: 11-7-2023 (M-D-Y).
    > Integrated graphics device with 4 adapter port(s)
        - There are no monitors attached to this device!

OpenGL Settings
  Safe mode: Off
  Use accelerated hardware modes: On
  Redraw scene when viewports are exposed: On
  Graphics level being used: OpenGL 4.6 (primary GPU's maximum)
  
  Anti-alias mode: 4x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: High
  
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 10-18-2023
  Driver Version: 31.0.15.3770
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 16376 MB

Rhino plugins that do not ship with Rhino
  C:\Users\r.neumerkel\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\Karamba3D\3.0.6-pre\Karamba3D_LicensePlugin_Rhino8.rhp	"Karamba3DLicense"	

Rhino plugins that ship with Rhino
  C:\Program Files\Rhino 8\Plug-ins\Commands.rhp	"Commands"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\rdk.rhp	"Renderer Development Kit"	
  C:\Program Files\Rhino 8\Plug-ins\RhinoRenderCycles.rhp	"Rhino Render"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\rdk_etoui.rhp	"RDK_EtoUI"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\NamedSnapshots.rhp	"Snapshots"	
  C:\Program Files\Rhino 8\Plug-ins\MeshCommands.rhp	"MeshCommands"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\IronPython\RhinoDLR_Python.rhp	"IronPython"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\RhinoCycles.rhp	"RhinoCycles"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\Grasshopper\GrasshopperPlugin.rhp	"Grasshopper"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\RhinoCode\RhinoCodePlugin.rhp	"RhinoCodePlugin"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\Toolbars\Toolbars.rhp	"Toolbars"	8.3.24009.15001
  C:\Program Files\Rhino 8\Plug-ins\3dxrhino.rhp	"3Dconnexion 3D Mouse"	
  C:\Program Files\Rhino 8\Plug-ins\Displacement.rhp	"Displacement"	
  C:\Program Files\Rhino 8\Plug-ins\SectionTools.rhp	"SectionTools"	


Hard to tell without seeing the actual definition.

But Galapagos is simply running over and over your definition.
Galapagos itself is not using much of the cpu (probably its math is really inexpensive).

so…

Is your definition multithreaded?
Most of Rhino and Grasshopper components run single-threaded.
If you manually move around the sliders, how many cpu cores are being used?

It’s strange that your definition run single-threaded on Windows but Multi-threaded on Mac.
Too strange.

Does it actually run quicker on Mac than on Windows? Time-wise.

… are you using Karamba?
Maybe some Karamba setting have it being multithreaded on Mac, but the same setting is single-threaded on Windows?
Maybe this setting exist outside Rhino… (never used karamba…)

Sounds like a task that can easily be run in parallel…

Yes, it finishes faster on my Mac than on the PC (PC has a CPU with a near maf of 200W).

Yes

No. That’s not how Galapagos solver works.
Galapagos is not brute-forcing any possible input combination, but instead it is making attempts heuristically checking the resulting “fitness” at each attempt. It have to be sequential in a way or another.

Please turn on the profiler and check the karamba component alone: is it using a single thread? Win? Mac?

Again my guess is that you have to look for karamba setting outside Rhino. I think they are set up differently from win to Mac.

from Evolutionary Principles applied to Problem Solving | I Eat Bugs For Breakfast

As the solver starts it has no idea about the actual shape of the fitness landscape. Indeed, if we knew the shape we wouldn’t need to bother with all this messy evolutionary stuff in the first place. So the initial step of the solver is to populate the landscape (or “model-space”) with a random collection of individuals (or “genomes”). A genome is nothing more than a specific value for each and every gene. In the above case, a genome could for example be {A=0.2 B=0.5}.

I am a complete beginner in this topic, but couldn’t Galapagos hand the computation of each genome to a core? And say compute 16 genomes at once?

This is going OT.
(Have you solved the mistery why in one of your system it is going multithreaded and in another one not? Report please, this might be handy if someone else have the same problem…)


… current Galapagos implementation on Grasshopper do not do that. But I may be wrong.

From what I understand, Galapagos operate “externally” to normal grasshopper flow:
2024-01-28 15_04_40-Window
Normally GH data flow left to right. But galapagos isn’t inside that flow.

It’s like an external guy that:

  • move sliders (genome) to make a new attempt
  • take note of the results (fitness)
  • consider the past results and evaluate which new attempt to do
  • repeat

Any attempt is a single attempt.

Your best option is to optimize your code so it is run faster, so Galapagos make new attempts faster… or to look for another solver, alternative to Galapagos…

@DavidRutten please correct me …

No, not yet. But I can say that Karamba itself runs 4x faster on my PC workstation than on my MacBook

Although a few native components in GH1 are multi-threaded, the GH1 solver and Galapagos are not. So unless that file uses plug-in components which behave different on Mac than on Windows I don’t see where the multi-threading could possibly come from.

And yes, running the solver simultaneously during a Galapagos run would be quite possible in theory, GH1 is not threadsafe in any way and plug-ins are not expected to be thread-safe either. So running multiple gh documents at the same time in the same instance of Rhino is a recipe for disaster.

GH2 is fundamentally more multithreaded on a component level, but hopefully that just means that all cores will be occupied speeding up individual iterations, rather than running multiple ones simultaneously.

There’s no Galapagos equivalent yet for GH2 though…

2 Likes