可以使用提供的 Pip, Docker, Virtualenv, Anaconda 或 源碼編譯的方法安裝 TensorFlow.
我是在Ubuntu16的系統下使用pip安裝的,python2.7,安裝的事tensorflow1.0,以下實例演示簡單敘述一下。
首先,Pip安裝
<a href="https://en.wikipedia.org/wiki/Pip_(package_manager)" rel="nofollow" "="">Pip 是一個 Python 的軟件包安裝與管理工具.
python2.7版本
# Ubuntu/linux 64-bit$ sudo apt-get install python-pip python-devpython3.x版本
# Ubuntu/Linux 64-bit$ sudo apt-get install python-pip3 python-dev接著,tensorflow安裝
# Ubuntu/Linux 64-bit, CPU only, Python 2.7:$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_gpu-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7. Requires CUDA toolkit 8.0 and CuDNN v5.# For other versions, see "Install from sources" below.$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl這一步需要翻墻,否則會報錯
還有一種辦法:
$ sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow或者
$ sudo pip install -i http://pypi.douban.com/simple tensorflow記者加sudo權限,否則會報錯
最后,測試tensorflow安裝是否成功打開終端
$ python>>> import tensorflow as tf>>> hello = tf.constant('Hello, TensorFlow!')>>> sess = tf.session()>>> PRint sess.run(hello)Hello, TensorFlow!>>> a = tf.constant(10)>>> b = tf.constant(32)>>> print sess.run(a+b)42>>>
新聞熱點
疑難解答