jetson tx1使用记录

来源:互联网 发布:教师个人网络研修计划 编辑:程序博客网 时间:2024/05/14 02:56

配置

硬件配置

GPIO、I2C、I2S、SPI、带流控制的TTL UART等接口,摄像头扩展头,PCIe x4接口,USB 2.0 Client/Host接口

软件配置

  • 操作系统
    操作系统为 Ubuntu 16.04.1 LTS
  • 开发环境搭建
    (1)登录一台运行Ubuntu 14.04 Linux 64-bit 系统的电脑
    (2)通过usb连接jeson tx1
    (3)在 https://developer.nvidia.com/embedded/downloads上下载JetPack for L4T
    (4)ctrl+alt+t打开终端
    (5)在Host电脑上为JetPack安装包添加运行权限并执行
    (6)运行JetPack,根据引导完成安装。
    搭建完成后,jetson tx1上运行L4T 24.2 (Ubuntu 16.04) OpenCV4Tegra CUDA 8.0 cuDNN v5.1

Caffe

Caffe安装

sudo add-apt-repository universesudo apt-get update –y/bin/echo -e "\e[1;32mLoading Caffe Dependencies.\e[0m"sudo apt-get install cmake –ysudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev \libhdf5-serial-dev protobuf-compiler –ysudo apt-get install --no-install-recommends libboost-all-dev –ysudo apt-get install libatlas-base-dev –ysudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev –ysudo apt-get install python-dev python-numpy -ysudo usermod -a -G video $USER/bin/echo -e "\e[1;32mCloning Caffe into the home directory\e[0m"cd $HOMEgit clone https://github.com/BVLC/caffe.git cd caffe cp Makefile.config.example Makefile.configcmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFFecho "INCLUDE_DIRS += /usr/include/hdf5/serial/" >> Makefile.config/bin/echo -e "\e[1;32mCompiling Caffe\e[0m"make -j4 all/bin/echo -e "\e[1;32mRunning Caffe Tests\e[0m"make -j4 runtest

若opencv 有问题,更换opencv版本,修改CMakeList.txt如下
这里写图片描述

Opencv_DIR为你自己编译的opencv build 目录
参考http://blog.csdn.net/haizimin/article/details/51927386

Caffe使用案例

MNIST

MNIST 是由Yann LeCun 创建的一个手写数字数据库,手写数字包括0~9共10类数字,有60000幅训练图像以及10000幅测试图像。
官方网站:http://yann.lecun.com/exdb/mnist/。
获得MNIST数据集

# cd ./data/mnist#./get_mnist.sh

生成训练及测试数据,将样本转为leveldb格式

# cd ./examples/mnist# ./create_mnist.sh

执行该命令后在当前路径下生成两个目录,mnist_test_lmdb及mnist_train_lmdb
训练及测试

# cd ./examples/mnist/data/mnist# ./train_lenet.sh

本次训练使用60000幅图像迭代了10000次,同时测试了识别10000幅图像,正确率为99.05%。
同时,程序分别生成训练迭代5000次及10000次的模型文件

Cifar-10

cifar-10是由Hinton等人整理的用于目标识别的图像数据集。该数据集中总共有10类目标,每一类有 6000 幅32x32 的彩色图像组成,共60000幅。其中50000幅用于训练,每一类中随机选出1000幅,共10000幅图片用于测试。
获得cifar-10 数据集

# cd ./data/cifar10# ./get_cifar10.sh

共下载得到6个batch文件,其中5个用于训练,一个用于测试。每个batch有10000幅图像。
生成训练及测试数据,将样本转为leveldb格式

# cd ./examples/cifar10# ./create_cifar10.sh

生成cifar10_train_lmdb、cifar10_test_lmdb两个目录及均值文件mean.binaryproto
训练及测试

# cd ./examples/cifar10# ./train_full.sh

本次训练使用50000幅图像迭代了68000次,同时测试了识别10000幅图像,正确率为81.51%。

py-faster-rcnn

1、git clone –recursive https://github.com/rbgirshick/py-faster-rcnn.git
2、

cd py-faster-rcnn/libMake

3、编译caffe,先修改 cudnn 为cudnn 3

cd caffe-fast-rcnncmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFFmake –j8 allmake pycaffe

4.
http://stackoverflow.com/questions/31328436/typeerror-constructor-returned-null-while-importing-pyplot-in-ssh
5.

cd .././data/scripts/fetch_faster_rcnn_models.sh./tools/demo.py

plate_recog_caffe

1、 修改CMakeLists.txt
2、 Cmake ../
3、 Make
4、 报错
解决:https://github.com/muupan/dqn-in-the-caffe/issues/3
5、运行

GPU使用情况

在tx1上我们无法使用nvidia-smi查看GPU使用情况,这里要使用sudo ~/tegrastats
EMC – memory controller
AVP – audio/video processor
VDE – video decoder engine
GR3D – GPU

vnc使用

1.apt-get install vnc4server
2.$sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
3.然后修改xstartup文件(/home/Ubuntu/.vnc)

#!/bin/sh# Uncomment the following two lines for normal desktop:export XKL_XMODMAP_DISABLE=1 unset SESSION_MANAGER# exec /etc/X11/xinit/xinitrcunset DBUS_SESSION_BUS_ADDRESSgnome-panel &gnmoe-settings-daemon &metacity &nautilus &gnome-terminal &

4.vncserver
5.windows上下载客户端连接

更换cudnn

tar zxvf <cudnn v4 tar file> Copy files ininclude” dir and “lib” dir into /usr/local/cuda/include/ and /usr/local/cuda/lib/

opencv

1.安装使用下载 OpenCV for Linux/Mac (Version 3.1),然后

sudo apt-add-repository universesudo apt-get update# Some general development librariessudo apt-get install -y build-essential make cmake cmake-curses-gui g++# libav video input/output development librariessudo apt-get install -y libavformat-dev libavutil-dev libswscale-dev# Video4Linux camera development librariessudo apt-get install -y libv4l-dev# Eigen3 math development librariessudo apt-get install -y libeigen3-dev# OpenGL development libraries (to allow creating graphical windows)sudo apt-get install -y libglew1.6-dev# GTK development libraries (to allow creating graphical windows)sudo apt-get install -y libgtk2.0-dev# Compile and install opencvcd ~mkdir srccd srcunzip ~/Downloads/opencv-3.1.0.zipcd opencv-3.1.0mkdir buildcd buildcmake -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON -DCMAKE_INSTALL_PREFIX=/home/ubuntu/opencv-3.1.0 ..make -j4 install

因为cuda8与opencv3不兼容会报错
这里写图片描述
解决办法:修改 ~/opencv/modules/cudalegacy/src/graphcuts.cpp文件内容,如图:
这里写图片描述

2、测试
test.c

#include "opencv/highgui.h"int main(int argc,char** argv){        IplImage* img= cvLoadImage(argv[1]);        cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);        cvShowImage("Example1",img);        cvWaitKey(0);        cvReleaseImage(&img);        cvDestroyWindow("Example1");}

编译文件

g++ test.c -o test `pkg-config --libs --cflags opencv`
0 0
原创粉丝点击