[樹莓] 樹莓派3B+ 安裝Keras
直接下指令pip install keras,會出現keras requires tensorflow 2.2 or higher.
總之要使用keras需要tensorflow 2.2以上的版本。
在此做一下記錄,注意!我是在樹莓派3B+上實作的。
指令 安裝tensorflow 2.4.0-cp37-none-linux_armv7l版本:
$ sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev gcc gfortran python-dev libgfortran5 \ libatlas3-base libatlas-base-dev libopenblas-dev libopenblas-base libblas-dev \ liblapack-dev cython libatlas-base-dev openmpi-bin libopenmpi-dev python3-dev $ sudo pip3 install keras_applications==1.0.8 --no-deps $ sudo pip3 install keras_preprocessing==1.1.0 --no-deps $ sudo pip3 install h5py==2.9.0 $ sudo pip3 install pybind11 $ pip3 install -U --user six wheel mock
$ pip3 install -U --ignore-installed wrapt enum34 simplejson netaddr (這行不執行會出現:Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.) 到此下載:https://github.com/lhelontra/tensorflow-on-arm/releases (點選tensorflow-2.4.0-cp37-none-linux-armv7l.whl, 或參考資料裡有備份此檔供下載) $ sudo -H pip3 install tensorflow-2.4.0-cp37-none-linux_armv7l.whl
安裝完tensorflow以後再下指令安裝keras:
sudo pip3 install keras
就可以了
目前import 以下keras的LIB是沒問題的:
import keras
from keras.layers import Dense, Dropout, Input
from keras.models import Model,Sequential
from keras.datasets import mnist
from tqdm import tqdm
from keras.layers.advanced_activations import LeakyReLU
from keras.optimizers import Adam
PS: Adam的A要大寫喔,輸入adam會出錯
參考 references:
主要參考
https://github.com/PINTO0309/Tensorflow-bin/#usage
解決ERROR: Cannot uninstall 'wrapt'
備份tensorflow-2.4.0-cp37-none-linux-armv7l.whl
https://drive.google.com/file/d/1zmNgt6K-tNgJq2ethog-OgVuOl8dh2Rh/view?usp=sharing
其他
留言
張貼留言