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

3 Likes

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 https://course.fast.ai/setup/colab | bash
2 Likes

Hi Just follow this answer: https://www.raspberrypi.org/forums/viewtopic.php?t=161515&start=50#p1060457

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 fastai.vision throws an error.

1 Like

Have you installed PyTorch before installing fast.ai?

1 Like

No, I am struggling with it. I am following the steps explained here. https://medium.com/hardware-interfacing/how-to-install-pytorch-v4-0-on-raspberry-pi-3b-odroids-and-other-arm-based-devices-91d62f2933c7
My build process is taking painfully long. I ran python3 setup.py 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 fast.ai 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.
https://www.youtube.com/watch?v=Ymugp9kRRT0&
https://nmilosev.svbtle.com/compling-arm-stuff-without-an-arm-board-build-pytorch-for-the-raspberry-pi

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/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\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

/dev/null

do??

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 https://course.fast.ai/setup/colab | bash

it throws error:
Command "python setup.py 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: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting fastai
  Using cached https://files.pythonhosted.org/packages/f5/e4/a7025bf28f303dbda0f862c09a7f957476fa92c9271643b4061a81bb595f/fastai-1.0.60-py3-none-any.whl
Collecting packaging (from fastai)
  Using cached https://files.pythonhosted.org/packages/98/42/87c585dd3b113c775e65fd6b8d9d0a43abe1819c471d7af702d4e01e9b20/packaging-20.1-py2.py3-none-any.whl
Collecting nvidia-ml-py3 (from fastai)
  Using cached https://www.piwheels.org/simple/nvidia-ml-py3/nvidia_ml_py3-7.352.0-py3-none-any.whl
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 https://files.pythonhosted.org/packages/41/67/347d73405b8612e436a4278f577186a8b783fe757df549ba1a82a2986727/fastprogress-0.2.2-py3-none-any.whl
Collecting bottleneck (from fastai)
  Using cached https://www.piwheels.org/simple/bottleneck/Bottleneck-1.3.1-cp37-cp37m-linux_armv7l.whl
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from fastai) (2.21.0)
Collecting numexpr (from fastai)
  Using cached https://www.piwheels.org/simple/numexpr/numexpr-2.7.1-cp37-cp37m-linux_armv7l.whl
Collecting spacy>=2.0.18 (from fastai)
  Using cached https://files.pythonhosted.org/packages/b7/f2/052bfe5861761599b5421916aba3eb0064d83145ff3072390ecdc5a836de/spacy-2.2.3.tar.gz
  Installing build dependencies ... done
    Complete output from command python setup.py 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/installer.py", line 128, in fetch_build_egg
        subprocess.check_call(cmd)
      File "/usr/lib/python3.7/subprocess.py", 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/setup.py", line 200, in <module>
        setup_package()
      File "/tmp/pip-install-0d91mofz/spacy/setup.py", line 195, in setup_package
        cmdclass={"build_ext": build_ext_subclass},
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/dist.py", line 721, in fetch_build_eggs
        replace_conflicting=True,
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 783, in resolve
        replace_conflicting=replace_conflicting
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1066, in best_match
        return self.obtain(req, installer)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1078, in obtain
        return installer(requirement)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/dist.py", line 777, in fetch_build_egg
        return fetch_build_egg(self, req)
      File "/tmp/pip-build-env-hqcbe4dr/lib/python3.7/site-packages/setuptools/installer.py", 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 setup.py 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 fast.ai far enough, look into time series with GluonTS and geometric deep learning on graph data next.

Don’t miss the train before it starts …

https://gluon-ts.mxnet.io/

https://www.dgl.ai/pages/about.html

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.