You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

installation.rst 7.1 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .. _installation:
  2. ============
  3. Installation
  4. ============
  5. TensorLayer has some prerequisites that need to be installed first, including
  6. `TensorFlow`_ , numpy and matplotlib. For GPU
  7. support CUDA and cuDNN are required.
  8. If you run into any trouble, please check the `TensorFlow installation
  9. instructions <https://www.tensorflow.org/versions/master/get_started/os_setup.html>`_
  10. which cover installing the TensorFlow for a range of operating systems including
  11. Mac OX, Linux and Windows, or ask for help on `tensorlayer@gmail.com <tensorlayer@gmail.com>`_
  12. or `FAQ <http://tensorlayer.readthedocs.io/en/latest/user/more.html>`_.
  13. Install TensorFlow
  14. =========================
  15. .. code-block:: bash
  16. pip3 install tensorflow-gpu==2.0.0-beta1 # specific version (YOU SHOULD INSTALL THIS ONE NOW)
  17. pip3 install tensorflow-gpu # GPU version
  18. pip3 install tensorflow # CPU version
  19. The installation instructions of TensorFlow are written to be very detailed on `TensorFlow`_ website.
  20. However, there are something need to be considered. For example, `TensorFlow`_ officially supports GPU acceleration for Linux, Mac OX and Windows at present. For ARM processor architecture, you need to install TensorFlow from source.
  21. Install TensorLayer
  22. =========================
  23. For stable version:
  24. .. code-block:: bash
  25. pip3 install tensorlayer
  26. For latest version, please install from Github.
  27. .. code-block:: bash
  28. pip3 install git+https://github.com/tensorlayer/tensorlayer.git
  29. or
  30. pip3 install https://github.com/tensorlayer/tensorlayer/archive/master.zip
  31. For developers, you should clone the folder to your local machine and put it along with your project scripts.
  32. .. code-block:: bash
  33. git clone https://github.com/tensorlayer/tensorlayer.git
  34. Alternatively, you can build from the source.
  35. .. code-block:: bash
  36. # First clone the repository and change the current directory to the newly cloned repository
  37. git clone https://github.com/tensorlayer/tensorlayer.git
  38. cd tensorlayer
  39. # Install virtualenv if necessary
  40. pip install virtualenv
  41. # Then create a virtualenv called `venv`
  42. virtualenv venv
  43. # Activate the virtualenv
  44. ## Linux:
  45. source venv/bin/activate
  46. ## Windows:
  47. venv\Scripts\activate.bat
  48. # basic installation
  49. pip install .
  50. # ============= IF TENSORFLOW IS NOT ALREADY INSTALLED ============= #
  51. # for a machine **without** an NVIDIA GPU
  52. pip install -e ".[all_cpu_dev]"
  53. # for a machine **with** an NVIDIA GPU
  54. pip install -e ".[all_gpu_dev]"
  55. If you want install TensorLayer 1.X, the simplest way to install TensorLayer 1.X is as follow. It will also install the numpy and matplotlib automatically.
  56. .. code-block:: bash
  57. [stable version] pip install tensorlayer==1.x.x
  58. However, if you want to modify or extend TensorLayer 1.X, you can download the repository from
  59. `Github`_ and install it as follow.
  60. .. code-block:: bash
  61. cd to the root of the git tree
  62. pip install -e .
  63. This command will run the ``setup.py`` to install TensorLayer. The ``-e`` reflects
  64. editable, then you can edit the source code in ``tensorlayer`` folder, and ``import`` the edited
  65. TensorLayer.
  66. GPU support
  67. ==========================
  68. Thanks to NVIDIA supports, training a fully connected network on a
  69. GPU, which may be 10 to 20 times faster than training them on a CPU.
  70. For convolutional network, may have 50 times faster.
  71. This requires an NVIDIA GPU with CUDA and cuDNN support.
  72. CUDA
  73. ----
  74. The TensorFlow website also teach how to install the CUDA and cuDNN, please see
  75. `TensorFlow GPU Support <https://www.tensorflow.org/versions/master/get_started/os_setup.html#optional-install-cuda-gpus-on-linux>`_.
  76. Download and install the latest CUDA is available from NVIDIA website:
  77. - `CUDA download and install <https://developer.nvidia.com/cuda-downloads>`_
  78. ..
  79. After installation, make sure ``/usr/local/cuda/bin`` is in your ``PATH`` (use ``echo #PATH`` to check), and
  80. ``nvcc --version`` works. Also ensure ``/usr/local/cuda/lib64`` is in your
  81. ``LD_LIBRARY_PATH``, so the CUDA libraries can be found.
  82. If CUDA is set up correctly, the following command should print some GPU information on
  83. the terminal:
  84. .. code-block:: bash
  85. python -c "import tensorflow"
  86. cuDNN
  87. --------
  88. Apart from CUDA, NVIDIA also provides a library for common neural network operations that especially
  89. speeds up Convolutional Neural Networks (CNNs). Again, it can be obtained from
  90. NVIDIA after registering as a developer (it take a while):
  91. Download and install the latest cuDNN is available from NVIDIA website:
  92. - `cuDNN download and install <https://developer.nvidia.com/cudnn>`_
  93. To install it, copy the ``*.h`` files to ``/usr/local/cuda/include`` and the
  94. ``lib*`` files to ``/usr/local/cuda/lib64``.
  95. .. _TensorFlow: https://www.tensorflow.org/versions/master/get_started/os_setup.html
  96. .. _GitHub: https://github.com/tensorlayer/tensorlayer
  97. .. _TensorLayer: https://github.com/tensorlayer/tensorlayer/
  98. Windows User
  99. ==============
  100. TensorLayer is built on the top of Python-version TensorFlow, so please install Python first.
  101. Note:We highly recommend installing Anaconda. The lowest version requirements of Python is py35.
  102. `Anaconda download <https://www.continuum.io/downloads>`_
  103. GPU support
  104. ------------
  105. Thanks to NVIDIA supports, training a fully connected network on a GPU, which may be 10 to 20 times faster than training them on a CPU. For convolutional network, may have 50 times faster. This requires an NVIDIA GPU with CUDA and cuDNN support.
  106. 1. Installing Microsoft Visual Studio
  107. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  108. You should preinstall Microsoft Visual Studio (VS) before installing CUDA. The lowest version requirements is VS2010. We recommend installing VS2015 or VS2013. CUDA7.5 supports VS2010, VS2012 and VS2013. CUDA8.0 also supports VS2015.
  109. 2. Installing CUDA
  110. ^^^^^^^^^^^^^^^^^^^^^^^
  111. Download and install the latest CUDA is available from NVIDIA website:
  112. `CUDA download <https://developer.nvidia.com/CUDA-downloads>`_
  113. We do not recommend modifying the default installation directory.
  114. 3. Installing cuDNN
  115. ^^^^^^^^^^^^^^^^^^^^^^
  116. The NVIDIA CUDA® Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. Download and extract the latest cuDNN is available from NVIDIA website:
  117. `cuDNN download <https://developer.nvidia.com/cuDNN>`_
  118. After extracting cuDNN, you will get three folders (bin, lib, include). Then these folders should be copied to CUDA installation. (The default installation directory is `C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0`)
  119. Installing TensorLayer
  120. ------------------------
  121. For TensorLayer, please refer to the steps mentioned above.
  122. .. code-block:: bash
  123. pip install tensorflow #CPU version
  124. pip install tensorflow-gpu   #GPU version (GPU version and CPU version just choose one)
  125. pip install tensorlayer       #Install tensorlayer
  126. Issue
  127. =======
  128. If you get the following output when import tensorlayer, please read `FQA <http://tensorlayer.readthedocs.io/en/latest/user/more.html>`_.
  129. .. code-block:: bash
  130. _tkinter.TclError: no display name and no $DISPLAY environment variable

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.