Install fastai on raspberry pi 3 b+

how do i install fastai on raspberry pi 3 b+ (raspbian stretch os). pip install fastai does not seem to work


Install all requirements before downloading & running the colab script:

sudo apt-get update # fetch latest versions before installing anything
sudo apt-get install python-pip # PIP for **python2** 
sudo apt-get install python3-pip # for **python3** 

!pip install pytorch
!pip install imgaug==0.2.7
!pip install folium==0.2.1
!pip install --upgrade pandas
!pip install --upgrade numpy

Assuming you have the dependencies above in place, try the colab script, like so:

!curl -s | bash

Hi Just follow this answer:

1 Like

I went through the forum, I did not see any specific instructions to install fastai on raspberry pi3 (b+). It would be really helpful if you could point me to a specific post that explains the steps.

Thanks for your help. It seems to work but I still have an issue. import fastai works, but import throws an error.

1 Like

Have you installed PyTorch before installing

1 Like

No, I am struggling with it. I am following the steps explained here.
My build process is taking painfully long. I ran python3 build and left it overnight. After a while my pi got stuck and the build would simply not progress. Is there any other simpler way to install pytorch on raspberry pi 3 b+?

I’m afraid,
but PyTorch is essential for so that’s something you have to solve.

When I did a quick search, I found that there is an issue with the NO_DISTRIBUTED=1 flag in the setup script that requires further work. That said, PyTorch install issue are better discussed in the PyTorch forum. Try the links below:

1 Like

Im not great at this stuff either, but I’ve been interested for a while now on firing up fastai on a Pi. I’ll give it a shot and report back here. Cheers to all helping out in this thread!

I’m currently working on getting fastai up and running on the system. From the videos I’ve found about installing Pytorch, it can take upwards of 36+ hours. I let mine run for about 24 before deciding it froze. I tried again and just let it run - it eventually kept moving and finished, so be patient.

From what I’ve learned, the Pi is likely more capable of inference than training the models, I’ll have to post an update on the performance and see whether I can apply any TPU units like Google’s Coral to up some vision detection wants I have.

Alternate option is running Fedora and following this guide.

hi man, have you got any update?

I am very interested in it.

I have my Pi 4 Module B with 4GB RAM waiting to be harnessed.

1 Like

hi Sam, have you got any update?

I have my Pi 4 Module B with 4GB RAM waiting to be harnessed.

How’s your performance review going?

No, I didn’t get it working but I also didn’t try that hard. Give it another shot and post here if you get it working. Cheers.

hi @marvin thanks for your information.

I have tried to install imgaug==0.2.7, and got this error:

error: library mach has Fortran sources but no Fortran compiler found
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-anplvpc0/scipy/';f=getattr(tokenize, 'open', open)(__file__);'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-7gm37gq1/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-anplvpc0/scipy/

hi @marvin what does the



hi @yogisin42 have you got yours working on your Pi?

I just received my new Pi4 and I followed everything @marvin mentioned, and all dependencies have been installed successfully, it’s the last step

curl -s | bash

it throws error:
Command "python egg_info" failed with error code 1 in /tmp/pip-install-0tqdx4c8/spacy/

so I run
sudo pip install fastai
to see more details and found this:

Looking in indexes:,
Collecting fastai
  Using cached
Collecting packaging (from fastai)
  Using cached
Collecting nvidia-ml-py3 (from fastai)
  Using cached
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from fastai) (3.13)
Requirement already satisfied: matplotlib in /usr/lib/python3/dist-packages (from fastai) (3.0.2)
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from fastai) (5.4.1)
Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from fastai) (1.4.1)
Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (from fastai) (0.25.3)
Requirement already satisfied: torchvision in /usr/local/lib/python3.7/dist-packages/torchvision-0.6.0a0+bb5af1d-py3.7-linux-armv7l.egg (from fastai) (0.6.0a0+bb5af1d)
Requirement already satisfied: beautifulsoup4 in /usr/lib/python3/dist-packages (from fastai) (4.7.1)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib/python3.7/dist-packages (from fastai) (1.18.1)
Requirement already satisfied: torch>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from fastai) (1.3.0a0+ee77ccb)
Collecting fastprogress>=0.2.1 (from fastai)
  Using cached
Collecting bottleneck (from fastai)
  Using cached
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from fastai) (2.21.0)
Collecting numexpr (from fastai)
  Using cached
Collecting spacy>=2.0.18 (from fastai)
  Using cached
  Installing build dependencies ... done
    Complete output from command python egg_info:
      Failed building wheel for blis
    ERROR: Failed to build one or more wheels
    Traceback (most recent call last):
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/", line 128, in fetch_build_egg
      File "/usr/lib/python3.7/", line 347, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp50x62zwq', '--quiet', 'blis<0.5.0,>=0.4.0']' returned non-zero exit status 1.
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-0d91mofz/spacy/", line 200, in <module>
      File "/tmp/pip-install-0d91mofz/spacy/", line 195, in setup_package
        cmdclass={"build_ext": build_ext_subclass},
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/", line 144, in setup
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/", line 139, in _install_setup_requires
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/", line 721, in fetch_build_eggs
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/pkg_resources/", line 783, in resolve
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/pkg_resources/", line 1066, in best_match
        return self.obtain(req, installer)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/pkg_resources/", line 1078, in obtain
        return installer(requirement)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/", line 777, in fetch_build_egg
        return fetch_build_egg(self, req)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/", line 130, in fetch_build_egg
        raise DistutilsError(str(e))
    distutils.errors.DistutilsError: Command '['/usr/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp50x62zwq', '--quiet', 'blis<0.5.0,>=0.4.0']' returned non-zero exit status 1.
Command "python egg_info" failed with error code 1 in /tmp/pip-install-0d91mofz/spacy/

Could you help please.

Well, install a Fortran compiler.

apt-cache search fortran

Essentially, it sends console output or whatever your send there to nirvana instead. The prime example is an email address dedicated to spam forward to /dev/zero

Folks I cannot really support this as I am full-time in another project.

thanks @marvin

I have figured out that issue.

Thanks for your help. Perfectly understood you are busy at other project, thanks :slight_smile:

I now only 1 step away from getting Fast.Ai installed on my Pi

The SpaCy installation keeps failing.

I have been stuck at there for the entire day…

Great, good luck.

Worth mentioning, I’m actually working on building the infrastructure for a deep learning start up. I can’t tell much due to NDA, but what I can share is this:

Once you got far enough, look into time series with GluonTS and geometric deep learning on graph data next.

Don’t miss the train before it starts …

Looks like you got a bit further than me getting Pytorch somewhat working. No updates from me.

I’ve been spending time getting a data set rolling first and foremost to get a learner trained up. Ultimately, I’ve been praying to the developer gods that someone with a comp-sci background figures it out before I do. Once I have a model that works, I’ll be putting more time into getting it on the Pi.