[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-24。"],[],[],null,["# Build LiteRT Python Wheel Package\n\nThis page describes how to build the LiteRT `tflite_runtime` Python\nlibrary for x86_64 and various ARM devices.\n\nThe following instructions have been tested on Ubuntu 16.04.3 64-bit PC (AMD64)\n, macOS Catalina (x86_64) and TensorFlow devel Docker image\n[tensorflow/tensorflow:devel](https://hub.docker.com/r/tensorflow/tensorflow/tags/).\n| **Note:** This feature is available since version 2.4.\n\n#### Prerequisites\n\nYou need CMake installed and a copy of the TensorFlow source code. Please check\n[Build LiteRT with CMake](./cmake)\npage for the details.\n\nTo build the PIP package for your workstation, you can run the following\ncommands. \n\n PYTHON=python3 tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh native\n\n| **Note:** If you have multiple Python interpreters available, specify the exact Python version with `PYTHON` variable. (Currently, it supports Python 3.7 or higher)\n\nARM cross compilation\n---------------------\n\nFor ARM cross compilation, it's recommended to use Docker since it makes easier\nto setup cross build environment. Also you needs a `target` option to figure out\nthe target architecture.\n\nThere is a helper tool in Makefile `tensorflow/lite/tools/pip_package/Makefile`\navailable to invoke a build command using a pre-defined Docker container. On a\nDocker host machine, you can run a build command as followings. \n\n make -C tensorflow/lite/tools/pip_package docker-build \\\n TENSORFLOW_TARGET=\u003ctarget\u003e PYTHON_VERSION=\u003cpython3 version\u003e\n\n| **Note:** Python version 3.7 or higher is supported.\n\n### Available target names\n\n`tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh` script needs\na target name to figure out target architecture. Here is the list of supported\ntargets.\n\n| Target | Target architecture | Comments |\n|---------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| armhf | ARMv7 VFP with Neon | Compatible with Raspberry Pi 3 and 4 |\n| rpi0 | ARMv6 | Compatible with Raspberry Pi Zero |\n| aarch64 | aarch64 (ARM 64-bit) | [Coral Mendel Linux 4.0](https://coral.ai/) Raspberry Pi with [Ubuntu Server 20.04.01 LTS 64-bit](https://ubuntu.com/download/raspberry-pi) |\n| native | Your workstation | It builds with \"-mnative\" optimization |\n| default | Your workstation | Default target |\n\n### Build examples\n\nHere are some example commands you can use.\n\n#### armhf target for Python 3.7\n\n make -C tensorflow/lite/tools/pip_package docker-build \\\n TENSORFLOW_TARGET=armhf PYTHON_VERSION=3.7\n\n#### aarch64 target for Python 3.8\n\n make -C tensorflow/lite/tools/pip_package docker-build \\\n TENSORFLOW_TARGET=aarch64 PYTHON_VERSION=3.8\n\n#### How to use a custom toolchain?\n\nIf the generated binaries are not compatible with your target, you need to use\nyour own toolchain or provide custom build flags. (Check\n[this](./cmake_arm#check_your_target_environment)\nto understand your target environment) In that case, you need to modify\n`tensorflow/lite/tools/cmake/download_toolchains.sh` to use your own toolchain.\nThe toolchain script defines the following two variables for the\n`build_pip_package_with_cmake.sh` script.\n\n| Variable | Purpose | example |\n|----------------|--------------------------|---------------------------------|\n| `ARMCC_PREFIX` | defines toolchain prefix | arm-linux-gnueabihf- |\n| `ARMCC_FLAGS` | compilation flags | -march=armv7-a -mfpu=neon-vfpv4 |\n\n| **Note:** `ARMCC_FLAGS` might need to contain Python library include path. See the `download_toolchains.sh` for the reference."]]