{"id":16769043,"url":"https://github.com/dsseng/rust-tf-pluggabledevice","last_synced_at":"2026-05-19T11:04:57.291Z","repository":{"id":49327646,"uuid":"517013649","full_name":"dsseng/rust-tf-pluggabledevice","owner":"dsseng","description":"A reference TensorFlow PluggableDevice implementation, in Rust","archived":false,"fork":false,"pushed_at":"2022-07-26T14:40:20.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T01:28:56.741Z","etag":null,"topics":["ffi-bindings","rust","tensorflow","tensorflow2","tpu","tpu-acceleration"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsseng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-23T09:26:48.000Z","updated_at":"2022-07-25T06:23:11.000Z","dependencies_parsed_at":"2022-08-25T17:23:44.204Z","dependency_job_id":null,"html_url":"https://github.com/dsseng/rust-tf-pluggabledevice","commit_stats":null,"previous_names":["dsseng/rust-tf-pluggabledevice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsseng%2Frust-tf-pluggabledevice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsseng%2Frust-tf-pluggabledevice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsseng%2Frust-tf-pluggabledevice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsseng%2Frust-tf-pluggabledevice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsseng","download_url":"https://codeload.github.com/dsseng/rust-tf-pluggabledevice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878437,"owners_count":20362432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffi-bindings","rust","tensorflow","tensorflow2","tpu","tpu-acceleration"],"created_at":"2024-10-13T06:13:12.900Z","updated_at":"2026-05-19T11:04:52.270Z","avatar_url":"https://github.com/dsseng.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust TensorFlow PluggableDevice\n\nPorted over from https://github.com/tensorflow/community/pull/352\n\nThe `tfp-bindings` crate mostly provides *unsafe* bindings to all TensorFlow C APIs required by plug-ins via `libtensorflow_framework.so.2` library (yes, and currently in only supports Linux and Python 3.10). It also has some *should-be-safe* bindings to main functions required by compute kernels and their registration. Its safety mostly relies on validating data, checking result codes and asserts in debug mode to prevent common plug-in issues like unterminated strings.\n\nPlugin itself (`tfp-plugin`) should link to that library via its `build.rs` script and implement `SE_InitPlugin` and `TF_InitKernel` functions with proper types (these are excluded from bindgen). It may also include optimizer, but it is not yet implemented in this repository.\n\n## Requirements\n- Linux, tested on Fedora 36, any should work fine.\n- MSRV not yet specified, I use nightly. No strict limits are being set.\n- Python 3 for test script. `pip3` and `venv` to install TensorFlow\n- clang for binding generation via bindgen\n\n## Usage in other packages\n\nYou can import the bindings crate by using such a dependency string. There are environment variables you can use to point the paths to TensorFlow library:\n\n- `TF_INCLUDE_PATH`\n- `TF_LIBRARY_PATH`\n\nThey could be set, for example, by [Cargo project config](https://doc.rust-lang.org/nightly/cargo/reference/config.html#env)\n\nCargo.toml example. Replace `x` by needed commit hash.\n\n```toml\ntfp-bindings = { git = \"https://github.com/sh7dm/rust-tf-pluggabledevice\", rev = \"x\" }\n```\n\n## Try it out\n\n```bash\npython3.10 -m venv venv\nsource venv/bin/activate\npip3 install --no-cache-dir tf-nightly-cpu # or tensorflow-cpu\n# https://github.com/tensorflow/tensorflow/issues/55497\nmv venv/lib64 venv/_lib64\ncargo build\nmkdir venv/lib/python3.10/site-packages/tensorflow-plugins/\ncp target/debug/libtfp.so venv/lib/python3.10/site-packages/tensorflow-plugins/\npython3 test.py\n```\n\n```python3\nimport tensorflow as tf\ntf.config.list_physical_devices()\n```\n\n## Running tests\n\nSpecifying `LD_LIBRARY_PATH` manually is necessary as of https://github.com/rust-lang/cargo/issues/4044\n\n```\nLD_LIBRARY_PATH=$(pwd)/venv/lib/python3.10/site-packages/tensorflow cargo test\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsseng%2Frust-tf-pluggabledevice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsseng%2Frust-tf-pluggabledevice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsseng%2Frust-tf-pluggabledevice/lists"}