博客搬移到:https://blog.csdn.net/u013171226/article/details/107680338
一.首先登錄github,在github上搜索pytorch,然后pytorch下面的說明中中可以看到如下內容
Installation
Binaries
Commands to install from binaries via Conda or pip wheels are on our website: https://pytorch.org
NVIDIA Jetson platforms
Python wheels for NVIDIA's Jetson Nano, Jetson TX2, and Jetson AGX Xavier are available via the following URLs:
- Stable binaries:
- Rolling weekly binaries:
They require JetPack 4.2 and above, and @dusty-nv maintains them
From Source
If you are installing from source, you will need a C++14 compiler. Also, we highly recommend installing an Anaconda environment. You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro.
Once you have Anaconda installed, here are the instructions.
If you want to compile with CUDA support, install
- NVIDIA CUDA 9.2 or above
- NVIDIA cuDNN v7 or above
- Compiler compatible with CUDA
If you want to disable CUDA support, export environment variable USE_CUDA=0
. Other potentially useful environment variables may be found in setup.py
.
If you are building for NVIDIA's Jetson platforms (Jetson Nano, TX1, TX2, AGX Xavier), Instructions to install PyTorch for Jetson Nano are available here
二.點擊上面的available here跳轉到nvidia網站,
可以在網站上下載whl文件,然后按照下面步驟進行安裝
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev pip3 install Cython pip3 install numpy torch-1.4.0-cp36-cp36m-linux_aarch64.whl
我安裝的時候前面兩步都沒成功,就直接安裝了torch
三.測試
用下面命令進行測試
python3
import torch
四.錯誤
錯誤1:OSError: libmpi_cxx.so.20: cannot open shared object file: No such file or directory
sudo apt-get update
apt-get install libopenmpi-dev
再次import torch發現上面的錯誤消失,但是出現下面的錯誤
錯誤2:ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory
sudo apt-get install libopenblas-dev
然后import torch,上面錯誤消失,出現如下新錯誤。
錯誤3:提示Segmentation fault(core dumped) no moudle named torch.
然后從網上搜索了各種方法,嘗試了如下的方法:https://blog.csdn.net/sparkexpert/article/details/77675581,把兩個庫重命名了一下,
然后繼續
gdb python
r -c "import torch"
出現如下錯誤提示
嘗試用如下方法,
sudo apt-get upgrade libapt-pkg
然后系統各種不正常了,於是又重新刷機了,
五:成功的方法
然后放棄上面的方法,重新下載torch1.6,https://forums.developer.nvidia.com/t/pytorch-for-jetson-nano-version-1-5-0-now-available/72048
下載torch需要FQ,去github上下載個藍燈,https://github.com/getlantern/lantern 。安裝藍燈之后就可以FQ下載了(有同學評論torch下載失敗,我才想起來我一直是在fq,於是筆記上補充上這一行)
torch 1.6安裝成功。
然后安裝torch1.6對應的torchvision。筆記如下:https://www.cnblogs.com/cumtchw/p/13279051.html