Prerequisites

Before using the PyTorch GPU2Ascend tool, make the following preparations:

Environment Setup

  1. Prepare a training server powered by Atlas training productss and install the corresponding driver and firmware.
  2. Install the Ascend-CANN-Toolkit. For details, see "Installing the Development Environment" in the CANN Software Installation Guide.
  3. Install MindStudio. For details, see "Installing MindStudio (Linux)" in the MindStudio Installation Guide.
  4. Install PyTorch 1.11.0. For details, see the "Installing PyTorch" in the CANN Software Installation Guide.
  5. Before using PyTorch GPU2Ascend for migration, run the following commands to install required dependencies. If you use a non-root user, add --user to the end of each installation command.
    pip3 install pandas         # The pandas version must be 1.2.4 or later.
    pip3 install libcst         # The semantic analysis library is used to parse Python files.
    pip3 install prettytable    # This dependency is used to visualize data in charts.

Environment Variable Configuration

  1. Log in as the running user, run the vi ~/.bashrc command in any directory to open the .bashrc file, and append the following content to the file (the default installation path of a non-root user is used as an example):
    # Ascend-CANN-Toolkit environment variable. Change it to the actual path.
    source ~/Ascend/ascend-toolkit/set_env.sh
    
    # PyTorch environment variable. Change it to the actual PyTorch path.
    export LD_LIBRARY_PATH=~/.local/lib/python3.7/site-packages/torch/lib:$LD_LIBRARY_PATH
  2. Run the :wq! command to save the file and exit.
  3. Run the source ~/.bashrc command for the modification to take effect immediately.

Data Preparation

  • PyTorch-CIFAR-100 model script. Upload it to the personal directory on the training server.
  • CIFAR-100 dataset. It is automatically downloaded during training.