jetsonnano配置python基本环境

开发板系统为:jetpack4.4

apt-get换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list

把里面所有内容全部删除,然后粘贴以下命令(清华源):

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

保存,打开终端输入:

sudo apt-get update

安装pip3

sudo apt-get install python3-pip python3-dev
python3 -m pip install --upgrade pip

jetsonnano带有自带python2.7和python3.6两个版本,一般都用Python3.6,所以python2.7就不配pip了。并且我没有换pip源的习惯,可通过-i + 镜像源手动换源下载。

安装tensorflow

Nvidia官方都已经配好了 https://developer.download.nvidia.cn/compute/redist/jp/v44
直接输入命令
tensorflow1.15安装(默认安装的就是gpu的版本,不需要额外指定)

sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow==1.15.2+nv20.4

tensorflow2.3安装

sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow==2.3.1+nv20.10

命令中的v44代表jetpack4.4,tensorflow==2.3.1/1.15.2代表tensorflow的版本为2.3.1/1.15.2,nv20.10代表容器为20.10。可根据上面官网自行修改自己对应的版本

安装pytorch

Nvidia官网下载pytorch安装包:https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-7-0-now-available/72048

安装pytorch1.7,自行修改版本

sudo pip3 install torch-1.7.0-cp36-cp36m-linux_aarch64.whl

安装报libmpi_cxx.so.20等错误

sudo apt-get install libopenmpi2

其它类似错误去https://pkgs.org/网站搜索一下缺少的dll包,可在Install Howto查看安装方式(有两种,一般用apt-get安装就可以了,命令如上)

安装torchvision

torchvision的安装感觉是最难的,安了好久也没成功,最终找到一个解压包
pytorch1.7对应的torchvision0.8.0或者torchvision0.8.1

链接:https://pan.baidu.com/s/1Sik_1HSGz94INlVLzZ5xBQ
提取码:xql2
复制这段内容后打开百度网盘手机App,操作更方便哦

cd到文件夹目录下

sudo python3 setup.py install

安装Pycharm

因为我用pycharm用习惯了,所以Jetsonnano也用它来编辑和修改代码(运行的话比较卡,感觉运行还是用终端好点)

官网下载Pycharm安装包:https://www.jetbrains.com/pycharm/download/#section=linux
cd到下载目录下解压文件(自行修改文件名)

sudo tar -avxf pycharm-community-2019.2.tar.gz

cd 到解压后的文件下的Bin目录,安装

./pycharm.sh

一般都会报JDK无效的错误,运行如下命令

apt-cache search openjdk
sudo apt-get install openjdk-11-jdk
which javac
file /usr/bin/javac
file /etc/alternatives/javac
file /usr/lib/jvm/java-11-openjdk-arm64/bin/javac

sudo gedit ~/.bashrc

在最后粘贴以下代码:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

保存后退出。
运行:

source ~/.bashrc

JDK就配置好了,此时再次安装pycharm

./pycharm.sh

你可能感兴趣的:(ubuntu,python,linux)