root@server:~$ uname -a
Linux root-desktop 4.9.253-tegra #1 SMP PREEMPT Mon Jul 26 12:13:06 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux
autopilot@server:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
root@server:~$ sudo jetson_release -v
- NVIDIA Jetson Nano (Developer Kit Version)
* Jetpack 4.6 [L4T 32.6.1]
* NV Power Mode: MAXN - Type: 0
* jetson_stats.service: active
- Board info:
* Type: Nano (Developer Kit Version)
* SOC Family: tegra210 - ID:33
* Module: P3448-0000 - Board: P3449-0000
* Code Name: porg
* Boardids: 3448
* CUDA GPU architecture (ARCH_BIN): 5.3
* Serial Number: 1420221073321
- Libraries:
* CUDA: 10.2.300
* cuDNN: 8.2.1.32
* TensorRT: 8.0.1.6
* Visionworks: 1.6.0.501
* OpenCV: 4.1.1 compiled CUDA: NO
* VPI: ii libnvvpi1 1.1.15 arm64 NVIDIA Vision Programming Interface library
* Vulkan: 1.2.70
- jetson-stats:
* Version 3.1.1
* Works on Python 2.7.17
root@server:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Feb_28_22:34:44_PST_2021
Cuda compilation tools, release 10.2, V10.2.300
Build cuda_10.2_r440.TC440_70.29663091_0
由于Nvidia Jetson AGX Xavier
是arrch64架构
所以无法安装Anaconda
,可以用Miniforge
代替
Nvidia Jetson AGX Xavier用Miniforge代替Anaconda,下载Miniforge-pypy3-4.10.3-10-Linux-aarch64.sh
用以下命令安装即可
sh Miniforge-pypy3-4.10.3-10-Linux-aarch64.sh
安装完成后需要配置环境变量(同Anaconda
)
vim ~/.bashrc
在最后一行加上
export PATH=$PATH:/home/your_path/Miniforge/bin
然后保存更改,运行即可
source ~/.bashrc
创建虚拟环境并激活(由于arrch64
的Pytorch
是由python3.6
编译,所以这里Python
选择3.6
版本)
conda create -n swin python=3.6
conda activate swin
注:由于Nvidia Jetson
使用的是arrch64
,并不是所有的库都可以用pip install进行编译安装,若要成功安装Pytorch
及其依赖库首先需要安装大量依赖
opencv-python
:JetPack 4.5.1
上的 Python 3.6
预装了 4.1.1
numpy: 1.13
(最新1.19.5
)matplotlib
: (Python 3.6
编译的最新版为 3.3.4
)pandas
: 0.22.0 (最新t 1.1.5
)scipy
: 0.19.1 (最新1.5.4
)安装所需相关依赖项
sudo apt install -y python3-pip python3-venv python3-dev libpython3-dev
sudo apt install -y libopenblas-base
sudo apt install -y gfortran libopenmpi-dev liblapack-dev libatlas-base-dev
安装Cython
pip3 install Cython
升级pip
和protobuf
pip3 install --upgrade pip
pip3 install --upgrade protobuf
升级numpy
和pandas
pip3 install --upgrade numpy
pip3 install --upgrade pandas
升级matplotlib
到3.3.4
(matplotlib 3.4
要求python>=3.7
)
pip3 install matplotlib==3.3.4
升级scipy
(可能时间较长)
pip3 install --upgrade scipy
安装 scikit-image
(可能时间较长)
pip3 `install` sklearn scikit-image
Nvidia官方Pytorch编译文件下载
wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl -O torch-1.8.0-cp36-cp36m-linux_aarch64.whl
我这里选择 torch-1.8.0-cp36-cp36m-linux_aarch64.whl
运行以下命令等待安装完成
pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl
安装完成后执行
python3 -c 'import torch; print(torch.cuda.is_available())'
或者打开Python
终端
>>>import torch
>>>torch.cuda.is_available()
这里应该输出True
不报错这一步可略,若报错:Illegal instruction (core dumped)
(这个错误可能与Numpy 1.19.5
或者OpenBLAS
依赖有关),需修改环境变量,执行
(或者把Numpy版本到1.19.4)
vim ~/.bashrc
在最后一行加上
export OPENBLAS_CORETYPE=ARMV8
然后保存更改,运行即可
source ~/.bashrc
Pytorch
官方github
的torch
和torchvision
版本对照表
根据上表,所以这里选择torchvision0.9.0
安装相关依赖
sudo apt install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
安装pillow
pip3 install --upgrade pillow
安装torchvision
git clone --branch v0.9.0 https://github.com/pytorch/vision torchvision
cd torchvision
export BUILD_VERSION=0.9.0
python3 setup.py install --user
若没有克隆Swin-Transformer-Object-Detection
仓库需要先克隆仓库 或 下载压缩包解压
git clone https://github.com/SwinTransformer/Swin-Transformer-Object-Detection.git
cd Swin-Transformer-Object-Detection
安装mmcv
(可能会在Building wheel for …
卡很长一段时间,可以先去喝杯茶)
pip3 install mmcv-full
安装mmdetection
(这里要安装Swin-Transformer-Object-Detection
仓库中的mmdet
而不是mmdetection
官方的,否则可能会出现
关键字 'embed_dim'
和'ape'
等错误)
pip3 install -r requirements.txt
pip3 install -v -e . (python setup.py develop)
执行如下命令安装即可,最后一行命令一定要复制全不要漏掉最后的./
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
https://zhangkaifang.blog.csdn.net/article/details/106710163
https://cognitivexr.at/blog/2021/03/11/installing-pytorch-and-yolov5-on-an-nvidia-jetson-xavier-nx.html
https://zhuanlan.zhihu.com/p/398439154