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

ops/2024/11/9 16:44:52/

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/ops/24483.html

相关文章

LED灯降压恒流驱动芯片5~60v输出1.5A大电流AP51656

产品描述 AP51656是一款连续电感电流导通模式的降压恒流源&#xff0c;用于驱动一颗或多颗串联LED输入电压范围从 5 V 到 60V&#xff0c;输出电流 最大可达 1.5A 。根据不同的输入电压和外部器件&#xff0c; 可以驱动高达数十瓦的 LED。 内置功率开关&#xff0c;采用高端电…

SpringCloud之OpenFeign

学习笔记&#xff1a; 官网地址&#xff1a;https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#spring-cloud-feign 源码&#xff1a;https://github.com/spring-cloud/spring-cloud-openfeign 1、概念总结 OpenFeign是一个声明式的Web服务客户端…

Springboot+Vue项目-基于Java+MySQL的校园疫情防控系统(附源码+演示视频+LW)

大家好&#xff01;我是程序猿老A&#xff0c;感谢您阅读本文&#xff0c;欢迎一键三连哦。 &#x1f49e;当前专栏&#xff1a;Java毕业设计 精彩专栏推荐&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; &#x1f380; Python毕业设计 &…

深度学习发展背后的人和事

深度学习发展背后的人和事 前言 深度学习现在是人工智能的主流研究方向&#xff0c;机器的深度学习是否跟人类的学习有什么关系&#xff0c;深度学习是如何发展至今的&#xff0c;《深度学习革命》这本书对此做了非常精彩的介绍。《深度学习革命&#xff1a;从历史到未来》由…

MySQL-角色管理

角色就是权限的集合方便管理相同权限的用户恰当的权限设定&#xff0c;可以确保数据的安全性 1、创建角色 用户数量较多时&#xff0c;避免单独给每个用户授予多个权限&#xff0c;则可将权限集合放入角色中&#xff0c;再赋予用户相应的角色语法&#xff1a;create role rol…

Docker consul的容器服务更新与发现

一、Docker consul 1. 什么是服务注册与发现 服务注册与发现是微服务架构中不可或缺的重要组件。起初服务都是单节点的&#xff0c;不保障高可用性&#xff0c;也不考虑服务的压力承载&#xff0c;服务之间调用单纯的通过接口访问。直到后来出现了多个节点的分布式架构&#…

RK3568 修改LCD为主显示

我拿到的这个SDK&#xff0c;默认是LVDS为主显&#xff0c;如需要用到LCD&#xff0c;必须每次输入命令进行设置才可以&#xff0c;但是实际使用中我需要开机就是LCD为主显示。 我们需要找到SDK的buildroot的weston包&#xff0c;weston是管理3568的显示&#xff0c;以我自己的…

Spring MVC系列之九大核心组件

概述 Spring MVC是面试必问知识点其一&#xff0c;Spring MVC知识体系庞杂&#xff0c;有以下九大核心组件&#xff1a; HandlerMappingHandlerAdapterHandlerExceptionResolverViewResolverRequestToViewNameTranslatorLocaleResolverThemeResolverMultipartResolverFlashMa…