Installation Procedure (Ubuntu 20.04)
- Log in to the server as the root user and check whether dependencies, such as Python and GCC, are installed.Run the following commands to check whether the dependencies such as GCC, Make, and Python are installed:
gcc --version g++ --version make --version cmake --version dpkg -l zlib1g| grep zlib1g| grep ii dpkg -l zlib1g-dev| grep zlib1g-dev| grep ii dpkg -l libsqlite3-dev| grep libsqlite3-dev| grep ii dpkg -l openssl| grep openssl| grep ii dpkg -l libssl-dev| grep libssl-dev| grep ii dpkg -l libffi-dev| grep libffi-dev| grep ii dpkg -l unzip| grep unzip| grep ii dpkg -l pciutils| grep pciutils| grep ii dpkg -l net-tools| grep net-tools| grep ii dpkg -l libblas-dev| grep libblas-dev| grep ii dpkg -l gfortran| grep gfortran| grep ii dpkg -l libblas3| grep libblas3| grep ii dpkg -l libopenblas-dev| grep libopenblas-dev| grep ii
If the following information is displayed, the dependencies have been installed. Go to the next step. (The following information shows an example.)
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 GNU Make 4.2.1 cmake version 3.16.3 zlib1g:arm64 1:1.2.11.dfsg-2ubuntu1.3 arm64 compression library - runtime zlib1g-dev:arm64 1:1.2.11.dfsg-2ubuntu1.3 arm64 compression library - development libsqlite3-dev:arm64 3.31.1-4ubuntu0.3 arm64 SQLite 3 development files openssl 1.1.1f-1ubuntu2.13 arm64 Secure Sockets Layer toolkit - cryptographic utility libssl-dev:arm64 1.1.1f-1ubuntu2.13 arm64 Secure Sockets Layer toolkit - development files libffi-dev:arm64 3.3-4 arm64 Foreign Function Interface library (development files) unzip 6.0-25ubuntu1 arm64 De-archiver for .zip files pciutils 1:3.6.4-1ubuntu0.20.04.1 arm64 PCI utilities net-tools 1.60+git20180626.aebd88e-1ubuntu1 arm64 NET-3 networking toolkit libblas-dev:arm64 3.9.0-1build1 arm64 Basic Linear Algebra Subroutines 3, static library gfortran 4:9.3.0-1ubuntu2 arm64 GNU Fortran 95 compiler libblas3:arm64 3.9.0-1build1 arm64 Basic Linear Algebra Reference implementations, shared library libopenblas-dev:arm64 0.3.8+ds-1ubuntu0.20.04.1 arm64 Optimized BLAS (linear algebra) library (dev, meta)
Otherwise, run the following command to install the software. You can change the following command to install only some of them as required.apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev openssl libsqlite3-dev libssl-dev libffi-dev unzip pciutils net-tools libblas-dev gfortran libblas3 libopenblas-dev
- Check whether the Python development environment that meets the version requirements is installed. For details, see Dependency List. This step uses Python 3.7.x as an example.
Run the python3 --version command. If the returned Python version meets the requirements (3.7.0 to 3.7.11), go to 3.
Otherwise, install Python (Python 3.7.5 is used as an example).
- Run the following command to download the source package of Python 3.7.5 to any directory of the installation environment:
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
- Go to the download directory and run the following command to extract the source package:
tar -zxvf Python-3.7.5.tgz
- Go to the decompressed folder and run the following configuration, build, and installation commands:
cd Python-3.7.5 ./configure --prefix=/usr/local/python3.7.5 --enable-loadable-sqlite-extensions --enable-shared make make install
The --prefix parameter specifies the Python installation path. You can change it based on the site requirements. The --enable-shared parameter is used to compile the libpython3.7m.so.1.0 dynamic library. The --enable-loadable-sqlite-extensions parameter is used to load libsqlite3-dev.
This document uses --prefix=/usr/local/python3.7.5 as an example. After the configuration, compilation, and installation commands are executed, the installation package is stored in the /usr/local/python3.7.5 directory, and the libpython3.7m.so.1.0 dynamic library is stored in the /usr/local/python3.7.5/lib/libpython3.7m.so.1.0 directory.
- Set the Python 3.7.5 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
Set environment variables in the preceding export mode. In this mode, the environment variables take effect only in the current window. You can also write the preceding commands to the ~/.bashrc file and run the source ~/.bashrc command for the environment variables to take effect permanently. If you need to use other Python versions in the environment, do not to write the preceding commands to the ~/.bashrc file.
- 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 --version pip3 --version
- Run the following command to download the source package of Python 3.7.5 to any directory of the installation environment:
- Before installing the CANN, run the pip3 list command to check whether the dependencies have been installed. If yes, skip this step. If not, run the following command to install the dependencies. If only some of the software is not installed, modify the following command to install selected software only.
- Configure the pip source before the installation. For details, see Configuring the PIP Source.
- Before the installation, you are advised to run the pip3 install --upgrade pip command to perform the upgrade to prevent the installation failure caused by an earlier pip version.
pip3 install attrs pip3 install cython pip3 install numpy pip3 install decorator pip3 install sympy pip3 install cffi pip3 install pyyaml pip3 install pathlib2 pip3 install psutil pip3 install protobuf pip3 install scipy pip3 install requests pip3 install absl-py
If the error message "subprocess.CalledProcessError: Command '('lsb_release', '-a')' return non-zero exit status 1" is displayed, rectify the fault by referring to Error Message "subprocess.CalledProcessError: Command '('lsb_release', '-a')' return non-zero exit status 1" Is Displayed During pip3 Installation.