Registry / ai-ml / libtpu

libtpu

JSON →
library0.0.46pypypi✓ verified 23d ago

The `libtpu` library is a low-level runtime component that provides the interface for Python-based machine learning frameworks (such as JAX and PyTorch/XLA) to communicate with Google Cloud TPUs. It is primarily a dependency managed by these high-level frameworks rather than a library intended for direct user application development. The current version is 0.0.39 and it requires Python >= 3.11. It has no strict release cadence, with updates typically coinciding with changes in underlying TPU infrastructure or integrations with ML frameworks.

pip install libtpu
INSTALL
IMPORT
SIG · LIBTPU
L
libtpu
ai-mlpythonv0.0.46
Install
21.6s avg
Import
118ms
Disk
745MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.21 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 25.05s
py 3.11
1/2 runs
✓ 33.1s
py 3.12
1/2 runs
✓ 15.45s
py 3.13
1/2 runs
✓ 12.7s
py 3.9
✕ build_error
1/2 runs
745MB installed
● package 745MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

libtpu
import libtpu
While `libtpu` can be imported, it is a low-level runtime library. Direct import for accessing user-facing classes or functions is uncommon. Most users will rely on frameworks like JAX or PyTorch/XLA to manage and utilize `libtpu` internally.

This quickstart demonstrates how to verify the presence and configuration of TPU devices using JAX, which is the most common way users interact with the capabilities provided by `libtpu`. Running this code on a Google Cloud TPU instance with `jax[tpu]` installed will confirm `libtpu`'s operational status.

import os # This quickstart demonstrates checking for TPU devices using JAX, # which implicitly relies on `libtpu` being correctly installed and configured. # Direct usage of `libtpu`'s API for application logic is rare. try: import jax # The following line will only succeed if libtpu is correctly installed # and a TPU device is available and configured in the environment. tpu_devices = jax.devices('tpu') print(f"Found {len(tpu_devices)} TPU devices: {tpu_devices}") if tpu_devices: print("libtpu is likely working correctly with JAX on a TPU.") else: print("No TPU devices found. libtpu may be installed, but no TPU is available or configured.") except ImportError: print("JAX is not installed. Please install JAX with TPU support: pip install jax[tpu]") except Exception as e: print(f"An error occurred while checking for TPU devices: {e}") print("This could indicate an issue with libtpu installation or TPU environment configuration.")
Debug
Known issues
gotcha`libtpu` is a low-level runtime library primarily used by ML frameworks (JAX, PyTorch/XLA) to interface with Google Cloud TPUs. It is not designed for direct import and high-level application development by end-users. Most users will interact with `libtpu` indirectly through these frameworks.
fix
Focus on setting up your ML framework (e.g., JAX) correctly for TPU usage; avoid trying to directly manipulate `libtpu`'s internal APIs unless you have a highly specialized use case.
affects: All
gotchaThis library requires a Google Cloud TPU environment to function. It cannot be used for local development without significant, specialized setup (e.g., a software emulator), which is not officially supported for general use.
fix
Deploy your application to a Google Cloud TPU VM or environment to utilize `libtpu`'s functionality.
affects: All
gotchaVersion compatibility between `libtpu`, JAX/PyTorch/XLA, and the underlying Google Cloud TPU software stack is crucial. Mismatched versions can lead to runtime errors, device not found errors, or unexpected behavior.
fix
Always follow the official installation instructions for JAX or PyTorch/XLA on TPU, which typically bundle or specify compatible `libtpu` versions. Avoid arbitrary `pip install libtpu` if you are using a framework.
affects: All
gotchaThe package currently requires Python 3.11 or higher. Using older Python versions will result in installation failures or runtime errors.
fix
Ensure your environment is running Python 3.11 or a later compatible version.
affects: <=0.0.39
gotchaFor some environments or older setups, `libtpu` might rely on specific environment variables (e.g., `LD_LIBRARY_PATH`, `XRT_TPU_CONFIG`) being correctly set to locate its underlying C++ components. While modern framework installations often handle this, it can be a source of 'TPU not found' errors.
fix
Consult Google Cloud's official documentation for JAX/PyTorch on TPU to ensure all necessary environment configurations are in place. When troubleshooting, verify these variables if other solutions fail.
affects: All
Errors
Common errors & fixes
cannot open shared object file: No such file or directory
The `libtpu.so` shared library cannot be found by the system or the application, often due to an incorrect `LD_LIBRARY_PATH`, a missing file, or an architecture mismatch (e.g., trying to use an x86-64 library on an ARM system).
fix
Ensure `libtpu.so` is correctly installed, the `LD_LIBRARY_PATH` environment variable includes its directory, and the library's architecture matches the system. Explicitly setting `TPU_LIBRARY_PATH` to the full path of `libtpu.so` may also resolve the issue.
A Google TPU may be present on this machine, but either a TPU-enabled jaxlib or libtpu is not installed. Falling back to cpu.
JAX or TensorFlow could not detect a properly installed and configured `libtpu` and/or a compatible TPU-enabled `jaxlib` (or `tensorflow-tpu`) that matches the detected TPU device, leading the framework to default to CPU execution.
fix
Verify that `libtpu` and the correct TPU-enabled version of `jaxlib` (or `tensorflow-tpu`) are installed and compatible with each other and your Python version. This often requires using specific `pip install` commands provided in the framework's documentation, which include `--find-links` arguments to the correct wheel repositories.
libtpu.so already in use by another process. Not attempting to load libtpu.so in this process.
The `libtpu.so` shared library or the underlying TPU device is currently locked or in use by another running process, preventing the current process from acquiring access to it.
fix
Identify and terminate any other process that might be using the TPU (e.g., using `sudo lsof -w /dev/accel0` to find the process ID) or ensure that only one process attempts to access the TPU at a time. A manual reset of the TPU server might also be required.
AttributeError: module 'libtpu' has no attribute 'get_library_path'
This error typically indicates a version incompatibility between a high-level framework (like JAX or TensorFlow) and `libtpu`, where the framework attempts to call a method (`get_library_path`) that is either missing, renamed, or structured differently in the installed `libtpu` version.
fix
Ensure that the versions of your machine learning framework (JAX or TensorFlow) and `libtpu` are compatible. This often requires installing specific, matching versions, potentially by downgrading the framework to a version known to be compatible with your `libtpu` installation.
Upgrade
Version history
0.0.46latest on PyPI · released Aug 14, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources