Hardware Query
A cross-platform Rust library for querying detailed system hardware information.
Features
- ✅ Cross-platform hardware detection (Windows, Linux, macOS)
- ✅ Detailed CPU information (cores, threads, cache, features)
- ✅ GPU detection and capabilities (CUDA, ROCm, DirectML support)
- ✅ Memory configuration and status
- ✅ Storage device enumeration and properties
- ✅ Network interface detection and capabilities
- ✅ Hardware acceleration support detection
- ✅ Battery status and health monitoring
- ✅ Thermal sensors and fan control (where available)
- ✅ PCI/USB device enumeration
- ✅ Serializable hardware information
Quick Start
Add this to your Cargo.toml
:
[]
= "0.1.0"
Usage
use HardwareInfo;
Specialized Hardware Support
The library provides comprehensive detection for AI/ML-oriented hardware:
- NPUs: Intel Movidius, GNA, XDNA; Apple Neural Engine; Qualcomm Hexagon
- TPUs: Google Cloud TPU and Edge TPU; Intel Habana
- ARM Systems: Raspberry Pi, NVIDIA Jetson, Apple Silicon with power management
- FPGAs: Intel/Altera and Xilinx families with AI optimization scoring
use HardwareInfo;
let hw_info = query?;
// Check for specialized AI hardware
for npu in hw_info.npus
for tpu in hw_info.tpus
Platform Support
Platform | CPU | GPU | Memory | Storage | Network | Battery | Thermal | PCI | USB |
---|---|---|---|---|---|---|---|---|---|
Windows | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Linux | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
macOS | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Optional Features
Enable additional GPU support with feature flags:
[]
= { = "0.1.0", = ["nvidia", "amd", "intel"] }
nvidia
: NVIDIA GPU support via NVMLamd
: AMD GPU support via ROCmintel
: Intel GPU support
Examples
See the examples directory for complete usage examples:
- Basic Hardware Detection
- Comprehensive Hardware
- Enhanced Hardware
- Advanced Usage
- Comprehensive AI Hardware
Building
# Build with default features
# Build with GPU support
# Run tests
# Run examples
Dependencies
sysinfo
- Cross-platform system informationserde
- Serialization frameworkthiserror
- Error handlingnum_cpus
- CPU core detection
Optional Dependencies
nvml-wrapper
- NVIDIA GPU support (feature: nvidia)wmi
- Windows Management Instrumentation (Windows only)libc
- Linux system calls (Linux only)core-foundation
- macOS system APIs (macOS only)
Performance
The library is designed for performance with:
- Lazy evaluation of hardware information
- Minimal system calls
- Efficient data structures
- Optional caching for repeated queries
Typical query times:
- Complete hardware scan: 10-50ms
- CPU information: 1-5ms
- GPU information: 5-20ms
- Memory information: 1-3ms
Error Handling
The library uses comprehensive error handling:
use ;
match query
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT OR Apache-2.0 License - see the LICENSE-MIT and LICENSE-APACHE files for details.
Acknowledgments
- Built on top of the excellent
sysinfo
crate - Inspired by the need for better hardware detection in AI workload placement
- Thanks to all contributors who helped improve cross-platform compatibility