【剁手系列】Jetson Nano(四)跑通jetson-inference

这篇文章介绍怎么安装英伟达的AI学习库Jetson-Inference

(一)下载jetson-inference

剩下的过程就比较简单了。首先如果您没有安装git和cmake,先安装它们

sudo apt-get install git cmake

接着从git上克隆jetson-inference

git clone https://github.com/dusty-nv/jetson-inference
cd jetson-inference
git submodule update --init

(二)关键点

下面开始有分流了,有两种方法
第一种,直接可以下载网络模型的,可以直接配置cmake,选择你要下载的模型,以及是否安装pytorch等。

mkdir build
cd build
cmake ../

第二种,通过浏览器下载
进入tools这个目录,里面有download-models.sh这个文件,用gedit打开
根据函数里的网址,一个一个下好,我是在jetson-inference目录下新建了downloads这个文件夹,并把下载好的文件放在这个文件夹下面
然后修改刚刚打开的文件,找到attempt_download_file和attempt_download_archive这两个函数进行修改,修改完代码如下:

function attempt_download_file()
{
	local filename=$1
	
	if [ -e ../downloads/$filename ]
	then
		local wget_status=0
	else
		local wget_status=1
	fi
	
	local wget_status=$?

	if [ $wget_status != 0 ]; then
		echo "$LOG No such file '$filename' (error code=$wget_status)"
		return $wget_status
	fi

	mv ../downloads/$filename $OUTPUT_DIR
	return 0
}


function attempt_download_archive()
{
	local filename=$1
	
	if [ -e ../downloads/$filename ]
	then
		local wget_status=0
	else
		local wget_status=1
	fi

	if [ $wget_status != 0 ]; then
		echo "$LOG No such file '$filename' (error code=$wget_status)"
		return $wget_status
	fi

	tar -xzf ../downloads/$filename -C $OUTPUT_DIR

	local tar_status=$?

	if [ $tar_status != 0 ]; then
		echo "$LOG tar failed to extract '$filename' (error code=$tar_status)"
		return $tar_status
	fi

	rm ../downloads/$filename
	return 0
}

对于pytorch,则是另外一个install-pytorch.sh文件,找到网址,将whl下载下来,自己安装一下就行了,到时候在选择安装pytorch的界面别选就行了。
最后还是老套路,cmake,记住上面提到的事项。

mkdir build
cd build
cmake ../

cmake成功后,就需要编译了

cd jetson-inference/build			
make
sudo make install

(三)测试

cd jetson-inference/build/aarch64/bin
./detectnet-console peds_0.jpg output_0.jpg

结果如下

detectNet -- loading detection network model from:
          -- model        networks/SSD-Mobilenet-v2/ssd_mobilenet_v2_coco.uff
          -- input_blob   'Input'
          -- output_blob  'NMS'
          -- output_count 'NMS_1'
          -- class_labels networks/SSD-Mobilenet-v2/ssd_coco_labels.txt
          -- threshold    0.500000
          -- batch_size   1

[TRT]   TensorRT version 5.1.6
[TRT]   loading NVIDIA plugins...
[TRT]   Plugin Creator registration succeeded - GridAnchor_TRT
[TRT]   Plugin Creator registration succeeded - NMS_TRT
[TRT]   Plugin Creator registration succeeded - Reorg_TRT
[TRT]   Plugin Creator registration succeeded - Region_TRT
[TRT]   Plugin Creator registration succeeded - Clip_TRT
[TRT]   Plugin Creator registration succeeded - LReLU_TRT
[TRT]   Plugin Creator registration succeeded - PriorBox_TRT
[TRT]   Plugin Creator registration succeeded - Normalize_TRT
[TRT]   Plugin Creator registration succeeded - RPROI_TRT
[TRT]   Plugin Creator registration succeeded - BatchedNMS_TRT
[TRT]   completed loading NVIDIA plugins.
[TRT]   detected model format - UFF  (extension '.uff')
[TRT]   desired precision specified for GPU: FASTEST
[TRT]   requested fasted precision for device GPU without providing valid calibrator, disabling INT8
[TRT]   native precisions detected for GPU:  FP32, FP16
[TRT]   selecting fastest native precision for GPU:  FP16
[TRT]   attempting to open engine cache file networks/SSD-Mobilenet-v2/ssd_mobilenet_v2_coco.uff.1.1.GPU.FP16.engine
[TRT]   loading network profile from engine cache... networks/SSD-Mobilenet-v2/ssd_mobilenet_v2_coco.uff.1.1.GPU.FP16.engine
[TRT]   device GPU, networks/SSD-Mobilenet-v2/ssd_mobilenet_v2_coco.uff loaded
[TRT]   Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[TRT]   device GPU, CUDA engine context initialized with 3 bindings
[TRT]   binding -- index   0
               -- name    'Input'
               -- type    FP32
               -- in/out  INPUT
               -- # dims  3
               -- dim #0  3 (CHANNEL)
               -- dim #1  300 (SPATIAL)
               -- dim #2  300 (SPATIAL)
[TRT]   binding -- index   1
               -- name    'NMS'
               -- type    FP32
               -- in/out  OUTPUT
               -- # dims  3
               -- dim #0  1 (CHANNEL)
               -- dim #1  100 (SPATIAL)
               -- dim #2  7 (SPATIAL)
[TRT]   binding -- index   2
               -- name    'NMS_1'
               -- type    FP32
               -- in/out  OUTPUT
               -- # dims  3
               -- dim #0  1 (CHANNEL)
               -- dim #1  1 (SPATIAL)
               -- dim #2  1 (SPATIAL)
[TRT]   binding to input 0 Input  binding index:  0
[TRT]   binding to input 0 Input  dims (b=1 c=3 h=300 w=300) size=1080000
[TRT]   binding to output 0 NMS  binding index:  1
[TRT]   binding to output 0 NMS  dims (b=1 c=1 h=100 w=7) size=2800
[TRT]   binding to output 1 NMS_1  binding index:  2
[TRT]   binding to output 1 NMS_1  dims (b=1 c=1 h=1 w=1) size=4
device GPU, networks/SSD-Mobilenet-v2/ssd_mobilenet_v2_coco.uff initialized.
W = 7  H = 100  C = 1
detectNet -- maximum bounding boxes:  100
detectNet -- loaded 91 class info entries
detectNet -- number of object classes:  91
[image] loaded './images/peds_0.jpg'  (1920 x 1080, 3 channels)
4 objects detected
detected obj 0  class #1 (person)  confidence=0.984694
bounding box 0  (1073.928711, 108.778038)  (1396.850952, 1002.921448)  w=322.922241  h=894.143433
detected obj 1  class #1 (person)  confidence=0.699254
bounding box 1  (458.434509, 122.990280)  (741.858093, 943.342163)  w=283.423584  h=820.351868
detected obj 2  class #1 (person)  confidence=0.975855
bounding box 2  (742.781067, 160.996078)  (1022.465393, 941.796326)  w=279.684326  h=780.800232
detected obj 3  class #1 (person)  confidence=0.863392
bounding box 3  (1477.790283, 149.502762)  (1720.689331, 914.901855)  w=242.899048  h=765.399109

[TRT]   ------------------------------------------------
[TRT]   Timing Report networks/SSD-Mobilenet-v2/ssd_mobilenet_v2_coco.uff
[TRT]   ------------------------------------------------
[TRT]   Pre-Process   CPU   0.09542ms  CUDA   0.77667ms
[TRT]   Network       CPU 117.64365ms  CUDA 116.89984ms
[TRT]   Post-Process  CPU   0.08344ms  CUDA   0.08234ms
[TRT]   Visualize     CPU  16.16084ms  CUDA  16.58760ms
[TRT]   Total         CPU 133.98334ms  CUDA 134.34645ms
[TRT]   ------------------------------------------------

[TRT]   note -- when processing a single image, run 'sudo jetson_clocks' before
                to disable DVFS for more accurate profiling/timing measurements

detectnet-console:  writing 1920x1080 image to 'output0.jpg'
detectnet-console:  successfully wrote 1920x1080 image to 'output0.jpg'
detectnet-console:  shutting down...
detectnet-console:  shutdown complete

在这里插入图片描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值