Install Theano on Raspberry Pi

"I searched all over the Internet and no one has successfully installed Theano on the Raspberry Pi. What does it feel like?"

- at the beginning

It must be said here that because there are too many pits in the installation process, the problems encountered are endless, so I can only record the impressive problems during the installation process. If there are other problems, you need to solve them yourself.

Material:

Raspberry Pi 3modelB (Raspberry Pi 3(B)), one display screen, one PC, one keyboard and mouse

Preliminary knowledge:

Linux command line basics, Python basics, Theano deep learning library basics

1. Configure the Raspberry Pi development environment

Can your raspberry pi connect to wifi? Is pip updated? Has the python version been updated? These must be done first.

2. Try sudo pip3 install theano

Of course not, I wouldn't have spent almost a week configuring it if I could. Due to the long time, I have forgotten what the specific error is, anyway, all kinds of libraries are not enough.

3. Try the conda method?

I did try the conda method. It is not easy to install Anaconda on the Raspberry Pi, because conda has released an ARM kernel distribution. I found a blog post that described how to install Anaconda on the Raspberry Pi system. , First go to the official website to download the armv7-based distribution, and then install it through the bash method. I did this on the Raspberry Pi, but unfortunately, it still failed when I called conda from the terminal. Installing conda is really difficult. Trouble, it turned out to be useless, it cost me all night.

Fourth, there is no way to continue to bite the bullet

It is not possible to install theano directly, so I need to install its dependent libraries. The first one I installed is dev, because the compilation of various dependent libraries requires him to help.

sudo apt-get install python-dev

Then continue to install the dependent library,

sudo apt-get install libopenblas-base 

sudo apt-get install libopenblas-dev

At this time, I installed theano again, and it magically did not report an error!

sudo pip3 install theano

Also, don't forget gcc,

sudo apt-get install gcc

Pretend, pretend, this is another night. . . . . .

五、你以为这就结束了吗?

安装是安装成了,你试试import一下?自然是不行的,报错了,说:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/theano/__init__.py", line 79, in <module>
    from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
  File "/usr/local/lib/python2.7/dist-packages/theano/scan_module/__init__.py", line 41, in <module>
    from theano.scan_module import scan_opt
  File "/usr/local/lib/python2.7/dist-packages/theano/scan_module/scan_opt.py", line 71, in <module>
    from theano.scan_module import scan_op
  File "/usr/local/lib/python2.7/dist-packages/theano/scan_module/scan_op.py", line 58, in <module>
    from six import iteritems, integer_types, raise_from
ImportError: cannot import name raise_from

那怎么办呢?

不过查到网上有人和我有同样的问题,我就放心了,请查阅:

https://github.com/keras-team/keras/issues/4616

那个老哥建议他不要用pip,自己下载安装,不过我直接用pip安装six没有出现什么大问题,

sudo pip3 install six

安装是成功了,不过依然调用失败,原因是树莓派会默认使用他自己的lib库中的six,我安装的版本是1.11最新版six,树莓派的版本很老了,所以还要sudo su 一下进入那个文件夹,把老版的six删了,再把咱们的新版six放进去,这样的话就ok了。

试试import theano ,终于成功了。

六、scipy老兄觉得不服

不过还没有结束,因为还有一个重要的module没有安装好,那就是scipy。。。

我先安装好再接着写吧

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325303287&siteId=291194637