1. 程式人生 > >全網最詳細的基於Ubuntu14.04/16.04 + Anaconda2 / Anaconda3 + Python2.7/3.4/3.5/3.6安裝Tensorflow詳細步驟(圖文)(博主推薦)

全網最詳細的基於Ubuntu14.04/16.04 + Anaconda2 / Anaconda3 + Python2.7/3.4/3.5/3.6安裝Tensorflow詳細步驟(圖文)(博主推薦)

  不多說,直接上乾貨!

前言

  建議參照最新的tensorflow安裝步驟(Linux,官方網站經常訪問不是很穩定,所以給了一個github的地址):          https://github.com/tensorflow/tensorflow/blob/master/tensorflow/docs_src/install/install_linux.md

  最近,tensorflow網站上給出了新的使用Anaconda配置和安裝Tensorflow的步驟,經過測試,在國內可以無障礙的訪問。Anaconda 是一個基於python的科學計算包集合,目前支援Python 2.7,3.4,3.5,3.6。

  注意:在安裝過程中如果出現很長的報錯,觀察錯誤資訊的末尾,如果是網路連結相關,就重新執行一遍語句即可(如出現進度條不動的情況,也可重新執行語句),Anaconda自身約500M,tensorflow所需軟體包約幾十M。

  作業系統: Ubuntu 14.04   或  Ubuntu16.04

  這是Github官網給出的安裝步驟

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/docs_src/install/install_linux.md

 

第一步、 安裝Anaconda

  從anaconda官網(https://www.continuum.io/downloads)上下載linux版本的安裝檔案,執行完成安裝。

  我這裡是以Anaconda2-5.0.1-Linux-x86_64.sh為例,Anaconda3一樣啦。這個很簡單。

 

[email protected]:~/SoftWare$ pwd
/home/deeplearning/SoftWare
[email protected]:~/SoftWare$ ll
total 519916
drwxrwxr-x  4 deeplearning deeplearning      4096
12月 4 09:42 ./ drwxr-xr-x 17 deeplearning deeplearning 4096 12月 3 20:46 ../ -rwxrw-r-- 1 deeplearning deeplearning 532375438 12月 4 09:42 Anaconda2-5.0.1-Linux-x86_64.sh* drwxr-xr-x 8 deeplearning deeplearning 4096 8月 5 2015 jdk1.8.0_60/ drwxrwxr-x 11 deeplearning deeplearning 4096 12月 3 20:07 pycharm-2017.3/ [email protected]:~/SoftWare$ bash ./Anaconda2-5.0.1-Linux-x86_64.sh Welcome to Anaconda2 5.0.1 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>> =================================== Anaconda End User License Agreement =================================== Copyright 2015, Anaconda, Inc. All rights reserved under the 3-clause BSD License: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditio ns are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Continuum Analytics, Inc. (dba Anaconda, Inc.) ("Continuum") nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT N OT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CON TINUUM BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY TH EORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Notice of Third Party Software Licenses ======================================= Anaconda contains open source software packages from third parties. These are available on an "as is" basis and subject to their in dividual license agreements. These licenses are available in Anaconda or at https://docs.anaconda.com/anaconda/packages/pkg-docs . Any binary packages of these third party tools you obtain via Anaconda are subject to their individual licenses as well as the Anac onda license. Continuum reserves the right to change which third party tools are provided in Anaconda. In particular, Anaconda contains re-distributable, run-time, shared-library files from the Intel(TM) Math Kernel Library ("MKL bina ries"). You are specifically authorized to use the MKL binaries with your installation of Anaconda. You are also authorized to redi stribute the MKL binaries with Anaconda or in the conda package that contains them. Use and redistribution of the MKL binaries are subject to the licensing terms located at https://software.intel.com/en-us/license/intel-simplified-software-license. If needed, in structions for removing the MKL binaries after installation of Anaconda are available at http://www.anaconda.com. Anaconda also contains cuDNN software binaries from NVIDIA Corporation ("cuDNN binaries"). You are specifically authorized to use t he cuDNN binaries with your installation of Anaconda. You are also authorized to redistribute the cuDNN binaries with an Anaconda p ackage that contains them. If needed, instructions for removing the cuDNN binaries after installation of Anaconda are available at http://www.anaconda.com. Cryptography Notice =================== This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, p ossession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check you r country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See the Wassenaar Arrangement <http://www.wassenaar.org/> for more information. Continuum has self-classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information securit y software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes i t eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administ ration Regulations, Section 740.13) for both object code and source code. In addition, the Intel(TM) Math Kernel Library contained in Continuum's software is classified by Intel(TM) as ECCN 5D992b with no license required for export to non-embargoed countries. The following packages are included in this distribution that relate to cryptography: openssl The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit imp lementing the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols as well as a full-strength general purpose cr yptography library. pycrypto A collection of both secure hash functions (such as SHA256 and RIPEMD160), and various encryption algorithms (AES, DES, RSA, El Gamal, etc.). pyopenssl A thin Python wrapper around (a subset of) the OpenSSL library. kerberos (krb5, non-Windows platforms) A network authentication protocol designed to provide strong authentication for client/server applications by using secret-key cryptography. cryptography A Python library which exposes cryptographic recipes and primitives.

 

Please answer 'yes' or 'no':'
>>> yes

Anaconda2 will now be installed into this location:
/home/deeplearning/anaconda2

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/deeplearning/anaconda2] >>> 
PREFIX=/home/deeplearning/anaconda2

installing: python-2.7.14-hc2b0042_21 ...
Python 2.7.14 :: Anaconda, Inc.
installing: ca-certificates-2017.08.26-h1d4fec5_0 ...
installing: conda-env-2.6.0-h36134e3_1 ...
installing: intel-openmp-2018.0.0-h15fc484_7 ...
installing: libgcc-ng-7.2.0-h7cc24e2_2 ...
installing: libgfortran-ng-7.2.0-h9f7466a_2 ...
installing: libstdcxx-ng-7.2.0-h7a57d05_2 ...
installing: bzip2-1.0.6-h0376d23_1 ...
installing: expat-2.2.4-hc00ebd1_1 ...
installing: gmp-6.1.2-hb3b607b_0 ...
installing: graphite2-1.3.10-hc526e54_0 ...
installing: icu-58.2-h211956c_0 ...
installing: jbig-2.1-hdba287a_0 ...
installing: jpeg-9b-habf39ab_1 ...
installing: libffi-3.2.1-h4deb6c0_3 ...
installing: libsodium-1.0.13-h31c71d8_2 ...
installing: libssh2-1.8.0-h8c220ad_2 ...
installing: libtool-2.4.6-hd50d1a6_0 ...
installing: libxcb-1.12-h84ff03f_3 ...
installing: lzo-2.10-h1bfc0ba_1 ...
installing: mkl-2018.0.0-hb491cac_4 ...
installing: ncurses-6.0-h06874d7_1 ...
installing: openssl-1.0.2l-h077ae2c_5 ...
installing: patchelf-0.9-hf79760b_2 ...
installing: pcre-8.41-hc71a17e_0 ...
installing: pixman-0.34.0-h83dc358_2 ...
installing: tk-8.6.7-h5979e9b_1 ...
installing: unixodbc-2.3.4-hc36303a_1 ...
installing: xz-5.2.3-h2bcbf08_1 ...
installing: yaml-0.1.7-h96e3832_1 ...
installing: zlib-1.2.11-hfbfcf68_1 ...
installing: curl-7.55.1-hcb0b314_2 ...
installing: glib-2.53.6-hc861d11_1 ...
installing: hdf5-1.10.1-hb0523eb_0 ...
installing: libedit-3.1-heed3624_0 ...
installing: libpng-1.6.32-hda9c8bc_2 ...
installing: libtiff-4.0.8-h90200ff_9 ...
installing: libxml2-2.9.4-h6b072ca_5 ...
installing: mpfr-3.1.5-h12ff648_1 ...
installing: pandoc-1.19.2.1-hea2e7c5_1 ...
installing: readline-7.0-hac23ff0_3 ...
installing: zeromq-4.2.2-hb0b69da_1 ...
installing: dbus-1.10.22-h3b5a359_0 ...
installing: freetype-2.8-h52ed37b_0 ...
installing: gstreamer-1.12.2-h4f93127_0 ...
installing: libxslt-1.1.29-hcf9102b_5 ...
installing: mpc-1.0.3-hf803216_4 ...
installing: sqlite-3.20.1-h6d8b0f3_1 ...
installing: fontconfig-2.12.4-h88586e7_1 ...
installing: gst-plugins-base-1.12.2-he3457e5_0 ...
installing: alabaster-0.7.10-py27he5a193a_0 ...
installing: asn1crypto-0.22.0-py27h94ebe91_1 ...
installing: backports-1.0-py27h63c9359_1 ...
installing: backports_abc-0.5-py27h7b3c97b_0 ...
installing: beautifulsoup4-4.6.0-py27h3f86ba9_1 ...
installing: bitarray-0.8.1-py27h304d4c6_0 ...
installing: boto-2.48.0-py27h9556ac2_1 ...
installing: cairo-1.14.10-haa5651f_5 ...
installing: cdecimal-2.3-py27h4e63abe_1 ...
installing: certifi-2017.7.27.1-py27h9ceb091_0 ...
installing: chardet-3.0.4-py27hfa10054_1 ...
installing: click-6.7-py27h4225b90_0 ...
installing: cloudpickle-0.4.0-py27ha64365b_0 ...
installing: colorama-0.3.9-py27h5cde069_0 ...
installing: configparser-3.5.0-py27h5117587_0 ...
installing: contextlib2-0.5.5-py27hbf4c468_0 ...
installing: dask-core-0.15.3-py27h53a7ee6_0 ...
installing: decorator-4.1.2-py27h1544723_0 ...
installing: docutils-0.14-py27hae222c1_0 ...
installing: enum34-1.1.6-py27h99a27e9_1 ...
installing: et_xmlfile-1.0.1-py27h75840f5_0 ...
installing: fastcache-1.0.2-py27h4cb8e01_0 ...
installing: filelock-2.0.12-py27h38fa839_0 ...
installing: funcsigs-1.0.2-py27h83f16ab_0 ...
installing: functools32-3.2.3.2-py27h4ead58f_1 ...
installing: futures-3.1.1-py27hdbc8cbb_0 ...
installing: glob2-0.5-py27hd3b7d1f_1 ...
installing: gmpy2-2.0.8-py27hc856308_1 ...
installing: greenlet-0.4.12-py27hac09c53_0 ...
installing: grin-1.2.1-py27h54abee7_1 ...
installing: heapdict-1.0.0-py27h33770af_0 ...
installing: idna-2.6-py27h5722d68_1 ...
installing: imagesize-0.7.1-py27hd17bf80_0 ...
installing: ipaddress-1.0.18-py27h337fd85_0 ...
installing: ipython_genutils-0.2.0-py27h89fb69b_0 ...
installing: itsdangerous-0.24-py27hb8295c1_1 ...
installing: jdcal-1.3-py27h2cc5433_0 ...
installing: jedi-0.10.2-py27h8af4e35_0 ...
installing: lazy-object-proxy-1.3.1-py27h682c727_0 ...
installing: locket-0.2.0-py27h73929a2_1 ...
installing: lxml-4.1.0-py27hb025457_0 ...
installing: markupsafe-1.0-py27h97b2822_1 ...
installing: mccabe-0.6.1-py27h0e7c7be_1 ...
installing: mistune-0.7.4-py27h6da7e90_0 ...
installing: mkl-service-1.1.2-py27hb2d42c5_4 ...
installing: mpmath-0.19-py27h4bb41bd_2 ...
installing: msgpack-python-0.4.8-py27hc2fa789_0 ...
installing: multipledispatch-0.4.9-py27h9b5f95a_0 ...
installing: numpy-1.13.3-py27hbcc08e0_0 ...
installing: olefile-0.44-py27h4bd3e3c_0 ...
installing: pandocfilters-1.4.2-py27h428e1e5_1 ...
installing: path.py-10.3.1-py27hc258cac_0 ...
installing: pep8-1.7.0-py27h444351c_0 ...
installing: pkginfo-1.4.1-py27hee1a9ad_1 ...
installing: ply-3.10-py27hd6d9ae5_0 ...
installing: psutil-5.4.0-py27h7da3062_0 ...
installing: ptyprocess-0.5.2-py27h4ccb14c_0 ...
installing: py-1.4.34-py27he5894e4_1 ...
installing: pycodestyle-2.3.1-py27h904819d_0 ...
installing: pycosat-0.6.2-py27h1cf261c_1 ...
installing: pycparser-2.18-py27hefa08c5_1 ...
installing: pycrypto-2.6.1-py27h9abbf5c_1 ...
installing: pycurl-7.43.0-py27hcf8ebea_3 ...
installing: pyodbc-4.0.17-py27h7f7627d_0 ...
installing: pyparsing-2.2.0-py27hf1513f8_1 ...
installing: pysocks-1.6.7-py27he2db6d2_1 ...
installing: pytz-2017.2-py27hcac29fa_1 ...
installing: pyyaml-3.12-py27h2d70dd7_1 ...
installing: pyzmq-16.0.2-py27h297844f_2 ...
installing: qt-5.6.2-h974d657_12 ...
installing: qtpy-1.3.1-py27h63d3751_0 ...
installing: rope-0.10.5-py27hcb0a616_0 ...
installing: ruamel_yaml-0.11.14-py27h672d447_2 ...
installing: scandir-1.6-py27hf7388dc_0 ...
installing: simplegeneric-0.8.1-py27h19e43cd_0 ...
installing: sip-4.18.1-py27he9ba0ab_2 ...
installing: six-1.11.0-py27h5f960f1_1 ...
installing: snowballstemmer-1.2.1-py27h44e2768_0 ...
installing: sortedcontainers-1.5.7-py27he59936f_0 ...
installing: sphinxcontrib-1.0-py27h1512b58_1 ...
installing: sqlalchemy-1.1.13-py27hb0a01da_0 ...
installing: subprocess32-3.2.7-py27h373dbce_0 ...
installing: tblib-1.3.2-py27h51fe5ba_0 ...
installing: toolz-0.8.2-py27hd3b1e7e_0 ...
installing: typing-3.6.2-py27h66f49e2_0 ...
installing: unicodecsv-0.14.1-py27h5062da9_0 ...
installing: wcwidth-0.1.7-py27h9e3e1ab_0 ...
installing: webencodings-0.5.1-py27hff10b21_1 ...
installing: werkzeug-0.12.2-py27hbf75dff_0 ...
installing: wrapt-1.10.11-py27h04f6869_0 ...
installing: xlrd-1.1.0-py27ha77178f_1 ...
installing: xlsxwriter-1.0.2-py27h12cbc6b_0 ...
installing: xlwt-1.3.0-py27h3d85d97_0 ...
installing: babel-2.5.0-py27h20693cd_0 ...
installing: backports.shutil_get_terminal_size-1.0.0-py27h5bc021e_2 ...
installing: bottleneck-1.2.1-py27h21b16a3_0 ...
installing: cffi-1.10.0-py27hf1aaaf4_1 ...
installing: conda-verify-2.0.0-py27hf052a9d_0 ...
installing: cycler-0.10.0-py27hc7354d3_0 ...
installing: cytoolz-0.8.2-py27hf14aec9_0 ...
installing: entrypoints-0.2.3-py27h502b47d_2 ...
installing: h5py-2.7.0-py27h71d1790_1 ...
installing: harfbuzz-1.5.0-h2545bd6_0 ...
installing: html5lib-0.999999999-py27hdf15f34_0 ...
installing: llvmlite-0.20.0-py27_0 ...
installing: networkx-2.0-py27hfc23926_0 ...
installing: nltk-3.2.4-py27h41293c3_0 ...
installing: numexpr-2.6.2-py27he5efce1_1 ...
installing: openpyxl-2.4.8-py27h9f0c937_1 ...
installing: packaging-16.8-py27h5e07c7c_1 ...
installing: partd-0.3.8-py27h4e55004_0 ...
installing: pathlib2-2.3.0-py27h6e9d198_0 ...
installing: pexpect-4.2.1-py27hcf82287_0 ...
installing: pillow-4.2.1-py27h7cd2321_0 ...
installing: pycairo-1.13.3-py27hea6d626_0 ...
installing: pyqt-5.6.0-py27h4b1e83c_5 ...
installing: python-dateutil-2.6.1-py27h4ca5741_1 ...
installing: pywavelets-0.5.2-py27hecda097_0 ...
installing: qtawesome-0.4.4-py27hd7914c3_0 ...
installing: scipy-0.19.1-py27h1edc525_3 ...
installing: setuptools-36.5.0-py27h68b189e_0 ...
installing: singledispatch-3.4.0.3-py27h9bcb476_0 ...
installing: sortedcollections-0.5.3-py27h135218e_0 ...
installing: sphinxcontrib-websupport-1.0.1-py27hf906f22_1 ...
installing: ssl_match_hostname-3.5.0.1-py27h4ec10b9_2 ...
installing: sympy-1.1.1-py27hc28188a_0 ...
installing: traitlets-4.3.2-py27hd6ce930_0 ...
installing: zict-0.1.3-py27h12c336c_0 ...
installing: backports.functools_lru_cache-1.4-py27he8db605_1 ...
installing: bleach-2.0.0-py27h3a0dcc8_0 ...
installing: clyent-1.2.2-py27h7276e6c_1 ...
installing: cryptography-2.0.3-py27hea39389_1 ...
installing: cython-0.26.1-py27hdbcff32_0 ...
installing: datashape-0.5.4-py27hf507385_0 ...
installing: get_terminal_size-1.0.0-haa9412d_0 ...
installing: gevent-1.2.2-py27h475ea6a_0 ...
installing: imageio-2.2.0-py27hf108a7f_0 ...
installing: isort-4.2.15-py27hcfa4749_0 ...
installing: jinja2-2.9.6-py27h82327ae_1 ...
installing: jsonschema-2.6.0-py27h7ed5aa4_0 ...
installing: jupyter_core-4.3.0-py27hcd9ae3a_0 ...
installing: navigator-updater-0.1.0-py27h0f9cd39_0 ...
installing: nose-1.3.7-py27heec2199_2 ...
installing: numba-0.35.0-np113py27_10 ...
installing: pandas-0.20.3-py27h820b67f_2 ...
installing: pango-1.40.11-h8191d47_0 ...
installing: patsy-0.4.1-py27hd1cf8c0_0 ...
installing: pickleshare-0.7.4-py27h09770e1_0 ...
installing: pyflakes-1.6.0-py27h904a57d_0 ...
installing: pygments-2.2.0-py27h4a8b6f5_0 ...
installing: pytables-3.4.2-py27h1f7bffc_2 ...
installing: pytest-3.2.1-py27h98000ae_1 ...
installing: scikit-learn-0.19.1-py27h445a80a_0 ...
installing: testpath-0.3.1-py27hc38d2c4_0 ...
installing: tornado-4.5.2-py27h97b179f_0 ...
installing: wheel-0.29.0-py27h411dd7b_1 ...
installing: astroid-1.5.3-py27h8f8f47c_0 ...
installing: astropy-2.0.2-py27h57072c0_4 ...
installing: bkcharts-0.2-py27h241ae91_0 ...
installing: bokeh-0.12.10-py27he46cc6b_0 ...
installing: distributed-1.19.1-py27h38c4a05_0 ...
installing: flask-0.12.2-py27h6d5c1cd_0 ...
installing: jupyter_client-5.1.0-py27hbee1118_0 ...
installing: matplotlib-2.1.0-py27h09aba24_0 ...
installing: nbformat-4.4.0-py27hed7f2b2_0 ...
installing: pip-9.0.1-py27hbf658b2_3 ...
installing: prompt_toolkit-1.0.15-py27h1b593e1_0 ...
installing: pyopenssl-17.2.0-py27h189ff3b_0 ...
installing: statsmodels-0.8.0-py27hc87d62d_0 ...
installing: terminado-0.6-py27h4be8df9_0 ...
installing: dask-0.15.3-py27hb94b45f_0 ...
installing: flask-cors-3.0.3-py27h1a8a27f_0 ...
installing: ipython-5.4.1-py27h36c99b6_1 ...
installing: nbconvert-5.3.1-py27he041f76_0 ...
installing: pylint-1.7.4-py27h6bc7935_0 ...
installing: seaborn-0.8.0-py27h9d2aaa1_0 ...
installing: urllib3-1.22-py27ha55213b_0 ...
installing: ipykernel-4.6.1-py27hc93e584_0 ...
installing: odo-0.5.1-py27h9170de3_0 ...
installing: requests-2.18.4-py27hc5b0589_1 ...
installing: scikit-image-0.13.0-py27h06cb35d_1 ...
installing: anaconda-client-1.6.5-py27hc8169bf_0 ...
installing: blaze-0.11.3-py27h5f341da_0 ...
installing: conda-4.3.30-py27h6ae6dc7_0 ...
installing: jupyter_console-5.2.0-py27hc6bee7e_1 ...
installing: notebook-5.0.0-py27h3661c2b_2 ...
installing: qtconsole-4.3.1-py27hc444b0d_0 ...
installing: sphinx-1.6.3-py27hf9b1778_0 ...
installing: anaconda-project-0.8.0-py27hd7a9a97_0 ...
installing: conda-build-3.0.27-py27hff9f855_0 ...
installing: jupyterlab_launcher-0.4.0-py27h0e16d15_0 ...
installing: numpydoc-0.7.0-py27h9647a75_0 ...
installing: widgetsnbextension-3.0.2-py27hcb77dec_1 ...
installing: anaconda-navigator-1.6.9-py27hfbc306d_0 ...
installing: ipywidgets-7.0.0-py27h4fda95d_0 ...
installing: jupyterlab-0.27.0-py27h42ebfef_2 ...
installing: spyder-3.2.4-py27h04a3490_0 ...
installing: _ipyw_jlab_nb_ext_conf-0.1.0-py27h08a7f0c_0 ...
installing: jupyter-1.0.0-py27h505fd4b_0 ...
installing: anaconda-5.0.1-py27hd9359a7_1 ...
installation finished.
Do you wish the installer to prepend the Anaconda2 install location
to PATH in your /home/deeplearning/.bashrc ? [yes|no]
[no] >>> 
You may wish to edit your .bashrc to prepend the Anaconda2 install location to PATH:

export PATH=/home/deeplearning/anaconda2/bin:$PATH

Thank you for installing Anaconda2!

   因為這是一個坑,是安裝時最後一步新增環境變數的時候沒有選擇yes導致執行 conda info 時出錯,很好解決,根據錯誤提示:

  然後,緊接著去配置Anaconda2的環境變數。怎麼做呢?很簡單。

  在命令列輸入就可以了。

$ export PATH=/home/deeplearning/anaconda2/bin:$PATH

第二步、建立一個tensorflow的執行環境

# Python 2.7 (選好自己的) 
$ conda create -n tensorflow python=2.7  
  
# Python 3.4  (選好自己的)
$ conda create -n tensorflow python=3.4  
  
# Python 3.5  (選好自己的)
$ conda create -n tensorflow python=3.5  

   注意:在這一步,你也許會遇到conda: command not found

 

  遇到這個問題的時候, 


  解決方法是:

export PATH="/home/[your_name]/anaconda/bin:$PATH"

  比如我這裡是

export PATH=/home/deeplearning/anaconda2/bin:$PATH

  但是下一次重啟之後,還是會出現這個問題,所以我們要啟用下 ~/.bash_profile

. ~/.bash_profile
#或者
source ~/.bash_profile
或者source /etc/profile

 那是因為我的環境變數是如下:

 

#Anaconda2
ANACONDA2_HOME=/home/deeplearning/anaconda2
ANACONDA2_BIN=/home/deeplearning/anaconda2/bin
PATH=$PATH:$ANACONDA2_BIN
export ANACONDA2_HOME ANACONDA2_BIN PATH

   所以,

[email protected]:~$ conda create -n tensorflow python=2.7  
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /home/deeplearning/anaconda2/envs/tensorflow:

The following NEW packages will be INSTALLED:

    ca-certificates: 2017.08.26-h1d4fec5_0   
    certifi:         2017.11.5-py27h71e7faf_0
    libedit:         3.1-heed3624_0          
    libffi:          3.2.1-hd88cf55_4        
    libgcc-ng:       7.2.0-h7cc24e2_2        
    libstdcxx-ng:    7.2.0-h7a57d05_2        
    ncurses:         6.0-h9df7e31_2          
    openssl:         1.0.2m-h26d622b_1       
    pip:             9.0.1-py27ha730c48_4    
    python:          2.7.14-hdd48546_24      
    readline:        7.0-ha6073c6_4          
    setuptools:      36.5.0-py27h68b189e_0   
    sqlite:          3.20.1-hb898158_2       
    tk:              8.6.7-hc745277_3        
    wheel:           0.30.0-py27h2bc6bb2_1   
    zlib:            1.2.11-ha838bed_2       

Proceed ([y]/n)? y

 

 

第三步、在conda環境中安裝tensorflow

  在conda環境中安裝tensorflow的好處是可以便捷的管理tensorflow的依賴包。

  分為兩個步驟:啟用上一步建立的名為tensorflow的conda環境;用conda或者pip工具安裝Tensorflow,我選擇的是pip方式。

3.1 pip方式(可以這種方式來安裝)

  pip方式需要首先啟用conda環境

[email protected]:~$ source activate tensorflow
(tensorflow) [email protected]:~$ 

   然後根據要安裝的不同tensorflow版本選擇對應的一條環境變數設定export語句(作業系統,Python版本,CPU版本還是CPU+GPU版本)

# Ubuntu/Linux 64-bit, CPU only, Python 2.7  
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl  
  
# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7  
# Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.  
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl  
  
# Mac OS X, CPU only, Python 2.7:  
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.10.0-py2-none-any.whl  
  
# Mac OS X, GPU enabled, Python 2.7:  
(tensorflow)$ export TF_BINARY_URL=https://storage.googlea