網頁

2019年7月27日 星期六

apt-get

sudo apt-get install chromium-browser-l10n
chromium-browser
chromium-codecs-ffmpeg-extra
unity-scope-chromiumbookmarks
apt list --installed
sudo apt-get remove chromium-browser
apt-cache madison chromium-browser
sudo apt-get install chromium-browser=75.0.3770.90-0ubuntu0.18.04.1


2019年7月25日 星期四

毫米波雷達

基於TI AWR1642的77G毫米波雷達盲區偵測BSD方案

找到好東西,記錄下列重點

FMCW (Frequency Modulated Continuous Wave , 線性調頻信號)
ADAS 先進駕駛輔助系統(Advanced Driver Assistance Systems)
自适应巡航(ACC)
前向碰撞预警(FCW)
自动紧急制动(AEB)
盲点侦测(BSD)
辅助停车(PA)
变道辅助(lane change assist,LCA)
后碰预警(RCW)
一般来讲 chirp 的扫频带宽越大,分辨率越好,但是探测距离会短,反之则分辨率低,探测距离远

AWR1843 是 3T4R
如果是 3 TX and 4 RX,則 MIMO radar system 可以等效為 12 virtual channels 其 Angular resolution 約為 10°
AWR1642 是 2T4R
如果是 2 TX and 4 RX,則 MIMO radar system 可以等效為 8 virtual channels 其 Angular resolution 約為 15°
3T4R 可以在 2T4R 基础上,增加水平角分辨率,或者是增加测俯仰角的能力。

假設一個 frame 具有 128 chirps ( Nchirp = 128 ) 、
ADC 取樣數 為 256 samples ( Nadc = 256 ) 、
ADC sampling rate 為 5 MHz 、
四個 RX 天線 則 radar-cube memory 所需為 512KB
( 256 samples × 128 chirps × 4 antennas × 4 bytes / sample )
以 AWR1642 的 C674x DSP 運作在 600 MHz 的運算能力做計算。
256-pt range-FFT with windowing 需要耗時 ( 1.55 + 0.37 ) = 1.92 μs
因為 ADC 取樣數 為 256 samples ( Nadc = 256 ) 、
ADC sampling rate 為 5 MHz 則 Chirp cycle time Tc 至少為 256 / 5 = 51μs ( 不包含 Idle Time )
所以在 Intraframe processing 處理 1st Dimension FFT Processing 處理時間相當寬裕。
一樣以 AWR1642 的 C674x DSP 運作在 600 MHz 的運算能力做計算。
Doppler-FFT with windowing 需要耗時 ( 1.59 + 0.32 ) = 1.91 μs,
所以在 Interframe processing 處理 Doppler-FFT 需耗時 1.95 ms
( 1.91 μs × 256 range bins × 4 RX antennas )
一個 frame 計算到這裡,至少耗時 15.006 ms ( 256 × 51μs + 1.95ms )
隨後根據系統 Signal Processing Chain 接續的 detection algorithm 繼續計算。

雷达可以探测静止目标,车辆停止时也有功能,此时可以做为 RCTA (后方横向来车告警),用于车辆倒车出库时的盲区提醒。

这里面所说的精度指的是 Range Resolution,
根据 mmw Radar 捕捉目标的基本理论 Range Resolution=C/2B,
其中 C= 光速,B= 雷达带宽。以此计算,AWR1642 最大输出带宽为 4GHz,
得到 Range Resolution ≈ 4cm。
24GHz 雷達分辨率約為 60cm
77GHz 雷達分辨率約為 4cm

雷达性能参数
Max range:最大距离,雷达能探测到的最远距离。
Range resolution:距离分辨率,指分辨两个距离很近的物体的能力。
Range accuracy:距离精度,单个目标的距离测量精度,取决于信噪比,通常距离精度是距离分辨率的一小部分。
Max velocity:最大速度,最大相对速度可以通过两个间隔为 Tc 的 Chirp 测得,更高的 Vmax 需要两个线性调频脉冲之间更短的传输时间。
Velocity resolution:速度分辨率,在速度上分离两个物体的能力,取决于帧的活动持续时间,雷达的速度分辨率与帧时间(Tf)成反比。
Velocity accuracy:速度精度,单个物体速度测量的准确性,取决于信噪比,通常是速度分辨率的一部分。
Max Angular Field of View:最大角视场,两个天线之间的间隔 l = l/2 会导致 ±90°的最大角视场。
Angular resolution:角度分辨率,角度分离两个物体的能力,雷达传感器的角度分辨率通常较低。

Chirp duration 為 8μs 最大可量測相對速度為 92.28 kmph

Maximum unambiguous range 80 m
Range resolution 35 cm ( Normal resolution )

2019年7月12日 星期五

玩 OpenAI Gym Atari 遊戲

參考 Playing the OpenAI Gym Atari Games

sudo apt-get build-dep python-pygame
pip install pygame
pip install matplotlib
sudo apt-get install python3-tk

mkdir -p gym/utils
下載 play.py 到 gym/utils

執行
import gym
from gym.utils.play import play
env = gym.make("MontezumaRevengeNoFrameskip-v4")
play(env, zoom=4)

2019年7月11日 星期四

Nvidia Jetson AGX Xavier 之 Qt 安裝

參考 How to install PyQt4 on Tx2
sudo apt-get install libqt4-dev qt4-dev-tools python-qt4-dev pyqt4-dev-tools
sudo apt-get install python-qt4
sudo apt-get install python3-pyqt4


參考 Install Qt Creator on NVIDIA Jetson TK1
sudo apt-get install build-essential qt5-default qtcreator -y
開啟 Qt Creator
選擇 Tools/Options/Build & Run/Compilers
Add/GCC
Compiler path: /usr/bin/gcc
選擇 Tools/Options/Build & Run/Kits
Manual/Desktop (default)
Compiler: GCC

sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools
cp -r /usr/lib/python3/dist-packages/PyQt5 ~/XavierSSD/envs/OpenAiGym/lib/python3.6/site-packages/

wget "https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz"
wget 網址已經不存在
改從 https://distfiles.macports.org/py-sip/ 下載
tar -zxf sip-4.19.14.tar.gz
cd sip-4.19.14/
python configure.py
make
make install

2019年7月3日 星期三

python virtualenv

# pip3 install virtualenv 不能使用
apt-get install  python3-venv
mkdir envs
cd envs

virtualenv -p /usr/bin/python3 tensorflow
python3 -m venv --system-site-packages tensorflow

source tensorflow/bin/activate

安裝 指定版本
pip install package_name==2.6.0
列出已安裝的 package
pip list
顯示 package 的資料
pip show package_name
產生一份安裝列表
pip freeze > requirements.txt
cat requirements.txt
依據安裝列表 安裝 package
pip install -r requirements.txt

deactivate

若需要有 root 的權限
$ sudo tensorflow/bin/python your_python.py
若需要傳入特定環境變數
$ sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH tensorflow/bin/python your_python.py


2019年6月30日 星期日

Xavier OpenAI Gym

使用PyTorch,OpenAI Gym和Gazebo機器人模擬器爲NVIDIA Jetson深度強化學習GPU庫
PyTorch Install problem (Solved)
Robot Operating System (ROS) on NVIDIA Jetson AGX Xavier Developer Kit
TX2 - Jetson Reinforcement - cmake -- configuring incomplete
Install Gazebo using Ubuntu packages
NVIDIA Xavier - Deep Learning - Deep Learning Tutorials - Jetson Reinforcement
Ubuntu gazebo package
nvidia@jetson-0423418048807:~$ apt-cache madison gazebo9
   gazebo9 | 9.8.0-1~bionic | http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic/main arm64 Packages
   gazebo9 | 9.0.0+dfsg5-3ubuntu1 | http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 Packages
    gazebo | 9.0.0+dfsg5-3ubuntu1 | http://ports.ubuntu.com/ubuntu-ports bionic/universe Sources
nvidia@jetson-0423418048807:~$
nvidia@jetson-0423418048807:~$ apt-cache madison libgazebo9-dev
libgazebo9-dev | 9.8.0-1~bionic | http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic/main arm64 Packages
libgazebo9-dev | 9.0.0+dfsg5-3ubuntu1 | http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 Packages
    gazebo | 9.0.0+dfsg5-3ubuntu1 | http://ports.ubuntu.com/ubuntu-ports bionic/universe Sources
nvidia@jetson-0423418048807:~$
nvidia@jetson-0423418048807:~$ sudo apt-get install gazebo9=9.0.0+dfsg5-3ubuntu1
nvidia@jetson-0423418048807:~$ sudo apt-get install libgazebo9-dev=9.0.0+dfsg5-3ubuntu1
Getting Started with Gym
Errors during install sklearn.
How to install opencv-python for python3.6
Installing everything
GitHub atari_py
python3 setup.py build
python3 setup.py install
pip3 install cffi
sudo apt install libffi-dev

2019年6月25日 星期二

Nvidia Jetson AGX Xavier Build tensorflow 1.13

參考 Building Tensorflow 1.13 on Jetson Xavier

安裝 bazel
nvidia@jetson-0423418048807:~/XavierSSD/Downloads$ wget https://github.com/bazelbuild/bazel/releases/download/0.19.2/bazel-0.19.2-dist.zip
nvidia@jetson-0423418048807:~/XavierSSD/Downloads$ mkdir bazel
nvidia@jetson-0423418048807:~/XavierSSD/Downloads$ cd bazel
nvidia@jetson-0423418048807:~/XavierSSD/Downloads/bazel$ unzip bazel-0.19.2-dist.zip
nvidia@jetson-0423418048807:~/XavierSSD/Downloads/bazel$ env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh
nvidia@jetson-0423418048807:~/XavierSSD/Downloads/bazel$ cd ..
nvidia@jetson-0423418048807:~/XavierSSD/Downloads$ mv bazel ~/XavierSSD
nvidia@jetson-0423418048807:~/XavierSSD/Downloads$ cd ../bazel/
nvidia@jetson-0423418048807:~/XavierSSD/bazel$ vi ~/.bashrc
加入下一行到檔案底部,並且也執行一遍
export PATH=~/XavierSSD/bazel/output${PATH:+:${PATH}}

下載 tensorflow
nvidia@jetson-0423418048807:~/XavierSSD/bazel$ cd ..
nvidia@jetson-0423418048807:~/XavierSSD$ git clone https://github.com/tensorflow/tensorflow.git
nvidia@jetson-0423418048807:~/XavierSSD$ cd tensorflow/

設定 git 環境,取得 r1.13 版
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git config --global user.email "name@yahoo.com.tw"
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git config --global user.name "name"
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git checkout r1.13

為 Nvidia Jetson AGX Xavier 修改
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ vi tensorflow/lite/kernels/internal/BUILD
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git add tensorflow/lite/kernels/internal/BUILD
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git commit -m "Update 1"
[r1.13 982e077b2a] Update 1
 1 file changed, 3 deletions(-)
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git log
commit 982e077b2a4e2123f7a299dbaf95d97383303d17 (HEAD -> r1.13)
Author: name <name@yahoo.com.tw>
Date:   Mon Jun 24 14:49:30 2019 +0800

    Update 1

commit 93dd14dce2e8751bcaab0a0eb363d55eb0cc5813 (origin/r1.13)
Author: Mihai Maruseac <mihaimaruseac@google.com>
Date:   Tue May 21 10:08:18 2019 -0700

    Update png_archive version to 1.6.37

    PiperOrigin-RevId: 249272809

nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git diff 93dd1 982e0
diff --git a/tensorflow/lite/kernels/internal/BUILD b/tensorflow/lite/kernels/internal/BUILD
index 4be3226938..7226f96fdf 100644
--- a/tensorflow/lite/kernels/internal/BUILD
+++ b/tensorflow/lite/kernels/internal/BUILD
@@ -22,15 +22,12 @@ HARD_FP_FLAGS_IF_APPLICABLE = select({
 NEON_FLAGS_IF_APPLICABLE = select({
     ":arm": [
         "-O3",
-        "-mfpu=neon",
     ],
     ":armeabi-v7a": [
         "-O3",
-        "-mfpu=neon",
     ],
     ":armv7a": [
         "-O3",
-        "-mfpu=neon",
     ],
     "//conditions:default": [
         "-O3",
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ vi third_party/aws/BUILD.bazel
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git add third_party/aws/BUILD.bazel
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git commit -m "Update 2"
[r1.13 a3d6ea2fce] Update 2
 1 file changed, 1 insertion(+), 1 deletion(-)
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git log
commit a3d6ea2fce8fff7bcf74ee52cd77074416d24bf2 (HEAD -> r1.13)
Author: mark <ingrenn@yahoo.com.tw>
Date:   Mon Jun 24 14:56:09 2019 +0800

    Update 2

commit 982e077b2a4e2123f7a299dbaf95d97383303d17
Author: mark <ingrenn@yahoo.com.tw>
Date:   Mon Jun 24 14:49:30 2019 +0800

    Update 1

nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git diff 982e0 a3d6ea
diff --git a/third_party/aws/BUILD.bazel b/third_party/aws/BUILD.bazel
index 5426f79e46..e08f8fc108 100644
--- a/third_party/aws/BUILD.bazel
+++ b/third_party/aws/BUILD.bazel
@@ -24,7 +24,7 @@ cc_library(
         "@org_tensorflow//tensorflow:raspberry_pi_armeabi": glob([
             "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp",
         ]),
-        "//conditions:default": [],
+        "//conditions:default": glob(["aws-cpp-sdk-core/source/platform/linux-shared/*.cpp",]),
     }) + glob([
         "aws-cpp-sdk-core/include/**/*.h",
         "aws-cpp-sdk-core/source/*.cpp",
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ vi third_party/gpus/crosstool/BUILD.tpl
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git add third_party/gpus/cro
sstool/BUILD.tpl
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git commit -m "Update 3"
[r1.13 65ad3b64e5] Update 3
 1 file changed, 1 insertion(+)
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git log
commit 65ad3b64e5f16b3496628bee800fabf825a7c1ce (HEAD -> r1.13)
Author: mark <ingrenn@yahoo.com.tw>
Date:   Mon Jun 24 15:04:22 2019 +0800

    Update 3

commit a3d6ea2fce8fff7bcf74ee52cd77074416d24bf2
Author: mark <ingrenn@yahoo.com.tw>
Date:   Mon Jun 24 14:56:09 2019 +0800

    Update 2

commit 982e077b2a4e2123f7a299dbaf95d97383303d17
Author: mark <ingrenn@yahoo.com.tw>
Date:   Mon Jun 24 14:49:30 2019 +0800

    Update 1

commit 93dd14dce2e8751bcaab0a0eb363d55eb0cc5813 (origin/r1.13)
Author: Mihai Maruseac <mihaimaruseac@google.com>
Date:   Tue May 21 10:08:18 2019 -0700

    Update png_archive version to 1.6.37
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ git diff a3d6ea 65ad3
diff --git a/third_party/gpus/crosstool/BUILD.tpl b/third_party/gpus/crosstool/BUILD.tpl
index db76306ffb..184cd35b87 100644
--- a/third_party/gpus/crosstool/BUILD.tpl
+++ b/third_party/gpus/crosstool/BUILD.tpl
@@ -24,6 +24,7 @@ cc_toolchain_suite(
         "x64_windows|msvc-cl": ":cc-compiler-windows",
         "x64_windows": ":cc-compiler-windows",
         "arm": ":cc-compiler-local",
+        "aarch64": ":cc-compiler-local",
         "k8": ":cc-compiler-local",
         "piii": ":cc-compiler-local",
         "ppc": ":cc-compiler-local",
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
修改完成

安裝所需版本的 g++ 和 gcc
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ sudo apt-get install g++-5
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ sudo apt-get install gcc-5

設定編譯環境
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ ./configure
Extracting Bazel installation...
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.19.2- (@non-git) installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3


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

Do you wish to build TensorFlow with XLA JIT support? [Y/n]: n
No XLA JIT support will be enabled for TensorFlow.

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

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]: y
CUDA support will be enabled for TensorFlow.

Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]:


Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0


Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3


Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: /usr/lib/aarch64-linux-gnu


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

Please specify the location where TensorRT is installed. [Default is /usr/lib/aarch64-linux-gnu]:


Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]:


Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,7.0]: 7.2


Do you want to use clang as CUDA compiler? [y/N]: n
nvcc will be used as CUDA compiler.

Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: /usr/bin/gcc-5


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

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


Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n
Not configuring the WORKSPACE for Android builds.

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=monolithic     # Config for mostly static monolithic build.
        --config=gdr            # Build with GDR support.
        --config=verbs          # Build with libverbs support.
        --config=ngraph         # Build with Intel nGraph support.
        --config=dynamic_kernels        # (Experimental) Build kernels into separate shared objects.
Preconfigured Bazel build configs to DISABLE default on features:
        --config=noaws          # Disable AWS S3 filesystem support.
        --config=nogcp          # Disable GCP support.
        --config=nohdfs         # Disable HDFS support.
        --config=noignite       # Disable Apacha Ignite support.
        --config=nokafka        # Disable Apache Kafka support.
        --config=nonccl         # Disable NVIDIA NCCL support.
Configuration finished
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$

建立 tensorflow 安裝資料
此處會執行很久,甚至會報錯,如找不到 numpy 等
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ bazel build --config=opt --config=nonccl //tensorflow/tools/pip_package:build_pip_package --incompatible_remove_native_http_archive=false --verbose_failures --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
產生 tensorflow-1.13.1-cp36-cp36m-linux_aarch64.whl
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ sudo bazel-bin/tensorflow/tools/pip_package/build_pip_package ../


移除舊的 tensorflow,並安裝新的
nvidia@jetson-0423418048807:~$ source XavierSSD/envs/tensorflow/bin/activate
(tensorflow) nvidia@jetson-0423418048807:~$ cd XavierSSD/tensorflow/
((tensorflow) nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ pip3 uninstall tensorflow-gpu
(tensorflow) nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ pip3 install ../tensorflow-1.13.1-cp36-cp36m-linux_aarch64.whl
(tensorflow) nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ deactivate
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$

建立 tensorflow c++ 的 shared library libtensorflow_cc.so
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ bazel build --config=opt --config=nonccl //tensorflow:libtensorflow_cc.so --incompatible_remove_native_http_archive=false --verbose_failures --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ ls -al bazel-bin/tensorflow/
libtensorflow_cc.so
-r-xr-xr-x 1 nvidia nvidia 303026864 Jun 25 12:22 bazel-bin/tensorflow/libtensorflow_cc.so
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$

nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ mkdir tensorflow/cc/example
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ vi tensorflow/cc/example/example.cc

// tensorflow/cc/example/example.cc

#include "tensorflow/cc/client/client_session.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/tensor.h"

int main() {
  using namespace tensorflow;
  using namespace tensorflow::ops;
  Scope root = Scope::NewRootScope();
  // Matrix A = [3 2; -1 0]
  auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f} });
  // Vector b = [3 5]
  auto b = Const(root, { {3.f, 5.f} });
  // v = Ab^T
  auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true));
  std::vector<Tensor> outputs;
  ClientSession session(root);
  // Run and fetch v
  TF_CHECK_OK(session.Run({v}, &outputs));
  // Expect outputs[0] == [19; -3]
  LOG(INFO) << outputs[0].matrix<float>();
  return 0;
}
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ vi tensorflow/cc/example/BUILD

load("//tensorflow:tensorflow.bzl", "tf_cc_binary")

tf_cc_binary(
    name = "example",
    srcs = ["example.cc"],
    deps = [
        "//tensorflow/cc:cc_ops",
        "//tensorflow/cc:client_session",
        "//tensorflow/core:tensorflow",
    ],
)
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$

編譯範例 example.cc
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ bazel build -c opt //tensorflow/cc/example:example
跑了好久,測試執行
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$ bazel-bin/tensorflow/cc/exam
ple/example
2019-06-25 16:10:03.922559: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:965] ARM64 does not support NUMA - returning NUMA node zero
2019-06-25 16:10:03.922959: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: Xavier major: 7 minor: 2 memoryClockRate(GHz): 1.5
pciBusID: 0000:00:00.0
totalMemory: 15.45GiB freeMemory: 8.57GiB
2019-06-25 16:10:03.923054: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-06-25 16:10:03.924346: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-06-25 16:10:03.924409: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0
2019-06-25 16:10:03.924452: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N
2019-06-25 16:10:03.925152: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8340 MB memory) -> physical GPU (device: 0, name: Xavier, pci bus id: 0000:00:00.0, compute capability: 7.2)
2019-06-25 16:10:07.582973: I tensorflow/cc/example/example.cc:22] 19
-3
nvidia@jetson-0423418048807:~/XavierSSD/tensorflow$


nvidia@jetson-0423418048807:~/XavierSSD$ git clone https://github.com/bitbionic/
keras-to-tensorflow.git
Cloning into 'keras-to-tensorflow'...
remote: Enumerating objects: 3719, done.
remote: Total 3719 (delta 0), reused 0 (delta 0), pack-reused 3719
Receiving objects: 100% (3719/3719), 227.81 MiB | 786.00 KiB/s, done.
Resolving deltas: 100% (7/7), done.
Checking out files: 100% (3688/3688), done.
nvidia@jetson-0423418048807:~/XavierSSD$
nvidia@jetson-0423418048807:~/XavierSSD$ cd keras-to-tensorflow
nvidia@jetson-0423418048807:~/XavierSSD/keras-to-tensorflow$ vi main.c
因為編譯時會有兩種錯誤
data.ToString(); 改成 std::string(data);
tensorflow::StringPiece(file_name).ends_with(".png")
改成
tensorflow::str_util::EndsWith(file_name, ".png")

nvidia@jetson-0423418048807:~/XavierSSD/keras-to-tensorflow$
nvidia@jetson-0423418048807:~/XavierSSD/keras-to-tensorflow$ g++-5 -std=gnu++11 -c ./main.cpp -D_GLIBCXX_USE_CXX11_ABI=0     -I../tensorflow     -I../tensorflow/bazel-tensorflow/external/eigen_archive     -I../tensorflow/bazel-tensorflow/external/protobuf_archive/src     -I../tensorflow/bazel-tensorflow/external/com_google_absl     -I../tensorflow/bazel-genfiles