我要评分
获取效率
正确性
完整性
易理解

Installation from Source Code

The process of building and installing TensorFlow 1.15.5 source code includes installing dependencies, obtaining source code, configuring related options, and building and installing the pip software package.

  1. Use PuTTY to log in to the server as the root user.
  2. Go to the compilation path for TensorFlow source code.
    1
    cd /path/to/tensorflow
    
  3. Install the dependencies.
    1
    2
    3
    4
    5
    6
    pip3 install wheel
    pip3 install Cython==0.29.14
    pip3 install numpy==1.18.5 --no-build-isolation
    pip3 install h5py==2.8.0
    pip3 install protobuf==3.19.0
    pip3 install keras_preprocessing==1.1.2
    
  4. Configure the proxy for Git.
    1
    2
    3
    git config --global http.sslVerify false
    git config --global https.sslverify false
    git config --global http.proxy "http://Username:Password@Proxy_IP_address:Proxy_port"
    
  5. If the environment variable configuration has been loaded, skip this step. Set the Bazel and Python environment variables based on the actual installation path. Example:
    1
    2
    3
    export PATH=/path/to/bazel/bazel-0.26.1/output:$PATH
    export PATH=/usr/local/python3.7.5/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
    
  6. Obtain the TensorFlow 1.15.5 source code.
    1
    wget https://github.com/tensorflow/tensorflow/archive/refs/tags/v1.15.5.zip --no-check-certificate
    
  7. Decompress the TensorFlow source package and go to the decompressed directory.
    1
    2
    unzip v1.15.5.zip
    cd tensorflow-1.15.5
    
  8. Run configure to set the configuration options.
    1
    ./configure
    

    The configuration procedure is as follows:

    1. Confirm the location of the Python executable program.
      1
      Please specify the location of python. [Default is /usr/bin/python]:
      

      If the Python 3 path is the same as the preceding default path, press Enter. Otherwise, enter the correct Python 3 path.

    2. Confirm the location of the Python library.
      1
      2
      3
      Found possible Python library paths:
        /usr/local/python3.7.5/lib/python3.7/site-packages
      Please input the desired Python library path to use.  Default is [/usr/local/python3.7.5/lib/python3.7/site-packages]
      

      If the Python 3 path is the same as the preceding default path, press Enter. Otherwise, enter the correct Python library path.

    3. Determine whether to enable the XLA JIT feature. In this document, enter n.
      1
      Do you wish to build TensorFlow with XLA JIT support? [Y/n]:n
      
    4. Determine whether to enable the OpenCL SYCL feature. In this document, enter N.
      1
      Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
      
    5. Determine whether to enable the ROCm feature. In this document, enter N.
      1
      Do you wish to build TensorFlow with ROCm support? [y/N]: N
      
    6. Determine whether to enable the CUDA feature. In this document, enter N.
      1
      Do you wish to build TensorFlow with CUDA support? [y/N]: N
      
    7. Determine whether to enable Clang. In this document, enter N.
      1
      Do you wish to download a fresh release of clang? (Experimental) [y/N]: N
      
    8. Determine whether to enable MPI. In this document, enter N.
      1
      Do you wish to build TensorFlow with MPI support? [y/N]: N
      
    9. Configure compilation options. In this document, retain the default settings and press Enter.
      1
      Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -Wno-sign-compare]:
      
    10. When building an Android application, determine whether to set a workspace. In this document, enter N.
      1
      "Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: N
      
  9. Build TensorFlow.
    1
    bazel build --config=v1 --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"  //tensorflow/tools/pip_package:build_pip_package
    
    • Building TensorFlow from source code requires substantial memory. For memory-constrained systems, add the --local_ram_resources={memory_size} option to the build command. For example, --local_ram_resources=2048 indicates that the maximum memory overhead allowed is 2048 MB.
  10. Build the pip software package.
    1
    ./bazel-bin/tensorflow/tools/pip_package/build_pip_package  ./output
    

    The tensorflow-1.15.5-cp37-cp37m-linux_aarch64.whl software package is generated in the output directory.

  11. Install the TensorFlow pip software package.
    1
    2
    cd output 
    pip3 install tensorflow-1.15.5-cp37-cp37m-linux_aarch64.whl