Configuring Environment Variables

After installing the software packages, you need to configure environment variables to ensure that the software can work properly.

(Optional) Disabling Password-Free Login

After the installation is complete, you are advised to cancel the root user login and password-free login based on the actual application scenario.

In Linux, if you use ssh-keygen to generate a key for password-free login, perform the following steps to disable password-free login:

  1. Go to the ~/ssh directory.
    cd ~/.ssh
  2. Delete the corresponding public key file.
    rm authorized_keys

Configuring Python Environment Variables

Before using Python 3.7.5, configure the following environment variables:
# Set the Python 3.7.5 library path.
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
# If multiple Python 3 versions exist in the user environment, use Python 3.7.5.
export PATH=/usr/local/python3.7.5/bin:$PATH

(Optional) Configuring GCC Environment Variables

GCC 7.3.0 or later is required for model training. You can run the gcc --version command to query the GCC version. If the GCC version is earlier than 7.3.0, perform the following steps to install GCC 7.3.0:
  1. Log in to the server as the root user.
  2. Configure environment variables. (The /usr/local/gcc7.3.0 path is used as an example. Replace it with the actual GCC 7.3.0 path. You can run the find / -name gcc7.3.0 command to query the actual installation path.)
    export LD_LIBRARY_PATH=/usr/local/gcc7.3.0/lib64:${LD_LIBRARY_PATH}
    export CC=/usr/local/gcc7.3.0/bin/gcc
    export CXX=/usr/local/gcc7.3.0/bin/g++
    export PATH=/usr/local/gcc7.3.0/bin:${PATH}
  3. Run the gcc --version command to check the GCC version. If the following information is displayed, the configuration is successful:
    gcc (GCC) 7.3.0
  • During the installation, the Docker user group is created and the Docker service is started. After the installation is complete, you can uninstall third-party components that may pose security risks, such as GCC, g++, and JDK, from the system.
  • If you require GCC 7.3.0 to compile a model but the GCC version cannot be controlled using the environment variable due to user compilation script limitations, perform the following operations to modify the soft link.

    Before modifying the soft link, run the find / -name gcc7.3.0 command to check whether the gcc7.3.0 folder exists. If no, GCC 7.3.0 is not installed. In this case, skip the following operations.

    1. Run the following command in any directory on the server, for example, usr/local/gcc7.3.0, to create a soft link based on the actual path of the gcc 7.3.0 folder:
      ln -sf /usr/local/gcc7.3.0/bin/gcc /usr/bin/gcc
    2. Run the gcc --version command to check the GCC version. If the following information is displayed, the configuration is successful:
      gcc (GCC) 7.3.0

Configuring the Environment Variables of the Ascend Software

The Toolkit and other software provide scripts for setting process-level environment variables. You can reference the scripts in processes to automatically set environment variables. The environment variables automatically become invalid after the processes end. The default installation path of the root user is used as an example.
# Configure the following when installing a version earlier than Toolkit 8.5.0:
. /usr/local/Ascend/ascend-toolkit/set_env.sh  

# Configure the following when installing Toolkit, NNRT, and NNAE 8.5.0 or later:
. /usr/local/Ascend/cann/set_env.sh 


# Configure the following when installing a version earlier than NNRT 8.5.0:
. /usr/local/Ascend/nnrt/set_env.sh
    
# Configure the following when installing a version earlier than NNAE 8.5.0:
. /usr/local/Ascend/nnae/set_env.sh

# Configure the following when installing the ToolBox package:
. /usr/local/Ascend/toolbox/set_env.sh
You can also configure permanent environment variables by modifying the ~/.bashrc file. The procedure is as follows:
  1. Run the vi ~/.bashrc command in any directory as the running user to open the .bashrc file and append the preceding lines to the file.
  2. Run the :wq! command to save the file and exit.
  3. Run the source ~/.bashrc command for the modification to take effect immediately.

(Optional) Configuring the NIC IP Address of the Device

During distributed training, configure the NIC IP address of the device. For details, see Configuring the Parameter Plane Network.

If you want to configure the NIC IP addresses of devices in batches, use the device IP configuration script (ascend-deployer/ascend_deployer/tools/hccn.py) provided by MindCluster Ascend Deployer. For details, see Using HCCN Tool.