Jammy@Jetson Orin Nano - Tensorflow GPU版本安装

news/2024/11/14 5:02:48/

Jammy@Jetson Orin Nano - Tensorflow GPU版本安装

  • 1. 源由
  • 2. 问题
  • 3. 分析
    • 3.1 当前版本Tensorflow 2.16.1
    • 3.2 GPU版本二进制安装
    • 3.3 GPU版本源代码安装
      • 3.3.1 问题1 ERROR: no such target '//tensorflow/tools/pip_package:wheel'
      • 3.3.2 问题2 fatal error: 'cstddef' file not found
      • 3.3.3 问题3 clang: error: unsupported CUDA gpu architecture: sm_90
  • 4. 总结
  • 5. 参考资料

1. 源由

前面关于Jetson Orin Nano板子的软件安装已经总结了不少,不过这个板子最大的好处是GPU的运算能力,比如:《ubuntu22.04@Jetson Orin Nano之OpenCV安装》。

不过最近发现目前安装的tensorflow 2.16.1版本,在做运算时,压根没有用到GPU,而是在大量的使用CPU计算。这个就有点郁闷了,到底原因出在哪里?必须Fix~~

2. 问题

Tensorflow跑以下示例代码的时候,发现jtop中6个CPU占用率都跑满了。

  • 《Jammy@Jetson Orin - Tensorflow & Keras Get Started: 004 Keras Pre-Trained ImageNet Models》
  • 《Jammy@Jetson Orin - Tensorflow & Keras Get Started: 005 Keras Fine Tune Pre-Trained Models GTSRB》

显然,Jetson Orin Nano是满满的可以跑GPU的,怎么到CPU上去运算了?

初步怀疑就是Tensorflow版本没有支持NVIDIA的GPU。

3. 分析

3.1 当前版本Tensorflow 2.16.1

通过之前安装命令,以及Tensorflow官网安装的信息看,当前安装的版本应该只是CPU版本,并非GPU的版本。

  • Jammy@Jetson Orin - Tensorflow & Keras Get Started: 000 setup for tutorial
  • Tensorflow - Install TensorFlow with pip

3.2 GPU版本二进制安装

$ sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v60dp tensorflow==2.15.0+nv24.03
  • How to install tensorflow with GPU support on Jetson Orin Nano?
  • Installing TensorFlow for Jetson Platform

当前JetPack 6.0DP 支持的Tensorflow版本,暂不支持2.16.1版本
在这里插入图片描述

3.3 GPU版本源代码安装

为了安装Tensorflow 2.16.1最新发布稳定版本,只有最后的一个选择,从源代码编译。

  • Tensorflow - Build from source
  • How to compile tensorflow for Jetson Orin Nano?
  • tensorflow was not compiled for cuda support jetson nano ??

在Linux 36.2@Jetson Orin Nano之基础环境构建基础上建立编译环境:

$ sudo apt-get install bazel-bootstrap
$ sudo apt-get install clang
$ sudo apt-get install python3-clang$ cd ~/Downloads
$ wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-linux-arm64
$ chmod +x bazelisk-linux-arm64
$ sudo mv bazelisk-linux-arm64 /usr/local/bin/bazel
$ which bazel
$ /usr/local/bin/bazel$ export TF_PYTHON_VERSION=3.10

目前上无法顺利编译通过,请持续关注:Tensorflow v2.16.1 GPU version local build on Jetson Orin Nano failed

tensorflowtoolspip_packagewheel_72">3.3.1 问题1 ERROR: no such target ‘//tensorflow/tools/pip_package:wheel’

根据官网指南,执行报错:ERROR: no such target ‘//tensorflow/tools/pip_package:wheel’

$ bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow --config=cuda
... ...
WARNING: The following configs were expanded more than once: [tensorrt, cuda_clang, cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
ERROR: Skipping '//tensorflow/tools/pip_package:wheel': no such target '//tensorflow/tools/pip_package:wheel': target 'wheel' not declared in package 'tensorflow/tools/pip_package' defined by /home/daniel/OpenCV/tensorflow/tensorflow/tools/pip_package/BUILD (Tip: use `query "//tensorflow/tools/pip_package:*"` to see all the targets in that package)
WARNING: Target pattern parsing failed.
ERROR: no such target '//tensorflow/tools/pip_package:wheel': target 'wheel' not declared in package 'tensorflow/tools/pip_package' defined by /home/daniel/OpenCV/tensorflow/tensorflow/tools/pip_package/BUILD (Tip: use `query "//tensorflow/tools/pip_package:*"` to see all the targets in that package)
INFO: Elapsed time: 1.498s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

调整编译目标:build_pip_package

$ bazel query "//tensorflow/tools/pip_package:*"
//tensorflow/tools/pip_package:BUILD
//tensorflow/tools/pip_package:MANIFEST.in
//tensorflow/tools/pip_package:README
//tensorflow/tools/pip_package:THIRD_PARTY_NOTICES.txt
//tensorflow/tools/pip_package:build_pip_package
//tensorflow/tools/pip_package:build_pip_package.sh
//tensorflow/tools/pip_package:included_headers
//tensorflow/tools/pip_package:included_headers_gather
//tensorflow/tools/pip_package:licenses
//tensorflow/tools/pip_package:setup.py
//tensorflow/tools/pip_package:simple_console
//tensorflow/tools/pip_package:simple_console.py
//tensorflow/tools/pip_package:xla_build/CMakeLists.txt
//tensorflow/tools/pip_package:xla_cmake
//tensorflow/tools/pip_package:xla_compiled_cpu_runtime_srcs.txt
//tensorflow/tools/pip_package:xla_compiled_cpu_runtime_srcs.txt_file
Loading: 0 packages loaded
$ bazel build //tensorflow/tools/pip_package:build_pip_package --repo_env=WHEEL_NAME=tensorflow --config=cuda

3.3.2 问题2 fatal error: ‘cstddef’ file not found

编译报错,头文件找不到

$ bazel build //tensorflow/tools/pip_package:build_pip_package --repo_env=WHEEL_NAME=tensorflow --config=cuda
... ...
WARNING: The following configs were expanded more than once: [tensorrt, cuda_clang, cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
INFO: Analyzed target //tensorflow/tools/pip_package:build_pip_package (704 packages loaded, 50634 targets configured).
INFO: Found 1 target...
ERROR: /home/daniel/.cache/bazel/_bazel_daniel/11588ef030db288b35dd97b3c9d34cbc/external/llvm-project/llvm/BUILD.bazel:191:11: Compiling llvm/lib/Demangle/RustDemangle.cpp failed: (Exit 1): clang failed: error executing command (from target @llvm-project//llvm:Demangle) /usr/lib/llvm-14/bin/clang -MD -MF bazel-out/aarch64-opt/bin/external/llvm-project/llvm/_objs/Demangle/RustDemangle.pic.d ... (remaining 85 arguments skipped)
In file included from external/llvm-project/llvm/lib/Demangle/RustDemangle.cpp:14:
external/llvm-project/llvm/include/llvm/Demangle/Demangle.h:12:10: fatal error: 'cstddef' file not found
#include <cstddef>^~~~~~~~~
1 error generated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 731.518s, Critical Path: 0.46s
INFO: 24 processes: 17 internal, 7 local.
FAILED: Build did NOT complete successfully

安装· libstdc+±12-dev·库

$ sudo apt install libstdc++-12-dev

3.3.3 问题3 clang: error: unsupported CUDA gpu architecture: sm_90

$ bazel build //tensorflow/tools/pip_package:build_pip_package --repo_env=WHEEL_NAME=tensorflow --config=cuda
... ...
ERROR: /home/daniel/.cache/bazel/_bazel_daniel/11588ef030db288b35dd97b3c9d34cbc/external/local_xla/xla/stream_executor/cuda/BUILD:505:13: Compiling xla/stream_executor/cuda/cuda_conditional_kernels.cu.cc failed: (Exit 1): clang failed: error executing command (from target @local_xla//xla/stream_executor/cuda:cuda_conditional_kernels) /usr/lib/llvm-14/bin/clang -MD -MF bazel-out/aarch64-opt/bin/external/local_xla/xla/stream_executor/cuda/_objs/cuda_conditional_kernels/cuda_conditional_kernels.cu.pic.d ... (remaining 72 arguments skipped)
clang: warning: CUDA version is newer than the latest supported version 11.5 [-Wunknown-cuda-version]
clang: error: unsupported CUDA gpu architecture: sm_90
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 853.288s, Critical Path: 61.65s
INFO: 11696 processes: 8427 internal, 3269 local.
FAILED: Build did NOT complete successfully

4. 总结

小白入手,通常都是卡在这种没有技术含量的事情上,而这些会导致真正核心技术的发展。

希望通过这些简单的总结,帮助到各位希望学习技术的朋友,在后面的技术道路上走的更顺畅,减少这些由于不熟悉导致的浪费时间。把重点放在技术的学习、突破和创新上。

另外,不同版本的代码之间可能存在或多或少的兼容性问题。

  • Multiple executive warnings after switching tensorflow from 2.16.1 CPU to v60dp tensorflow==2.15.0+nv24.03 GPU version

这也是在技术管理上最重要的一环:版本管理。

5. 参考资料

【1】Linux 36.2@Jetson Orin Nano之基础环境构建
【2】Linux 36.2@Jetson Orin Nano之Hello AI World!
【3】ubuntu22.04@Jetson Orin Nano之OpenCV安装
【3】ubuntu22.04@Jetson Orin Nano之CSI IMX219安装
【3】ubuntu22.04@Jetson Orin Nano安装&配置VNC服务端
【3】Jammy@Jetson Orin - Tensorflow & Keras Get Started: 000 setup for tutorial


http://www.ppmy.cn/news/1445101.html

相关文章

Zynq 7000 系列之启动模式—NAND启动

NAND启动是一种使用NAND闪存进行设备启动的方式。NAND闪存是一种非易失性存储设备&#xff0c;广泛用于嵌入式系统、计算机和其他电子设备中。由于NAND闪存具有高速读写和较高的存储密度等特点&#xff0c;使得NAND启动成为了一种高效且常用的启动方式。 1 特点 NAND启动具有…

Java List 获取部分组成new list,获取两个list相同/不同的内容

获取List中的一项 List<String> _outingCntry list.stream().map(OSzItem::getGroup). collect(Collectors.toList()); 获取List中的多项 List<vo> list new ArrayList<>(); Map<String, String> map list.stream().collect( Collectors.toMap(v…

密文域可逆信息隐藏技术综述(上)

加密图像可逆信息隐藏是一种加密原始图像后&#xff0c;在密文图像中可逆地隐藏附加数据&#xff0c;并且在数据提取后&#xff0c;原始图像可以被无损重建的技术。RDH-EI的分类如图1所示。 按对图像的加密方法&#xff0c;现有RDH-EI算法可分为对称加密域和非对称(公钥)加密域…

OSPF基本配置

原理概述 OSPF 是一种应用非常广泛的基于链路状态的动态路由协议&#xff0c;它具有区域&#xff08; Area )化的层次结构&#xff0c;扩展性好&#xff0c;收敛速度快&#xff0c;适合部署在各种规模的网络上。 在 OSPF 中&#xff0c;每台路由器都必须有一个 Router-I…

.net报错异常及常用功能处理总结(持续更新)

.net报错异常及常用功能处理总结---持续更新 1. WebApi dynamic传参解析结果中ValueKind Object处理方法问题描述方案1&#xff1a;(推荐&#xff0c;改动很小)方案2&#xff1a; 2.C# .net多层循环嵌套结构数据对象如何写对象动态属性赋值问题描述JavaScript动态属性赋值.net…

CentOS 7 安装 Puppeteer Google Chrome

由于需要使用到了 Puppeteer 功能&#xff0c;安装了多次失败而告终。最终找到了一个可以安装成功的方式&#xff0c;特此记录下来。 安装 Puppeteer 需要注意 Node.js 版本&#xff0c;我使用的是 16.x cnpm i puppeteer安装 Google Chrome 这里需要注意的一下是&#xff0c;…

介绍一个在数据分析中常用的函数:data.iloc[]

平时处理数据集中&#xff0c;总是需要选中一些列的数据&#xff0c;去预测其他列的数据&#xff0c;所以data.iloc[]&#xff0c;在数据分析中显得尤为方便。 介绍一下data.iloc[] data.iloc[] 是 Python 中 pandas 库的一个非常有用的功能&#xff0c;它允许你通过行和列的…

windows上通过定时任务提交新增文件到SVN(bat双击可执行,但是通过定时任务后无法提交到svn)

这个要必须记录一下了&#xff0c;因为折腾了蛮久断断续续加起来花费的有一天多时间。因为这个跟上篇定时备份是一个事来的&#xff0c;备份完了不可能留在跟数据库相同的机器吧&#xff0c;这样的话也起不到备份的作用啊&#xff0c;所以就想着让它每天去定时备份&#xff0c;…