当前位置: 首页 > news >正文

bazel编译litert

bazel 编译

一、安装工具
# 1. 更新系统并安装依赖
sudo apt update
sudo apt install -y curl git openjdk-17-jdk

# 2. 下载 Bazelisk 并命名为 `bazel`
curl -LO "https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64"
sudo mv bazelisk-linux-amd64 /usr/local/bin/bazel
sudo chmod +x /usr/local/bin/bazel

二、常用命令

1、编译项目中的所有目标,在项目根目录运行:  bazel build //...
这会告诉 Bazel 递归地查找并构建从根目录开始的所有 BUILD 文件中定义的所有目标。

2、编译特定目录下的所有目标:如果你只想编译 litert/cc 及其子目录下的所有内容,可以运行:
bazel build //litert/cc/...

3、编译指定目标,其中有一个名为 litert_api_with_dynamic_runtime 的库
bazel build //litert/cc:litert_api_with_dynamic_runtime

4、要运行 litert/cc 目录及其子目录中定义的所有测试,可以使用 ... 通配符:
bazel test //litert/cc/...

三、使用bazel编译LiteRT
1、下载LiteRT代码
https://github.com/google-ai-edge/LiteRT

2、下载sdk和ndk(都要是linux的)
ndk下载很简单,到对应网址下载25版本即可
sdk下载:先下载 command-tool https://developer.android.com/studio#command-tools
然后通过command-tool sdkmanager 下载platforms和build-tools
./cmdline-tools/bin/sdkmanager \
"platform-tools"\
"build-tools;34.0.0"\
"build-tools;33.0.2"\
"platforms;android-34"\
"platforms;android-33"\
"platforms;android-31"\
--sdk_root=~/work/cfc/sdk

3、到项目主目录执行 python3.13  configure.py ,按照指引一步步设置,这里我们需要编译的库跑在安卓手机,所以前面都选N
交互如下:
You have bazel 7.6.1 installed.
Please specify the location of python. [Default is /usr/local/bin/python3.13]: 


Found possible Python library paths:
/usr/local/lib/python3.13/site-packages
Please input the desired Python library path to use.  Default is [/usr/local/lib/python3.13/site-packages]

            Do you wish to build TensorFlow with ROCm support? [y/N]: N
No ROCm support will be enabled for TensorFlow.

            Do you wish to build TensorFlow with CUDA support? [y/N]: N
No CUDA support will be enabled for TensorFlow.

            Do you want to use Clang to build TensorFlow? [Y/n]: n
GCC will be used to compile TensorFlow.

            Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -Wno-sign-compare]: 


Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: y
Searching for NDK and SDK installations.

            Please specify the home path of the Android NDK to use. [Default is /home/njsmoketest/Android/Sdk/ndk-bundle]: /home/njsmoketest/work/cfc/ndk/android-ndk-r25c


Please specify the (min) Android NDK API level to use. [Available levels: [16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33]] [Default is 21]: 


Please specify the home path of the Android SDK to use. [Default is /home/njsmoketest/Android/Sdk]: /home/njsmoketest/work/cfc/sdk                 


Please specify the Android SDK API level to use. [Available levels: ['31', '33', '34']] [Default is 34]: 


Please specify an Android build tools version to use. [Available versions: ['33.0.2', '34.0.0']] [Default is 34.0.0]: 


Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details.
--config=mkl             # Build with MKL support.
--config=mkl_aarch64     # Build with oneDNN and Compute Library for the Arm Architecture (ACL).
--config=monolithic      # Config for mostly static monolithic build.
--config=numa            # Build with NUMA support.
--config=dynamic_kernels    # (Experimental) Build kernels into separate shared objects.
--config=v1              # Build with TensorFlow 1 API instead of TF 2 API.
Preconfigured Bazel build configs to DISABLE default on features:
--config=nogcp           # Disable GCP support.
--config=nonccl          # Disable NVIDIA NCCL support.

4、编译,我们只编译需要的,整个编译的话会报其他错误,暂时就这样了。
bazel build //litert/cc:litert_api_with_dynamic_runtime

 

http://www.dtcms.com/a/408464.html

相关文章:

  • 台州网站制作 外贸墙外必去的网站
  • 医院网站建设模板学校网站建设方案论文
  • 怎么申请 免费网站空间十大黄台软件app下载
  • 苏州全网网站建设asp网站建设代码
  • 寿光建设银行网站海南响应式网站建设制作
  • 网站开发的技术解决方案物流门户网站开发
  • 有做销售产品的网站有哪些内容sem推广
  • 构建AI智能体:四十四、线性回归遇见大模型:从数学原理到智能实战
  • 网站建设总结ppt珠海品牌型网站建设
  • 做网页兼职网站有哪些做外贸网站的都有哪些类型的公司
  • 合肥专业网站制作设计电子商务网站建设策划书
  • 介绍好看的电影网站模板免费下载可以做免费推广的网站有哪些
  • 十三师建设局网站深圳较便宜的网站建设
  • 《RStudio》软件下载_《RStudio》安装包下载_《RStudio》安装教程下载_《RStudio》网盘下载
  • 做网站的问卷调查做网站的关键词是指
  • 企业网站的内容选题来源中山专业门户网站制作咨询
  • 泊头做网站的公司宿州网络推广公司
  • 制作大型网站网站做统计分析
  • 软装设计案例网站互联网设计师leader
  • 网站上做网页怎么改图片公司简介介绍
  • qwen3_embedding
  • 建网站需要营业执照吗注册推广
  • 百度不收录网站吗个人网站备案转企业备案
  • 专门做水生植物销售网站如何伪原创 网站
  • 找人做网站网站制作书签教案
  • 网站设置主页在哪里课工场网站建设培训
  • 网站关键字优化技巧沙特网站后缀
  • 济南 网站开发怎么样在网上推广
  • 网站怎么做微信登录做网站建设的销售薪水
  • 珠海 旅游 网站建设个人网站盈利