1.安装tensorflow
pip
pip是一个Python的软件包安装与管理工具,安装方法如下
# Ubuntu/Linux 64-bit $ sudo apt-get install python-pip python-dev # Mac OS X $ sudo easy_install pip
安装tensorflow
# 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
python3的话
# 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
2.遇到的问题
- 导入tensorflow时出错,证明没有安装好,然后就决定卸载tensorflow
- 不管是卸载tensorflow,还是安装tensorflow,又出现了一个pip的问题
sudo pip uninstall tensorflow
- 然后重新卸载pip,并安装
$ sudo apt-get remove python-pip $ tar -xzvf pip-9.0.1.tar.gz $ cd pip-9.0.1
- 输入下面代码时会出错
$ python setup.py install
running install error: can't create or remove files in install directory因为权限不足,前面加sudo后成功。
- 再次安装tensorflow,此时又出现一个问题是
tensorflow-0.5.0-cp27-none-linux_x86_64.whl is not a supported wheel on this platform.
解决方法:
wget https://bootstrap.pypa.io/get-pip.py sudo python2.7 get-pip.py sudo python2.7 -m pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl $ python2.7最后成功!