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.
- 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"
- Obtain the PyTorch source code.
1git clone -b v2.1.2 https://github.com/pytorch/pytorch.git --depth 1
- Go to the /path/to/pytorch directory.
1cd /path/to/pytorch
- Obtain sub-repository dependency code.
1 2
git submodule sync git submodule update --init --recursive
- 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.
- Install the Python dependencies.
1pip install -r requirements.txt
- Compile and install PyTorch.
1python3 setup.py install
- Verify the installation.
1pip 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 obtaining the sub-repository dependency code, an error may be reported stating "unexpected disconnect while reading sideband packet fatal." Rectify this fault by following instructions in Failed to Obtain the Dependency of the Sub-repository.
- 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.