ubuntu 安装TensorFlow

Posted 播种的季节

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu 安装TensorFlow相关的知识,希望对你有一定的参考价值。

1.安装pip

$ sudo apt-get install python-pip python-dev

2.安装 TensorFlow for Python 2.7

# Ubuntu/Linux 64-bit, CPU only, Python 2.7:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7. Requires CUDA toolkit 7.5 and CuDNN v4.
# For other versions, see "Install from sources" below.
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

# Mac OS X, CPU only:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl

3. 安装 TensorFlow for Python 3.4

# Ubuntu/Linux 64-bit, CPU only, Python 3.4:
$ sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4. Requires CUDA toolkit 7.5 and CuDNN v4.
# For other versions, see "Install from sources" below.
$ sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl

# Mac OS X, CPU only:
$ sudo easy_install --upgrade six
$ sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py3-none-any.whl

备注:如果之前安装过 TensorFlow < 0.7.1 的版本,应该先使用 pip uninstall 卸载 TensorFlow 和 protobuf ,保证获取的是一个最新 protobuf 依赖下的安装包.

4.测试是否安装成功

$ 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
>>>

 

以上是关于ubuntu 安装TensorFlow的主要内容,如果未能解决你的问题,请参考以下文章

普通电脑PC怎样跑TensorFlow的GPU模式

WDCP在ubunt下的安装

Mint / Ubunt日常所需命令软件安装

win10上安装ubunt18双系统过程中出现mmx64.efi not found问题

01_Ubunt14.04的安装

Ubunt 20.04 使用CDROM或ISO作为安装源