# GNI
GPU Node ID (GNI) is a rust based library for creating an identifier for the set of GPUs running on the host. The ID is generated by hashing (blake3) all GPU UUIDs sorted lexicographically. GNI provides a consistent implementation for calculating and retrieving the ID, with bindings to a set of languages (Python, Go, C, CPP) to ensure a consistent and startardized approach to using this ID.
## Multi-Language Support
GNI offers the same core functionality for each supported language, provides bindings, and you can build from source for:
- [c](/src/c/README.md)
- [cpp](/src/cpp/README.md)
- [go](/src/go/README.md)
- [python](/src/python/README.md)
- [rust](./README.md#rust-library) see below
> Note: If you’d like support for another language, please open an issue or submit a pull request!
## Rust Library
GNI is available on [crates.io](https://crates.io/crates/gni), you should be able to call it from your Rust code:
```
let result = gni_lib::get_gpu_node_id(None);
println!("GPU Node ID: {:?}", result);
# stdout: GPU Node ID: Ok(<id>)
```
```
# Don't forget to add as a dependency on Cargo.toml
...
[dependencies]
gni = "0.1.0"
...
```
## Rust Build and Running GNI from source
### Prerequisites
- Rust & Cargo: Make sure you have a recent version of Rust (and the built-in Cargo tool) installed. You can check by running:
```
$ rustc --version
$ cargo --version
```
If you need to install Rust, visit [rustup.rs](https://rustup.rs/).
### Build
```bash
$ cargo build
```
See build artifacts in the target/debug directory.
### Run
```bash
$ cargo run
...
Usage: gni [OPTIONS]
Options:
-c, --cache-filepath <CACHE_FILEPATH> Filepath to cache ID [default: /tmp/gni]
-s, --stdout Print ID to stdout
-h, --help Print help
-V, --version Print version
```
## Contributing
Read our contributing guide to learn about our development process, how to propose bugfixes and feature requests, and how to build your changes.
### [Code of Conduct](https://code.fb.com/codeofconduct)
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
### License
GNI is licensed under the [Apache 2.0](./LICENSE) license.