Installing spaCy in your Python virtual environment should be a piece of cake ("pip install spacy
"). Unfortunately, on the Nvidia Jetson Nano, it's a bit more complicated. SpaCy doesn't provide wheels for arm64, which means you'll have to build the package yourself:
[...] The main thing is it's arm64 and we don't distribute wheels for that, so you'll have to build from source, and I'm not sure that'll work (polm, 2021).
Unfortunately, the issues with spaCy on the Jetson Nano arise even before building from source. It turns out there are some issues with installing the thinc
package on the Jetson Nano, a dependency for spaCy. The latest version of thinc that actually runs on the Nano is version 8.0.8. Recent versions of spaCy, however, require a thinc version greater than 8.0.8. This means that, if you try to install the latest spaCy using pip install spacy
, the pip installer script will cycle through all allowed versions of thinc, failing every single one of them (because they're all greater than 8.0.8), and ultimately just giving up entirely. In this article, we'll be installing the most recent version of spaCy that works on the Jetson Nano at the time of writing: version 3.1.2. This is the last version to support thinc 8.0.8.
First, install thinc 8.0.8. A very nice person called "austinjp" provides a wheel for this version for the Jetson Nano, which means we'll save a lot of time by not having to build the package from source. Execute the three pip install
commands from the GitHub repository. This will install the thinc dependencies, as well as thinc itself:
pip install 'https://github.com/jetson-nano-wheels/python3.6-numpy-1.19.4/releases/download/v0.0.2/numpy-1.19.4-cp36-cp36m-linux_aarch64.whl'
pip install 'https://github.com/jetson-nano-wheels/python3.6-blis-0.7.4/releases/download/v0.0.1/blis-0.7.4-cp36-cp36m-linux_aarch64.whl'
pip install 'https://github.com/jetson-nano-wheels/python3.6-thinc-8.0.0/releases/download/v0.0.1/thinc-8.0.8-cp36-cp36m-linux_aarch64.whl'
I've copied the commands here in case something happens to the repository, but I advise you to check out the repository itself and copy the commands there. Maybe more recent versions are available than the ones from this article.
Then, clone spaCy from its GitHub repository. Beware that you need to clone version 3.1.2!
git clone https://github.com/explosion/spaCy --branch v3.1.2
Enter the spaCy directory (cd spaCy
). Open the file requirements.txt
and change the dependency for thinc to exactly version 8.0.8. This means the line should become thinc==8.0.8
. Save the file. Now you can go ahead and install all spaCy dependencies:
pip3 install -r requirements.txt
The dependency installer should recognise that thinc 8.0.8 is installed and install all other required dependencies as well.
Now, it's time to build spaCy from source. Building from source sounds scary - it is - but I didn't encounter any problems (yes, root is actually necessary).
sudo python3 setup.py install
Prepare to wait quite a while. In under an hour, spaCy should be compiled and installed, after which you can use it in your NLP projects.