Jetson Nano开机安装官网系统及配置,安装tensorflow gpu 2.2.0开发环境搭建
1.准备一个64G高速内存卡;
2.Nvidia官网阅读Jetson nano刷机教程;
3.到官网链接下载Jetson nano的SD image(2020年7月,cuda版本10.2.89) 和对应的tensorflow gpu(tf_gpu-2.2.0+nv20.8-py3);
4.烧写SD image后,第一次进入ubuntu系统,先配置系统的国内源(/etc/apt/下有source.list文件)和python的国内源:
- 跳转到目录(cd /etc/apt)
- 备份source.list(sudo cp sources.list sources.list.bak);
- 编辑source.list(sudo gedit sources.list),清空source.list文件内容,选择下述中科大或者清华的arm64源,粘进文件,保存。(Tips:ARM源和一般源不同,需要将地址中的ubuntu改为ubuntu-ports);
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
- 更新源(sudo apt-get update)
- 更新系统(sudo apt-get upgrade)
5.配置python3的pip3国内源
- pip3国内源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
(Tips:新版的ubuntu必须使用https源。)
- 临时使用,例如从清华的镜像源去安装tensorflow库
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
- 需要修改Linux下(
~/.pip/pip.conf)文件,没有就
新建一个文件夹(文件夹名字前要加“.”,表示隐藏文件夹) 和文件
mkdir ~/.pip
sudo vi ~/.pip/pip.conf
- pip.conf文件的内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
6.安装nano编辑器(根据个人喜好选择是否安装)
sudo apt-get install nano
7.安装pip3及升级pip3
- 安装
sudo apt-get install python3-pip python3-dev
- 升级
python3 -m pip install --upgrade pip
- 打开pip3文件,如果没安装nano,就用vim打开
sudo nano /usr/bin/pip3
- 将pip3文件中的原来内容:
from pip import main
if __name__ == '__main__':
sys.exit(main())
- 替换为
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
- 修改结束后保存,运行pip3版本查看命令
pip3 -V
- 若成功,显示:
8.Jetson Nano官方镜像安装后,系统自带JetPack,cuda,cudaa,OpenCV等组件,但是需要修改下环境变量才可以使用。
- 利用nano打开 ~ 路径下.bashrc文件
sudo nano ~/.bashrc
- 文件的最最最后添加以下三行内容
export CUBA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda/bin:$PATH
- 直接生效.bashrc文件
source ~/.bashrc
- 输入nvcc -V命令进行查看版本并测试,如果显示如下信息,证明修改正确。
9.Jetson nano安装tensorflow gpu 2.20(官网简易教程)
- 安装所需的基本python包
sudo apt-get install python3-pip libhdf5-serial-dev hdf5-tools
- 安装所需的python包
sudo pip3 install -U pip testresources setuptools
- 自动更新系统,和删除卸载残余(根据个人喜好)
sudo apt-get update
sudo apt-get autoremove
- 安装所需系统包
sudo apt-get install python3-pip libhdf5-serial-dev hdf5-tools
- 安装所需系统包
sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
- 安装步骤3下载的tensorflow gpu 安装文件tensorflow gpu(tf_gpu-2.2.0+nv20.8-py3)
sudo pip3 install tensorflow-2.2.0+nv20.8-cp36-cp36m-linux_aarch64.whl
- 在Downloads文件夹下新建测试文件pyTest.py
cd ~/Downloads/
nano pyTest.py
- pyTest.py文件内容为
import tensorflow as tf
print('GPU', tf.test.is_gpu_available())
a = tf.constant(2.0)
b = tf.constant(4.0)
print(a + b)
- 执行pyTest.py文件,测试tensroflow gpu 2.2.0是否安装成功
python3 pyTest.py
- 若显示如下,证明安装成功