jetson nano开箱环境配置(training+inference)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/vslyu/article/details/95450085

一、刷机

参照官网教程https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit,不多赘述,注意micro SD卡推荐使用速度等级为Class 10的sd卡。

二、刷机后其他的tips(网路配置+apt换源+pip换源)

网络配置

有线网的配置:

华科校园网配置(有线)参照我之前的blog:https://blog.csdn.net/vslyu/article/details/83790487,不多赘述。

无线网的配置:

USB无线网卡Nvidia推荐使用的是EDIMAX-7811,貌似看网上的有一些其他的无线网卡(比方说小米的)也可以直接用。

 apt换source

apt换source(arm architecture的hardware,教育网维护的貌似只有清华和中科大的source,推荐中科大的source,使用稳定,rep同步国外的source更新)。

备份sources.list文件:

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak 

将 /etc/apt/sources.list修改为以下内容:

deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main universe restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main universe restricted

修改完了update即可:

sudo apt update

pip换source 

pip换source(推荐清华的) 

参看https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

确认是否修改成功:

vslyu@vslyu-nano-tx:~$ more /home/vslyu/.config/pip/pip.conf                                                                                                            [global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

 Nvidia编译器nvcc的环境变量配置:


export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH
}}

三、training——tensorflow的配置(gpu版本)

tensorflow由两种配置方式:

一种为使用bazel build源码编译,该方式配置灵活,支持C/C++/Java/Go/JS的API接口可选配置,支持Intel/Nvidia/ARM等多种硬件可选配置,具体配置方法参看https://www.tensorflow.org/官网的教程,jeston系列可以看这个jetsonhacks的blog教程: http://www.jetsonhacks.com/2017/09/14/build-tensorflow-on-nvidia-jetson-tx2-development-kit/,该方式配置周期较长(笔者在志强 E2640V4@3.5GHz上面编译python的.whl文件接近花了12个小时,编译C++的接口花了一个小时)。

一种为安装已经预配置好的定制的tensorflow版本,直接pip install就可以。该方式的优点是配置简单,速度快,具体速度看网速而定,缺点是不太灵活,只能使用定制的package。这里在jetson nano上面配置tensorflow,选择Nvidia定制的版本即可(已经默认开启tensorrt的支持)。该方式安装配置参考https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html

使用Nvidia定制嵌入式jeston平台版本配置tensorflow(python3):

安装相关的依赖:

sudo apt-get install libhdf5-serial-dev hdf5-tools zlib1g-dev zip libjpeg8-dev libhdf5-dev  python3-pip

upgrade pip3:

sudo pip3 install -U pip

安装相关的python package: 

pip3 install -U numpy  
pip3 install -U h5py #大致需要半个小时
pip3 install -U grpcio absl-py py-cpuinfo psutil portpicker six mock requests gast astor termcolor

 安装tensorflow(大约需要半个小时):

sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu

 配置成功后的样子:

vslyu@vslyu-nano-tx:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>

四、inference——TensorRT的配置

pycuda的配置:https://www.jianshu.com/p/775394de61cf

https://devtalk.nvidia.com/default/topic/1056369/b/t/post/5356083/

https://docs.nvidia.com/deeplearning/sdk/tensorrt-install-guide/index.html#installing-pycuda

Jeston nano刷机后自带TensorRT的库:

export CPATH=$CPATH:/usr/local/cuda-10.0/targets/aarch64-linux/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-10.0/targets/aarch64-linux/lib/
pip3 install 'pycuda>=2017.1.1'

 

 

五、编辑工具jupyter notebook配置 

vslyu@vslyu-nano-tx:~/training$ sudo pip3  jupyter

大约需要半个小时搞定。 

 附录

pip install pip -U升级后“Import Error:cannot import name main”的错误:

参照https://blog.csdn.net/zong596568821xp/article/details/80410416

修改/usr/bin/pip:

将原来的:

from pip import main
if __name__ == '__main__':
    sys.exit(main())

修改为: 

from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__.main())

pip install pycuda的error-"src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory"

解决方法:

export CPATH=$CPATH:/usr/local/cuda/targets/aarch64-linux/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-10.0/targets/aarch64-linux/lib/

 

展开阅读全文

没有更多推荐了,返回首页