Failed to Collect HPC Application Analysis Task Data on Ubuntu
Symptom
Failed to collect HPC application analysis task data on Ubuntu.
Possible Cause
The Python scripting function in the perf script is disabled on Ubuntu 13.04 and later. As a result, data fails to be collected in an HPC application analysis task. To enable this function on Ubuntu, recompile and replace perf in the OS.
Troubleshooting Procedure
- Use an SSH tool to remotely log in to the Linux CLI as the root user.
- Run the uname -r command to view the current kernel version.

In this example, the kernel version is 4.15.0.
- Download the perf version matching the kernel.
1 2 3 4
mkdir /home/linux_kernel cd /home/linux_kernel apt-get update apt-get source linux-source-<kernel-version>
In the preceding commands, replace <kernel-version> with the kernel version obtained in 2.
The downloaded source code is shown in the following figure:

- Compile perf.
Query the missing dependency packages.
1 2
cd /home/linux_kernel/linux-4.15.0/tools/perf make

If the console displays a message indicating that some dependency packages are missing, install those as prompted.
The Python scripting function requires python-dev, libelf-dev, libunwind-dev, libaudit-dev, and libslang2-dev.
Run the following commands to install the packages:
1 2 3
apt-get install python-dev libelf-dev libunwind-dev libaudit-dev libslang2-dev make make install

The command output shows that the libaudit, libelf, libpython, libslang, libunwind, lzma, and bpf are enabled.
- Verify that perf is compiled successfully.
1 2 3
cd /home/linux_kernel /home/linux_kernel/linux-4.15.0/tools/perf/perf record /home/linux_kernel/linux-4.15.0/tools/perf/perf script -g python
If a perf-script.py file is generated in the directory, the compilation is successful.

- Replace the existing perf. Then the Python scripting function is available on Ubuntu.
1cp /home/linux_kernel/linux-4.15.0/tools/perf/perf /usr/bin