一个专注于计算机编程和硬件学习的博客主

分类 jetson 下的文章

20/5
2019

jetson-nano -- 安装相关依赖库和工具、pip的配置

安装相关的依赖库和工具

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

系统里面默认是没有python3-pip的,所以需要自己安装。

pip的配置

修改配置文件

cd ~
mkdir .pip
vim .pip/pip.conf # 将上述配置内容写入配置文件即可
[global]

trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple

安装python相关的库

sudo pip3 install -U numpy  # 需要编译安装,用时很长,所以单独安装
sudo pip3 install -U grpcio absl-py py-cpuinfo psutil portpicker six mock requests gast astor termcolor

如果报这个错

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zdje0irm/h5py/

试试下面这条命令

sudo pip3 install --upgrade setuptools

+ MORE

18/5
2019

jetson-nano -- 进行简单的测试

Jetson-nano的系统已经将JetPack,cuda,cudnn,opencv等都已经安装好,不再需要额外的配置,这里简单测试一下。

系统里面自带了cudnn的测试程序,在/usr/src/cudnn_samples_v7/目录下,这里用mnistCUDNN程序进行测试。

cp -rvf /usr/src/cudnn_samples_v7/mnistCUDNN ~ # 将mnistCUDNN复制到home目录
cd ~/mnistCUDNN
make # 编译源代码
chmod a+x mnistCUDNN # 为可执行文件添加执行权限
./mnistCUDNN # 执行

上述步骤执行后,应该可以看到如下的输出:

cudnnGetVersion() : 7301 , CUDNN_VERSION from cudnn.h : 7301 (7.3.1)
Host compiler version : GCC 6.4.1
There are 1 CUDA capable devices on your machine :
device 0 : sms  1  Capabilities 5.3, SmClock 921.6 Mhz, MemSize (Mb) 3964, MemClock 12.8 Mhz, Ecc=0, boardGroupID=0
Using device 0

Testing single precision
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm ...
Fastest algorithm is Algo 1
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.324636 time requiring 3464 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.393541 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.616615 time requiring 57600 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 5.011875 time requiring 207360 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 25.143282 time requiring 203008 memory
Resulting weights from Softmax:
0.0000000 0.9999399 0.0000000 0.0000000 0.0000561 0.0000000 0.0000012 0.0000017 0.0000010 0.0000000 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 0.9999288 0.0000000 0.0000711 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 0.9999820 0.0000154 0.0000000 0.0000012 0.0000006 

Result of classification: 1 3 5

Test passed!

Testing half precision (math in single precision)
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm ...
Fastest algorithm is Algo 1
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.137136 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.157031 time requiring 3464 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.293541 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 1.024427 time requiring 207360 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 5.061406 time requiring 203008 memory
Resulting weights from Softmax:
0.0000001 1.0000000 0.0000001 0.0000000 0.0000563 0.0000001 0.0000012 0.0000017 0.0000010 0.0000001 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000714 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 1.0000000 0.0000154 0.0000000 0.0000012 0.0000006 

Result of classification: 1 3 5

Test passed!

从这个结果可以看到,jetson nano有一个显卡,cudnn版本为7.3.1。

+ MORE

16/5
2019

配置CUDA环境

jetson nano 官方已经默认安装好了 cuda10.0,也就是最新的,但是直接运行发现不成功,主要是因为cuda没有在系统环境变量中。

  • 测试命令

    • nvcc -V
  • 加入环境变量

    • sudo vim  ~/.bashrc
    • export CUBA_HOME=/usr/local/cuda-10.0
      export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH
      export PATH=/usr/local/cuda-10.0/bin:$PATH
    • 保存退出
  • source一下这个文件

    • source ~/.bashrc

CUDA就导入成功了.

+ MORE

13/5
2019

jetson-nano----换源

jetson nano官方的定制Ubuntu18.04 arm64系统,软件源为国外服务器,网速会很慢,需要换国内的ARM源。

  • 备份source.list文件

    • sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    • 为防止误操作后无法恢复,先备份原文件sources.list
  • 更换源

    • sudo vim /etc/apt/sources.list
    • 打开sources.list,将原来的内容使用”#”符号全部注释掉,然后在文件结尾出添加中国科学技术大学或清华的源 (我用的是中科大的)
  • 清华源

    • deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
      
      deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
      
      deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
      
      deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
      
      deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
      
      deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
      
      deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
      
      deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
  • 科大的源

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

替换结束后更新:

  • sudo apt-get update 
  • sudo apt-get upgrade

+ MORE