Last active
March 10, 2022 21:33
-
-
Save abishekmuthian/8d0ef5a3768c5d8d22e164863670330a to your computer and use it in GitHub Desktop.
Installing PyTorch, torchvision, spaCy, torchtext on Jetson Nanon [ARM]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script will install pytorch, torchvision, torchtext and spacy on nano. | |
# If you have any of these installed already on your machine, you can skip those. | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
#Dependencies | |
sudo apt-get install python3-setuptools | |
#Installing PyTorch | |
#For latest PyTorch refer original Nvidia Jetson Nano thread - https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/. | |
wget https://nvidia.box.com/shared/static/ncgzus5o23uck9i5oth2n8n06k340l6k.whl -O torch-1.4.0-cp36-cp36m-linux_aarch64.whl | |
sudo apt-get install python3-pip libopenblas-base | |
sudo pip3 install Cython | |
sudo pip3 install numpy torch-1.4.0-cp36-cp36m-linux_aarch64.whl | |
#Installing torchvision | |
#For latest torchvision refer original Nvidia Jetson Nano thread - https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/. | |
sudo apt-get install libjpeg-dev zlib1g-dev | |
git clone --branch v0.5.0 https://github.com/pytorch/vision torchvision # see below for version of torchvision to download | |
cd torchvision | |
sudo python setup.py install | |
cd ../ # attempting to load torchvision from build dir will result in import error | |
#Installing spaCy | |
#Installing dependency sentencepiece | |
sudo apt-get install cmake build-essential pkg-config libgoogle-perftools-dev | |
git clone https://github.com/google/sentencepiece.git | |
cd sentencepiece | |
mkdir build | |
cd build | |
cmake .. | |
make -j $(nproc) | |
sudo make install | |
sudo ldconfig -v | |
cd python | |
python3 setup.py build | |
sudo python3 setup.py install | |
cd ../../ | |
git clone https://github.com/explosion/spaCy | |
cd spaCy/ | |
export PYTHONPATH=`pwd` | |
export BLIS_ARCH=generic | |
sudo pip3 install -r requirements.txt | |
sudo python3 setup.py build_ext --inplace | |
sudo python3 setup.py install | |
python3 -m spacy download en_core_web_sm | |
cd ../ | |
#Installing torchtext | |
git clone https://github.com/pytorch/text.git | |
cd text | |
sudo pip3 install -r requirements.txt | |
sudo python3 setup.py install | |
cd ../ | |
echo "done installing PyTorch, torchvision, spaCy, torchtext" | |
Hi, I posted this more than a year ago. If I remember correctly I had issues with the pre-built packages and had to install everything by source.
If you are using this now means perhaps those issues still exist if not try following the pre-built packages before installing from source.
I'm not using spaCy on ARM currently and so I don't know the latest situation. If you can update your findings here I would appreciate it.
I finally looked in the repo and found a long list of pre-built wheels for ARM64 on sentencepiece's releases page :-)
pip3 install --no-cache-dir https://github.com/google/sentencepiece/releases/download/v0.1.96/sentencepiece-0.1.96-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Abishek_Muthian,
thanks for uploading this here – I found it searching for how to install spaCy on the Jetson Nano.
Building this sentencepiece lib takes quite a while… I guess it is strictly necessary to build it from source, is it?