Jetson TX2 安裝tensorflow

在Jetson TX2上安裝tensorflow,須要在源碼編譯,至少我看到如今的教程都是在源碼上編譯,編譯的時間會好久. node

源碼編譯安裝tensorflow能夠參考我另一個教程,這裏主要說一些注意要項.git


bazel和tensorflowgithub

bazel 和tensorflow的版本注意不要過高,我這裏就是bazel和tensorflow的版本選的過高,致使安裝完出現問題,雖然不知道是否是依賴沒有打完整的緣故,可是在這裏仍是建議選擇低一些的版本.ubuntu

我這邊選擇的是bazel-5.4,tensorflow1.3app


內存空間不足函數

網上說編譯tensorflow可能會出現內存空間不夠用的狀況,因此須要作一個交換文件,可是實際上我並無碰到,可是仍是記錄一下ui

#Create an 8GB swapfile
fallocate -l 8G swapfile
#Change permission of the swapfile
chmod 600 swapfile
#Create swap area
mkswap swapfile
#Activate the swap area
sudo swapon swapfile
# deactive the swap are
sudo swapoff swapfile
#Confirm swap area being used
swapon -s

修改tensorflow/stream_executor/cuda/cuda_gpu_executor.ccurl

在tensorflow/stream_executor/cuda/cuda_gpu_executor.cc中找到static int TryToReadNumaNode(conststring &pci_bus_id,intdevice_ordinal)這個函數,在最開始就添加一下內容spa

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

計算能力.net

在執行./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.o
In 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 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [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
相關文章
相關標籤/搜索