2018年6月9日 星期六

Donkeycar 的 Tensorflow 錯誤解決方法


既然 Raspberry Pi 3 Model B+ 無法使用 Donkeycar 的官方影像,就只好自行安裝。要在 NOOBS 成功安裝 Donkeycar 所須配件,網友 Dennis 指示以 https://github.com/wroscoe/donkey/blob/bd311a19acdc36b198882d3afbe9a023673ca007/install/make_pi_disk_img.sh 內的做法。花了數小時安裝,在啟動 Donkeycar 時,調用 Tensorflow 出現錯誤。嘗試了不同方法,最後發現轉用最新 Tensorflow 1.8.0 能解決問題。以下是我的安裝步驟:
##----------------------------------------------------------------------------------------
##  Donkey installation script for NOOBS.
##  Original version by wroscoe
##  Modified version by Pacess HO, 2018.
##----------------------------------------------------------------------------------------

##  Manually make sure the camera and I2C are enabled
sudo raspi-config

##  Standard updates (5 min)
sudo apt update -y
sudo apt upgrade -y
sudo rpi-update -y

##  Helpful libraries (2 min)
sudo apt install build-essential python3-dev python3-distlib python3-setuptools python3-pip python3-wheel -y
sudo apt install libzmq-dev -y
sudo apt install xsel xclip -y

##  Install numpy which is needed for OpenCV
pip3 install pandas
pip3 install h5py==2.8.0rc1

##  Install numpy and pandas (3 min)
sudo apt install libxml2-dev python3-lxml -y
sudo apt install libxslt-dev -y

##  Create a python virtualenv (2 min)
sudo apt install virtualenv -y
virtualenv donkey --system-site-packages --python python3
echo '##  Start donkeycar envoronment' >> ~/.bashrc
echo 'source ~/donkey/bin/activate' >> ~/.bashrc
source ~/.bashrc

##  Install redis-server (1 min)
sudo apt install redis-server

##  Install OpenCV (1 hour)
sudo apt-get install build-essential git cmake pkg-config -y
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
sudo apt-get install libxvidcore-dev libx264-dev -y
sudo apt-get install libatlas-base-dev gfortran -y

##  NOTE: this gets the dev version. Use tags to get specific version
git clone https://github.com/opencv/opencv.git --depth 1
git clone https://github.com/opencv/opencv_contrib.git --depth 1

cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D INSTALL_C_EXAMPLES=OFF \
  -D INSTALL_PYTHON_EXAMPLES=OFF \
  -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
  -D BUILD_EXAMPLES=OFF ..
make -j4
sudo make install
sudo ldconfig

##  Install tensorflow (5 min)
tf_file=tensorflow-1.8.0-cp35-none-linux_armv7l.whl
wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.8.0/${tf_file}
pip install ${tf_file}

##  Install donkey (1 min)
git clone https://github.com/wroscoe/donkey.git donkeycar
pip install -e donkeycar/[pi]

沒有留言: