5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Jetson Xavier NX OpenCV & TensorFlow

Last updated at Posted at 2020-07-01

#Pythonの環境構築

##Jetpackのバージョンを確認
$sudo apt-cache show nvidia-jetpack
Package: nvidia-jetpack
Version: 4.4-b144
Architecture: arm64
Maintainer: NVIDIA Corporation

##Python3のバージョンを確認
$python3 --version
Python 3.6.9

##pipのインストール
$sudo apt install python3-pip

##virtualenvのインストール

$ mkdir tf
$ cd tf
$ sudo python3 -m pip install virtualenv
$ virtualenv env

env/bin/activateに以下の2行を追加する。

OLD_PYTHONPATH=$PYTHONPATH
export PYTHONPATH="/usr/local/lib/python3.6/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.6/dist-packages"

env/bin/postdeactivateに以下の2行を追加する。

export PYTHONPATH=$OLD_PYTHONPATH
unset OLD_PYTHONPATH

##OpenCVのインストール
JetsonHacks

$ git clone https://github.com/jetsonhacks/buildOpenCVXavier.git
$ cd buildOpenCVXavier
$ git checkout v1.0
$ ./buildOpenCV.sh

###build Examples

これはエラーになる
$ g++ -o gstreamer_view -Wall -std=c++11 gstreamer_view.cpp $(pkg-config –libs opencv)

なのでこっち
$ g++ -o gstreamer_view -Wall -std=c++11 gstreamer_view.cpp `pkg-config --cflags --libs opencv`
$ sudo ldconfig 
$ ./gstreamer_view

##tensorflowのインストール

(env) nx@nx-desktop:~/tf $ sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev
(env) nx@nx-desktop:~/tf $ sudo apt-get install -y libhdf5-serial-dev hdf5-tools zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
(env) nx@nx-desktop:~/tf $ sudo apt-get install -y openmpi-bin libopenmpi-dev
(env) nx@nx-desktop:~/tf $ sudo apt-get install -y libatlas-base-dev
(env) nx@nx-desktop:~/tf $ python3 -m pip uninstall tensorflow
(env) nx@nx-desktop:~/tf $ pip3 install -U numpy==1.16.1 future==0.17.1 grpcio absl-py py-cpuinfo psutil portpicker six mock==3.0.5 requests gast==0.2.2 h5py==2.9.0 astor termcolor protobuf keras_preprocessing==1.0.5 keras_applications==1.0.8 wrapt google-pasta setuptools testresources scipy==1.4.1

###JP_VERSION
The major and minor version of JetPack you are using, such as 42 for JetPack 4.2.2 or 33 for JetPack 3.3.1.

###TF_VERSION
The released version of TensorFlow, for example, 1.13.1.

###NV_VERSION
The monthly NVIDIA container version of TensorFlow, for example, 19.01.

$ pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow==$TF_VERSION+nv$NV_VERSION


e.g
2系
$ pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow==2.1.0+nv20.04
1系
$ pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow==1.51.2+nv20.04

###インストール後の確認
仮想環境を一旦終了して再度起動する。

(env) pi@raspberrypi:~/tf_pi $ deactivate 
pi@raspberrypi:~/tf_pi $ source env/bin/activate 
(env) pi@raspberrypi:~/tf_pi $ python3 
>>>import tensorflow
>>>

エラーにならずにインポートできればOK

##参考
https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform-release-notes/tf-jetson-rel.html#tf-jetson-rel
https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html
https://forums.developer.nvidia.com/t/official-tensorflow-for-jetson-agx-xavier/65523
https://www.tensorflow.org/tutorials/quickstart/beginner

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?