# 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.

## Rust Build and Running GNI

### 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
```

## Non Rust usage

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)

> Note: If you’d like support for another language, please open an issue or submit a pull request!

## 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.