Updated on 2022-03-13 GMT+08:00

Environment Preparation

Environment Requirements

The DDK installation must meet the following environment requirements on the hardware and operating system (OS).

Table 1 CentOS version information

Category

Version

Obtaining Method

Precautions

OS

7.6

Download the following recommended version from http://vault.centos.org/altarch/7.6.1810/isos/aarch64/:

CentOS-7-aarch64-Everything-1810.iso

The DDK installation and offline installation packages are adapted and tested based on the Infrastructure Server of CentOS. Therefore, you must use the Infrastructure Server software for installation. Other software, for example, Minimal Install or Development and Creative Workstation, cannot be used.

Python

Python 2: 2.7+

Python3: 3.5+

For details, see Installing Dependencies.

Install Python 2.7 or later for Python2 and Python 3.5 or later for Python3. Both Python versions need to be installed.

(Optional) Preparing the DDK Installation User

You can install the DDK as any user (root or non-root).

  • If the root user is used for installation, skip this section.
  • If you use an existing non-root user to install the DDK, run the following command as the root user to grant the existing user with permission 750 on the $HOME directory:
    chmod 750 /home/username
  • If you want to install the DDK as a new non-root user, perform the following steps as the root user: This document describes how to install the DDK as a new non-root user.
    1. Run the following command to create a user for DDK installation and configure the $HOME directory of the user:
      useradd -d /home/username -m username
    2. Run the following command to set the password:
      passwd username
    3. Run the following command to set the permission:
      chmod 750 /home/username
      username indicates the user name for installing the DDK. The umask value of the user cannot be greater than 0027.
      • To view the umask value, run the umask command.
      • To change the umask value, run the umask New value command.
    If the created non-root user is HwHiAiUser, the DDK is deployed on the host server, and HwHiAiUser is used for offline model conversion, logs are stored in the var/dlog directory on the host by default. To enable the output of logs to the screen by default, you can set the following environment variable:
    export  SLOG_PRINT_TO_STDOUT=1
  • Change the size of the file descriptor.
    1. Open the system configuration file /etc/security/limits.conf as the root user by running the following command:
      vi /etc/security/limits.conf
    1. Add the following content to the end of the limits.conf file:
      * soft nproc 65535
      * hard nproc 65535
      * soft nofile 65535
      * hard nofile 65535

      * indicates all users. You are advised to replace it with the name of the user who installs the Mind Studio project.

    1. Run the :wq! command to save the file and exit.

(Optional) Configuring Permissions of the DDK Installation User

When a non-root user is used for installation, perform the following operations. Skip the following operations if the root user is used for installation.

Before installing the DDK, you need to download the dependent software with the sudo yum permission. Perform the following operations as the root user:

  1. Run the following commands to open the /etc/sudoers file:
    chmod u+w /etc/sudoers
    vi /etc/sudoers
  2. Under root ALL=(ALL:ALL) ALL in the file, add the following content:
    username ALL=(ALL:ALL) NOPASSWD:SETENV: /usr/bin/yum,/bin/make install,/bin/ln -s /usr/local/python3/bin/python3.5 /usr/bin/python3,/bin/ln -s /usr/local/python3/bin/python3.5 /usr/bin/python3.5,/bin/ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3,/bin/ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3.5

    Replace username with the name of the common user who executes the installation script.

    When you run other sudo commands, such as sudo rm -rf python3 for deleting the soft link to Python 3, the following error may be reported:

    Sorry, user sam is not allowed to execute '/bin/rm -rf python3' as root on localhost.localdomain.

    Open the /etc/sudoers file as the root user, add the /bin/rm -rf python3 command to the last line of 2 to obtain the operation permissions, and switch to the common user.

  3. Run the :wq! command to save the file.
  4. Run the following command to remove the write permission on the /etc/sudoers file:
    chmod u-w /etc/sudoers

Ensure that the last line of the /etc/sudoers file is #includedir /etc/sudoers.d. Otherwise, add it manually.

Configuring the Network

If CentOS cannot be connected to the network through a remote terminal after CentOS is started, perform the following steps to configure the network adapter:

Run the following command as the root user to open the NIC configuration file:

vi /etc/sysconfig/network-scripts/ifcfg-enp2s0f0

Replace ifcfg-enp2s0f0 with the actual name of the network adapter in use.

Change the value of ONBOOT to yes, and set network parameters as shown in the following figure.

Figure 1 Setting network parameters

BOOTPROTO indicates the IP address type of the device. For a static IP address, set this parameter to static or none. For a dynamic IP address, set this parameter to dhcp so that the IP address can be obtained automatically.

Save the file and exit. Run the following command to restart the network service:

service network restart

Configuring the Sources

DDK installation requires related dependencies, which must be downloaded in advance. Ensure that the server where the DDK is installed can successfully connect to the network. Perform the following steps as the root user:

  1. Run the following command to check source validity:

    yum makecache
    If an error is reported during the command execution, check whether the network connection is normal or replace the following content with the source in the /etc/yum.repos.d/CentOS-Base.repo file:
    [base]
     name=CentOS-$releasever - Base
     mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
     gpgcheck=1
     gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
            file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64
     #released updates
     [updates]
     name=CentOS-$releasever - Updates
     mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
     gpgcheck=1
     gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
             file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64
     #additional packages that may be useful
     [extras]
     name=CentOS-$releasever - Extras
     mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
     gpgcheck=1
     gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
            file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64
     enabled=1
     #additional packages that extend functionality of existing packages
     [centosplus]
     name=CentOS-$releasever - Plus
     mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
     gpgcheck=1
     enabled=0
     gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
            file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64

  2. Configure a special source to support Python download and installation.

    yum install -y epel-release

    If epel-release fails to be installed by using the yum source, rectify the fault by referring to FAQs > What Do I Do If epel-release Installation Fails?.

  3. Run the following commands to update the software information:

    yum clean all
    yum makecache

Installing Dependencies

Run the su - username command to switch to the DDK installation user and perform the following operations to install components such as the GCC and Python on which the DDK depends:

  1. Install Python 3.5.

    CentOS does not provide a proper source for installing Python 3.5. Therefore, install Python 3.5 by using an installation package.

    1. Install the dependencies that may be used in Python 3.5 installation: (If a command line is wrapped, copy the command to Word or Notepad, replace the line wrap point with a space to merge the lines into one and copy it back to the server for execution.)
      sudo -E yum install -y openssl-devel zlib-devel bzip2-devel expat-devel gdbm-devel gcc readline-devel sqlite-devel ncurses-devel
    2. Run the wget command to download the Python 3.5 installation package to any directory on the CentOS server:
      wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
    3. Run the following command to go to the download directory and decompress the installation package:
      tar -zxvf Python-3.5.1.tgz
    4. Go to the decompressed folder and run the following configuration, compilation, and installation commands:
      cd Python-3.5.1
      ./configure --prefix=/usr/local/python3
      make
      sudo make install
    5. Run the following commands to set the soft link:
      sudo ln -s /usr/local/python3/bin/python3.5 /usr/bin/python3
      sudo ln -s /usr/local/python3/bin/python3.5 /usr/bin/python3.5
      sudo ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
      sudo ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3.5
    6. After the installation is complete, run the following commands to check the installation version. If the required version information is displayed, the installation is successful.
      python3 -V
      pip3 -V

  2. Run the following command to install the dependencies:

    sudo -E yum install -y gcc-c++ cmake  make python python-devel python2-pip gcc-gfortran

  3. Install the Python dependencies.

    • Before installing the software on which Python 2.7 depends, ensure that the preceding operations are successful. Run the pip2 -V command to check the pip version. If the following information is displayed, it indicates that Python 2.7 has been installed correctly:
      pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

      The preceding information indicates that pip has been installed correctly. Run the following commands to install the software dependencies required by Python 2.7 (NumPy versions 1.11.0–1.16.0 are supported and the following uses 1.16.0 as an example):

      pip2 install numpy==1.16.0 --user
      pip2 install decorator --user
      pip2 install setuptools --upgrade --user
    • Before installing the software on which Python 3.5 depends, run the pip3.5 -V command to check the version information. If the following information is displayed, it indicates that Python 3.5 has been installed correctly.
      pip 7.1.2 from /usr/lib/python3.5/site-packages (python 3.5)

      The preceding information indicates that pip3.5 has been installed correctly. Run the following commands to install the software dependencies required by Python 3.5 (NumPy versions 1.11.0–1.16.0 are supported and the following uses 1.16.0 as an example):

      pip3.5 install numpy==1.16.0 --user
      pip3.5 install decorator --user
      pip3.5 install setuptools --upgrade --user

      If the message "Import Error:cannot import name main" is displayed when you run the pip3.5 -V command, rectify the fault by referring to What Do I Do If the Message "Import Error:cannot import name main" Is Displayed When the pip3/pip3.5 -V Command Is Run after pip3/pip3.5 Upgrade?.