# num_cpus

> Count the CPUs on the current machine from Rust

Source: https://talira.ai/catalog/num-cpus-8mb5q24j
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / system information](https://talira.ai/categories/libraries/system-information), [languages / rust](https://talira.ai/categories/languages/rust)
- Licence: MIT OR Apache-2.0[^1]
- Pricing: Free and open source[^2]
- Free tier: yes[^2]
- Backed by: [Sean McArthur](https://talira.ai/orgs/sean-mcarthur.md)

num_cpus is a small Rust crate that counts the CPUs on the current machine. num_cpus::get() returns the logical cores the process could use, taking Linux scheduler affinity and cgroups into account, so it reports the smaller number a container is limited to, and get_physical() returns physical cores. Sean McArthur wrote it.

## Links

- GitHub: https://github.com/seanmonstar/num_cpus
- Docs: https://docs.rs/num_cpus

## Problems it solves

- find out how many CPU cores my Rust program can use
- size a Rust thread pool to the CPUs a container is limited to
- get the number of physical rather than logical cores in Rust

## Features

- logical CPU count
- physical core count
- respects Linux sched affinity
- respects cgroup CPU limits in containers

## Limitations

- The CPU count is only a rough guide to how many tasks can run in parallel.[^1]

## Trust

Overall: 0.34 out of 1.
Signals: maintenance 0.27, adoption 0.56, momentum 0.22, community 0.70, backing 0.30, extensibility 0.00.

- latest release v1.16.0 3.4 years ago
- 625 GitHub stars
- 56 contributors
- accepts sponsorship (Github, Patreon)
- backed by Sean McArthur

Warnings:

- last commit 10 months ago

## Sources

[^1]: https://github.com/seanmonstar/num_cpus/blob/master/src/lib.rs (checked 28 Nov 2026)
[^2]: https://github.com/seanmonstar/num_cpus/blob/master/Cargo.toml (checked 28 Nov 2026)
