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

Basic Installation

The basic installation procedure of PyTorch includes obtaining the source code and sub-repository dependency code, setting environment variables, and compiling and installing PyTorch. Replace the example paths provided in the following procedure with the actual ones.

  1. Configure a network 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"
    
  2. Obtain the PyTorch source code.
    1
    git clone -b v2.1.2 https://github.com/pytorch/pytorch.git --depth 1
    
  3. Go to the /path/to/pytorch directory.
    1
    cd /path/to/pytorch
    
  4. Obtain sub-repository dependency code.
    1
    2
    git submodule sync
    git submodule update --init --recursive
    
  5. Set environment variables.
    1
    2
    3
    4
    export USE_CUDA=0
    export USE_ROCM=0
    export USE_FBGEMM=0
    export USE_GLOO=0
    

    USE_CUDA: CUDA is a technology dedicated to NVIDIA GPUs. Set this parameter to 0 in CPU scenarios, meaning that this option is disabled.

    USE_ROCM: ROCm is a technology dedicated to AMD GPUs. Set this parameter to 0 in CPU scenarios, meaning that this option is disabled.

    USE_FBGEMM: Matrix operation acceleration library, which applies only to x86. Set this parameter to 0 in Arm scenarios, meaning that this option is disabled.

    USE_GLOO: Communication library between multiple GPUs and multiple nodes. Set this parameter to 0 in CPU scenarios, meaning that this option is disabled.

  6. Install the Python dependencies.
    1
    pip install -r requirements.txt
    
  7. Compile and install PyTorch.
    1
    python3 setup.py install
    
  8. Verify the installation.
    1
    pip list | grep torch
    

    • When obtaining the PyTorch source code, an error may be reported stating "unexpected disconnect while reading sideband packet." Rectify this fault by following instructions in Failed to Obtain the PyTorch Source Code.
    • When compiling PyTorch, an error may be reported indicating that the CMakeLists.txt, Makefile, setup.py, LICENSE, LICENSE.md, and LICENSE.txt are not found in the /path/to/pytorch/third_party/ios-cmake directory. Rectify this fault by following instructions in No File Is Found During PyTorch Compilation.