Error Message "fatal error: 'cstdint' file not found" Is Displayed During ATC Conversion or Model Training

Symptom

When the ATC conversion command is executed on Ubuntu 22.04 or model training is performed on CentOS 7.6, the error message "fatal error: 'cstdint' file not found" is displayed.

Figure 1 Error screenshot

Possible Cause 1

When multiple GCC versions are installed in the Ubuntu 22.04 environment, the GCC of a later version and other tools (such as devtoolset-9-gcc) that contain GCC in the default installation path are used for CCEC compilation. However, during the installation of the GCC of a later version, some files are missing. As a result, the cstdint header file cannot be found.

The troubleshooting process is as follows:

  1. Check the GCC status in the environment:
    1
    2
    cd /usr/lib/gcc/aarch64-linux-gnu
    ll
    

    The following command output shows that two installation directories (GCC 11 and GCC 12) exist.

  2. Run the following command to query the GCC version in the environment:
    1
    dpkg -l | grep gcc
    

    The following command output shows that two versions (GCC 11 and GCC 12) exist.

    Alternatively, run a simple C program, use CCEC for compilation, and check the GCC version.

    ccec -o test ./test.cc -v

    The following command output shows that GCC 12 is used.

  3. Check whether the header file exists in each version, and find that the header file exists only in the GCC 11 version. The path is as follows:
    1
    /usr/include/c++/11/cstdint
    

Solution

Run the following command to uninstall GCC 12 and use the installed GCC 11 for compilation:

1
apt remove gcc-12 libgcc-12-dev

Possible Cause 2

The default GCC version of CentOS 7.6 is 4.8.5. Even if GCC 7.3.0 has been installed, the cstdint header file of the default GCC 4.8.5 is found during CCEC compilation. As a result, compatibility issues occur.

Solution

Before model training, configure the following environment variables (the configurations for AArch64 and x86_64 are the same). During compilation, use the GCC 7.3.0 header files that meet the version requirements. The following uses the installation path /usr/local/Ascend/ and GCC 7.3.0 as an example. Change the installation path and GCC version based on the site requirements.

export C_INCLUDE_PATH=/usr/local/Ascend/cann/toolkit/toolchain/hcc/aarch64-target-linux-gnu/include/c++/7.3.0/:/usr/local/Ascend/cann/toolkit/toolchain/hcc/aarch64-target-linux-gnu/include/c++/7.3.0/aarch64-target-linux-gnu/
export CPLUS_INCLUDE_PATH=/usr/local/Ascend/cann/toolkit/toolchain/hcc/aarch64-target-linux-gnu/include/c++/7.3.0/:/usr/local/Ascend/cann/toolkit/toolchain/hcc/aarch64-target-linux-gnu/include/c++/7.3.0/aarch64-target-linux-gnu/