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.3 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. pip install tensorlayer -i https://pypi.tuna.tsinghua.edu.cn/simple (faster in China)
  27. For latest version, please install from Github.
  28. .. code-block:: bash
  29. pip3 install git+https://github.com/tensorlayer/tensorlayer.git
  30. or
  31. pip3 install https://github.com/tensorlayer/tensorlayer/archive/master.zip
  32. For developers, you should clone the folder to your local machine and put it along with your project scripts.
  33. .. code-block:: bash
  34. git clone https://github.com/tensorlayer/tensorlayer.git
  35. Alternatively, you can build from the source.
  36. .. code-block:: bash
  37. # First clone the repository and change the current directory to the newly cloned repository
  38. git clone https://github.com/tensorlayer/tensorlayer.git
  39. cd tensorlayer
  40. # Install virtualenv if necessary
  41. sudo pip3 install virtualenv
  42. # Then create a virtualenv called `venv`
  43. virtualenv venv
  44. # Activate the virtualenv
  45. ## Linux:
  46. source venv/bin/activate
  47. ## Windows:
  48. venv\Scripts\activate.bat
  49. # basic installation
  50. pip3 install .
  51. # ============= IF TENSORFLOW IS NOT ALREADY INSTALLED ============= #
  52. # for a machine **without** an NVIDIA GPU
  53. pip3 install -e ".[all_cpu_dev]"
  54. # for a machine **with** an NVIDIA GPU
  55. pip3 install -e ".[all_gpu_dev]"
  56. 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.
  57. .. code-block:: bash
  58. [stable version] pip3 install tensorlayer==1.x.x
  59. However, if you want to modify or extend TensorLayer 1.X, you can download the repository from
  60. `Github`_ and install it as follow.
  61. .. code-block:: bash
  62. cd to the root of the git tree
  63. pip3 install -e .
  64. This command will run the ``setup.py`` to install TensorLayer. The ``-e`` reflects
  65. editable, then you can edit the source code in ``tensorlayer`` folder, and ``import`` the edited
  66. TensorLayer.
  67. GPU support
  68. ==========================
  69. Thanks to NVIDIA supports, training a fully connected network on a
  70. GPU, which may be 10 to 20 times faster than training them on a CPU.
  71. For convolutional network, may have 50 times faster.
  72. This requires an NVIDIA GPU with CUDA and cuDNN support.
  73. CUDA
  74. ----
  75. The TensorFlow website also teach how to install the CUDA and cuDNN, please see
  76. `TensorFlow GPU Support <https://www.tensorflow.org/versions/master/get_started/os_setup.html#optional-install-cuda-gpus-on-linux>`_.
  77. Download and install the latest CUDA is available from NVIDIA website:
  78. - `CUDA download and install <https://developer.nvidia.com/cuda-downloads>`_
  79. ..
  80. After installation, make sure ``/usr/local/cuda/bin`` is in your ``PATH`` (use ``echo #PATH`` to check), and
  81. ``nvcc --version`` works. Also ensure ``/usr/local/cuda/lib64`` is in your
  82. ``LD_LIBRARY_PATH``, so the CUDA libraries can be found.
  83. If CUDA is set up correctly, the following command should print some GPU information on
  84. the terminal:
  85. .. code-block:: bash
  86. python -c "import tensorflow"
  87. cuDNN
  88. --------
  89. Apart from CUDA, NVIDIA also provides a library for common neural network operations that especially
  90. speeds up Convolutional Neural Networks (CNNs). Again, it can be obtained from
  91. NVIDIA after registering as a developer (it take a while):
  92. Download and install the latest cuDNN is available from NVIDIA website:
  93. - `cuDNN download and install <https://developer.nvidia.com/cudnn>`_
  94. To install it, copy the ``*.h`` files to ``/usr/local/cuda/include`` and the
  95. ``lib*`` files to ``/usr/local/cuda/lib64``.
  96. .. _TensorFlow: https://www.tensorflow.org/versions/master/get_started/os_setup.html
  97. .. _GitHub: https://github.com/tensorlayer/tensorlayer
  98. .. _TensorLayer: https://github.com/tensorlayer/tensorlayer/
  99. Windows User
  100. ==============
  101. TensorLayer is built on the top of Python-version TensorFlow, so please install Python first.
  102. Note:We highly recommend installing Anaconda. The lowest version requirements of Python is py35.
  103. `Anaconda download <https://www.continuum.io/downloads>`_
  104. GPU support
  105. ------------
  106. 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.
  107. 1. Installing Microsoft Visual Studio
  108. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  109. 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.
  110. 2. Installing CUDA
  111. ^^^^^^^^^^^^^^^^^^^^^^^
  112. Download and install the latest CUDA is available from NVIDIA website:
  113. `CUDA download <https://developer.nvidia.com/CUDA-downloads>`_
  114. We do not recommend modifying the default installation directory.
  115. 3. Installing cuDNN
  116. ^^^^^^^^^^^^^^^^^^^^^^
  117. 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:
  118. `cuDNN download <https://developer.nvidia.com/cuDNN>`_
  119. 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`)
  120. Installing TensorLayer
  121. ------------------------
  122. For TensorLayer, please refer to the steps mentioned above.
  123. .. code-block:: bash
  124. pip3 install tensorflow #CPU version
  125. pip3 install tensorflow-gpu   #GPU version (GPU version and CPU version just choose one)
  126. pip3 install tensorlayer       #Install tensorlayer
  127. Issue
  128. =======
  129. If you get the following output when import tensorlayer, please read `FQA <http://tensorlayer.readthedocs.io/en/latest/user/more.html>`_.
  130. .. code-block:: bash
  131. _tkinter.TclError: no display name and no $DISPLAY environment variable

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