千家信息网

Jetson TX2如何安装tensorflow

发表于:2024-12-13 作者:千家信息网编辑
千家信息网最后更新 2024年12月13日,这篇文章主要介绍Jetson TX2如何安装tensorflow,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!在Jetson TX2上安装tensorflow,需要在源码编译,
千家信息网最后更新 2024年12月13日Jetson TX2如何安装tensorflow

这篇文章主要介绍Jetson TX2如何安装tensorflow,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

在Jetson TX2上安装tensorflow,需要在源码编译,至少我看到现在的教程都是在源码上编译,编译的时间会很久. 

源码编译安装tensorflow可以参考我另外一个教程,这里主要说一些注意要项.


bazel和tensorflow

bazel 和tensorflow的版本注意不要太高,我这里就是bazel和tensorflow的版本选的太高,导致安装完出现问题,虽然不知道是不是依赖没有打完整的缘故,但是在这里还是建议选择低一些的版本.

我这边选择的是bazel-5.4,tensorflow1.3


内存空间不足

网上说编译tensorflow可能会出现内存空间不够用的情况,所以需要做一个交换文件,但是实际上我并没有碰到,但是还是记录一下

#Create an 8GB swapfilefallocate -l 8G swapfile#Change permission of the swapfilechmod 600 swapfile#Create swap areamkswap swapfile#Activate the swap areasudo swapon swapfile# deactive the swap aresudo swapoff swapfile#Confirm swap area being usedswapon -s

修改tensorflow/stream_executor/cuda/cuda_gpu_executor.cc

在tensorflow/stream_executor/cuda/cuda_gpu_executor.cc中找到static int TryToReadNumaNode(conststring &pci_bus_id,intdevice_ordinal)这个函数,在最开始就添加一下内容

LOG(INFO) << "ARM has no NUMA node, hardcoding to return zero";return 0;

计算能力

在执行./configure的时候,如果要用到cuda会让你填Cuda compute capabilities,记得Jetson TX2的Cuda compute capabilities是6.2


Eigen错误

external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:359:55: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:360:55: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstore(py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:360:55: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:374:56: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstoreu(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:374:56: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:375:69: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstoreu(px+PacketSize, padd(pm.pmul(pc,xi1),pcj.pmul(ps,yi1))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:375:69: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:376:56: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstore (py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:376:56: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:377:69: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstore (py+PacketSize, psub(pcj.pmul(pc,yi1),pm.pmul(ps,xi1))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:377:69: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:385:66: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstoreu(x+peelingEnd, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:385:66: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:386:66: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstore (y+peelingEnd, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:386:66: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:415:53: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstore(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi))); ^ external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:415:53: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' external/eigen_archive/Eigen/src/Jacobi/Jacobi.h:416:53: error: 'struct Eigen::internal::conj_helper<__vector(4) __builtin_neon_sf, Eigen::internal::Packet2cf, false, false>' has no member named 'pmul' pstore(py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));

这些错误是eigen的arm部分有问题,解决方法: https://github.com/tensorflow/tensorflow/issues/9697

https://github.com/samjabrahams/tensorflow-on-raspberry-pi/issues/101

https://bitbucket.org/eigen/eigen/commits/d781c1de9834/

可以手工修改下,或者去下一个上述对arm修改过的3.3版本的Eigen去替换掉 ~/.cache/bazel/_bazel_ubuntu/5a48b4b8cc5de8b183f660553d84cc0b/external/eigen_archive/Eigen(那一长串的目录具体看你自己的)下的Eigen文件夹(下载地址: )

手工修改方法是将tensorflow/workspace.bzl文件中的

native.new_http_archive(    name = "eigen_archive",    urls = [        "http://mirror.bazel.build/bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz",        "https://bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz",    ],    sha256 = "ca7beac153d4059c02c8fc59816c82d54ea47fe58365e8aded4082ded0b820c4",    strip_prefix = "eigen-eigen-f3a22f35b044",    build_file = str(Label("//third_party:eigen.BUILD")),)

替换成

native.new_http_archive(      name = "eigen_archive",      urls = [          "http://mirror.bazel.build/bitbucket.org/eigen/eigen/get/d781c1de9834.tar.gz",          "https://bitbucket.org/eigen/eigen/get/d781c1de9834.tar.gz",      ],      sha256 = "a34b208da6ec18fa8da963369e166e4a368612c14d956dd2f9d7072904675d9b",      strip_prefix = "eigen-eigen-d781c1de9834",      build_file = str(Label("//third_party:eigen.BUILD")),  )

GL头文件问题

Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.oIn file included from /home/ubuntu/build/opencv/modules/core/src/opengl.cpp:50:0:/usr/local/cuda/include/cuda_gl_interop.h:64:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h #error Please include the appropriate gl headers before including cuda_gl_interop.h  ^make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o] Error 1make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2make: *** [all] Error 2

注释/usr/local/cuda/include/cuda_gl_interop.h

#ifndef GL_VERSION#error Please include the appropriate gl headers before including cuda_gl_interop.h#endif#else

以上是"Jetson TX2如何安装tensorflow"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

0