Number of cores as env/context variable ? #25057
-
Is there a general way to obtain the number of cores available on the current runner, no matter the OS ? I need to pass this number to some tools I’m using to configure parallelism. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
GitHub seems has no predefined environment variables or contexts to get the number of cores. As a workaround, you can run the following commands on each OS to view the number of cores: On Windows:
OR
On Linux:
OR
On macOS:
Then you can try to get the number from the output of the command, and set an output parameter with using the number as value. In a workflow, The output parameter only can be used between the steps in a same job via the syntax steps.<step_ID>.outputs.<output_name>. If you want to share the output parameter in other jobs, you can try to use artifact to pass the output parameter across jobs. My reply in this ticket shows a simaple demo about how to pass variables/parameters acress jobs. Hope this can help you. |
Beta Was this translation helpful? Give feedback.
-
I also think this should be an intrinsic variable provided by GitHub. Here's one workflow that implements the capability using node.js: https://github.com/SimenB/github-actions-cpu-cores |
Beta Was this translation helpful? Give feedback.
GitHub seems has no predefined environment variables or contexts to get the number of cores.
As a workaround, you can run the following commands on each OS to view the number of cores:
On Windows:
OR
On Linux:
OR
On macOS:
Then you can try to get the number from the output of the command, and set an output parameter with using the number as value.
In a workflow, The output parameter only can be used between the steps in a same job via the syntax steps.<step_ID>.outputs.<out…