Configure Your CPU or GPU System

Intel® oneAPI Base Toolkit

Note

If you are working with an FPGA system, see Configure Your FPGA System.

Install CMake*, pkg-config, and GNU* Dev Tools to Build Samples

Although the CMake and pkg-config build tools are not required by the oneAPI tools and toolkits, many oneAPI samples are provided as CMake projects and require CMake to build them. In some cases pkg-config is necessary to locate libraries needed to complete a build of the application.

The Intel compilers utilize the existing GNU build toolchains to provide a complete C/C++ development environment. If your distribution of Linux does not include the complete suite of GNU development tools, you need to install these tools.

To install CMake, pkg-config, and the GNU development tools on your Linux system, open a terminal session and enter the following commands:

Ubuntu*

sudo apt update
sudo apt -y install cmake pkg-config build-essential

Red Hat* and Fedora*

sudo yum update
sudo yum -y install cmake pkgconfig
sudo yum groupinstall "Development Tools"

SUSE*

sudo zypper update
sudo zypper --non-interactive install cmake pkg-config
sudo zypper --non-interactive install pattern devel_C_C++

Verify the installation by displaying the installation location with this command:

which cmake pkg-config make gcc g++

One or more of these locations will display:

/usr/bin/cmake

/usr/bin/pkg-config

/usr/bin/make

/usr/bin/gcc

/usr/bin/g++

For more information about CMake, refer to CMake.org. If you are unable to install CMake using your Linux distribution's standard package manager, see the CMake.org downloads page for additional installation options.

Set Environment Variables for CLI Development

For working at a Command Line Interface (CLI), the tools in the oneAPI toolkits are configured via environment variables. Set up your CLI environment by running the setvars script:

Option 1: Run setvars.sh once per session

Run setvars.sh every time you open a new terminal window:

You can find the setvars.sh script in the root folder of your oneAPI installation, which is typically /opt/intel/inteloneapi/ when installed as root or sudo, and ~/intel/inteloneapi/ when not installed as a super user. If you customized the installation folder, the setvars.sh is in your custom folder.

source <install_dir>/setvars.sh

Option 2: One time setup for setvars.sh

To have the environment automatically set up for your projects, include the command source <install_dir>/setvars.sh in a startup script where it will be invoked automatically (replace <install_dir> with the path to your oneAPI install location).

For example, you can add the source <install_dir>/setvars.sh command to your ~/.bashrc or ~/.bashrc_profile or ~/.profile file. To make the settings permanent for all accounts on your system, create a one-line .sh script in your system's /etc/profile.d folder that sources setvars.sh (for more details, see /etc/profile.d/).

The setvars.sh script can also be managed using a configuration file. For more details, see Using a Configuration File to Manage Setvars.sh

.

For GPU Users, Install GPU Drivers

For GPU development install GPU drivers using the following commands:

  • To access the packages, add the repository to your system and then install the packages using apt (Note: root permission is required)

cat << EOF | sudo tee /etc/apt/sources.list.d/intel-graphics.list
deb [trusted=yes arch=amd64] https://repositories.intel.com/graphics/ubuntu bionic main
EOF
sudo apt-get update && sudo apt-get install -y intel-opencl

Note

In Ubuntu 18.04, the Open CL package is named intel-opencl. Starting with the Ubuntu 19.04 (disco) release, this package was renamed intel-opencl-icd to align with how it is packaged by Canonical.

  • To access the packages, add the repository to your system and then install the packages using apt (Note: root permission is required)
cat << EOF | sudo tee /etc/apt/sources.list.d/intel-graphics.list
deb [trusted=yes arch=amd64] https://repositories.intel.com/graphics/ubuntu eoan main
EOF
sudo apt-get update && sudo apt-get install -y intel-opencl-icd

  • To access the packages, add the repository to your system and then install the packages using dnf (Note: root permission is required)
cat << EOF | sudo tee /etc/yum.repos.d/intel-graphics.repo
[intel-graphics]
name=Intel Graphics Drivers Repository
baseurl=https://repositories.intel.com/graphics/rhel/8.0/
enabled=1
gpgcheck=0
EOF
sudo dnf install -y intel-opencl

GPU: Disable Hangcheck

This section applies only to applications with long-running GPU compute workloads in native environments. It is not recommended for virtualizations or other standard usages of GPU, such as gaming.

A workload that takes more than four seconds for GPU hardware to execute is a long running workload. By default, individual threads that qualify as long-running workloads are considered hung and are terminated. By disabling the hangcheck timeout period, you can avoid this problem.

Note

If the system is rebooted, hangcheck is automatically enabled. You must disable hangcheck again after every reboot or follow the directions to disable hangcheck persistently (across multiple reboots).

To disable hangcheck until the next reboot:

sudo sh -c "echo N> /sys/module/i915/parameters/enable_hangcheck"

To disable hangcheck across multiple reboots:

Note

If the kernel is updated, hangcheck is automatically enabled. Run the procedure below after every kernel update to ensure hangcheck is disabled.

  1. Open a terminal.
  2. Open the grub file in /etc/default.
  3. In the grub file, find the line GRUB_CMDLINE_LINUX_DEFAULT="" .
  4. Enter this text between the quotes (""):
    i915.enable_hangcheck=0
  5. Run this command:
    sudo update-grub
  6. Reboot the system. Hangcheck remains disabled.

GPU: Add User to Video Group

For GPU compute workloads, non-root users do not have access to the GPU device. If you do not add a non-root user to the video group, all binaries compiled for a GPU will fail during execution. To fix this problem, add the non-root user to the video group:

usermod -a -G video <username>

Next Step

Run a sample project using one of these methods:

For more complete information about compiler optimizations, see our Optimization Notice.