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

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