Installing TensorFlow on Raspbian Stretch 2019-11-13 has Python compatibility problems

我与影子孤独终老i 提交于 2019-12-11 16:42:45

问题


With a new SD card and Raspbian version Stretch 2018-11-13:

sudo apt install -y python3-pip python3-dev python-virtualenv
virtualenv -p python3.5 --system-site-packages myenv
source myenv/bin/activate
pip3 install --upgrade tensorflow
$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
/home/pi/myenv/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
  return f(*args, **kwds)
/home/pi/myenv/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
  return f(*args, **kwds)
>>> 

回答1:


Check if your Python environment is already configured (requires Python 3.4, 3.5, or 3.6):

python3 --version
pip3 --version
virtualenv --version

Install these packages if necessary:

sudo apt update  
sudo apt install python3 python3-pip

TensorFlow requirements for the Raspbian operating system:

sudo apt update
sudo apt install python3-dev python3-pip  
sudo apt install libatlas-base-dev        # required for numpy  
sudo pip3 install --upgrade pip  
sudo pip3 install --upgrade virtualenv    # system-wide install  

Create a new virtual environment by choosing a Python interpreter and making a myenv directory to hold it:

virtualenv --system-site-packages -p python3 myenv

As you mentioned in your question, the python3 package version in Debian Stretch is 3.5.

Install TensorFlow (system install):

sudo pip3 install --user --upgrade tensorflow 

Verify the install:

python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

Success: TensorFlow is now installed. Read the tutorials to get started.



来源:https://stackoverflow.com/questions/54971370/installing-tensorflow-on-raspbian-stretch-2019-11-13-has-python-compatibility-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!