PyTorch* Prerequisites for Intel GPUs

author-image

By

PyTorch Prerequisites for Intel GPUs

These prerequisites let you compile and build PyTorch* 2.5 with optimizations for Intel GPUs. Developers doing early access stabilization work can also use these instructions when compiling and building PyTorch 2.4.

Important: Read the Release Notes for the latest information and known issues about system requirements and support packages.

The following sections provide prerequisite instructions for using:
 

  • Intel Data Center GPUs such as Intel® Data Center GPU Max Series platforms, or
  • Intel Client GPUs or CPUs with integrated GPUs such as Intel® Core™ Ultra Processors with Intel® Arc™ Graphics.

Build for Intel Data Center GPUs

These Intel Data Center GPUs are supported:

  • Intel® Data Center GPU Max Series platforms (formerly codename Ponte Vecchio or PVC)

These Linux releases are supported:

  • Red Hat* Enterprise Linux* 9.2
  • SUSE Linux Enterprise Server* 15 SP5
  • Ubuntu* Server 22.04 (>= 5.15 LTS kernel)

The following instructions show how to install:
 

  • Intel Data Center GPU Drivers along with compute and media runtimes and development packages

  • Intel GPU dependencies for PyTorch development package that collects a subset of oneAPI components needed for building and running PyTorch.

  • Profiling Tools Interfaces for Intel GPU (PTI for GPU) package that provides Kineto (part of the PyTorch profiler) with the interfaces it needs for collecting timing data from Intel GPUs for performance metrics during training and inference.

Step 1: Install Intel Data Center GPU Drivers

The Data Center GPU Installation Instructions describe software installation for Intel® Data Center GPU Max Series systems, along with compute and media runtimes and development packages. These general installation instructions install the Long Term Support (LTS) version of the Intel GPU drivers. However, you'll need to use the Intel GPU driver's rolling (also referred to as "rolling stable" or simply "rolling") release stream since this is where new hardware enablement first appears for early adopters who want to evaluate new features.
 

  • The Intel GPU dependencies for PyTorch development package works with either the Intel GPU drivers LTS or rolling release stream.
  • The PTI for GPU package only works with the Intel GPU drivers rolling release stream.

Important: If your use case needs the PyTorch profiler (and hence PTI for GPU support), follow the instructions in the Data Center GPU Release Streams documentation to configure the installation repository to the rolling release stream before following the rest of the GPU driver installation instructions. If PTI for GPU is not required, use the LTS release stream.

Before you can install the GPU drivers, you'll need to configure which release stream to use.
 

  1. Configure the Release Stream

    Here are links to specific sections in the Data Center GPU Installation Instructions for configuring the release stream, based on the Linux distribution you're using. As previously mentioned, choose the LTS or rolling release stream as appropriate for your use case:

    Release stream configuration: Red Hat Enterprise Linux Server
    Release stream configuration: SUSE Linux Enterprise Server
    Release stream configuration: Ubuntu Server

  2. Install the Intel GPU Drivers from the Configured Stream

    After you've configured the release stream, here are links to specific sections within the Data Center GPU installation instructions for installing the Intel GPU drivers, based on the Linux distribution you're using. These installation instructions assume you're using the LTS release stream. Since you've already configured the release stream in the previous step, skip instructions that would change it.

    Intel GPU drivers installation: Red Hat Enterprise Linux Server
    Intel GPU drivers installation: SUSE Linux Enterprise Server
    Intel GPU drivers installation: Ubuntu Server

  3. Configure Render Group Membership

    After the Intel GPU drivers are installed, follow these instructions to Configure Render Group Membership to have access to DRM render nodes.

  4. Optional GPU Hardware Verification

    Optionally, follow these instructions to verify expected Intel GPU hardware is working.

Step 2: Install Intel Support Packages

After the Intel GPU drivers are installed, choose one of these ways to install the two Intel support packages: either using a Linux package manager: APT, YUM, or Zypper, or using offline installation scripts

Step 3: Set Up oneAPI Environment Variables

Before you use any oneAPI component, you must have environment variables set to configure important folders and command settings. By default, oneAPI components are put in the /opt/intel/oneapi, so configure the oneAPI environment using this command:

source /opt/intel/oneapi/setvars.sh

If that command fails, you may have installed the oneAPI components in your home directory, so try using this command instead:

source ~/intel/oneapi/setvars.sh

Consider adding this command to your ~/.bashrc file so it runs every time you log in or create a new shell session.

Build for Intel Client GPUs

These Intel Client GPUs and CPUs with integrated GPUs are supported:

  • Intel® Core™ Ultra processor family with Intel® Arc™ Graphics (Codename Meteor Lake)
  • Intel® Arc™ Graphics family (Codename DG2)

These OS releases are supported:

  • Windows 11 Family, Windows 10 (22H2)
  • Windows Subsystem for Linux - Ubuntu 22.04 (WSL2)
  • Ubuntu* 22.04, kernel version >= 6.7, depending on graphics process model, as shown in this Hardware Devices table)

The following instructions show how to install prerequisite components depending on your OS:
 

  • Intel Client GPU Drivers along with compute and media runtimes and development packages

  • Intel GPU dependencies for PyTorch development package, which collects a subset of oneAPI components needed for building and running PyTorch.

  • Profiling Tools Interfaces for Intel GPU (PTI for GPU) package that provides Kineto (part of the PyTorch profiler) with the interfaces it needs  for collecting timing data from Intel GPUs for performance metrics during training and inference. (PTI for GPU is only supported on Linux and not Windows.)

Install for Windows 10/11

Step 1: Install Intel Client GPU Drivers

Follow the instructions in the Intel® Arc™ & Iris® Xe Graphics - Windows documentation to download and run the installer to update your WHQL Certified graphics driver to version 31.0.101.5522 or higher. That document also has links to version-specific release notes about this driver.

Step 2: Install Intel Support Package

Click on this link to download the PyTorch dev support package. Then double-click on the downloaded exe file to run it and follow the instructions to install:

The PTI SDK support package, which enables PyTorch profiling on Intel GPUs, is a Linux-only component and is not available for Windows.

Step 3: Set Up oneAPI Environment

Before you use any oneAPI component, you must have system variables set to configure important folders and command settings. By default, oneAPI components are put in the C:\Program Files (x86)\Intel\oneAPI folder, so configure the oneAPI environment using this command:

"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"

This command must be run every time you log in or create a new shell session.

Install for WSL2

Step 1: Install Intel Client GPU Drivers

When using WSL2, the GPU drivers are installed in the Windows OS and runtime components such as Level-Zero are installed within the WSL2 Linux environment.
 

  1. Follow the instructions in the Intel® Arc™ & Iris® Xe Graphics - Windows documentation to download and run the Windows installer to update your WHQL Certified graphics driver to version 31.0.101.5522 or higher. That document also has links to version-specific release notes about this driver.

  2. Configure the Ubuntu APT client to add the Intel graphics repository and its key (within WSL2) and update the APT client package list and repository index:

    sudo apt-get install -y gpg-agent wget
    
    wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor --output /tmp/intel-graphics.gpg
    
    sudo mv /tmp/intel-graphics.gpg /usr/share/keyrings/
    
    echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" > /tmp/intel-gpu-jammy.list
    
    sudo mv /tmp/intel-gpu-jammy.list  /etc/apt/sources.list.d/
    
    sudo apt-get update
    
  1. Install the necessary runtime packages (in WSL2)
    sudo apt-get install  intel-igc-cm intel-level-zero-gpu intel-opencl-icd \
        level-zero libigc1 libigdfcl1 libigdgmm12
    

Step 2: Install Intel Support Packages

  1. Download the Intel APT repository’s public key and put it into the /usr/share/keyrings directory:
    wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
      | gpg --dearmor > /tmp/intel-for-pytorch-gpu-dev-keyring.gpg
    
    sudo mv /tmp/intel-for-pytorch-gpu-dev-keyring.gpg /usr/share/keyrings
    
  1. Configure the APT client to add the Intel repository and its key:
    echo "deb [signed-by=/usr/share/keyrings/intel-for-pytorch-gpu-dev-keyring.gpg] https://apt.repos.intel.com/intel-for-pytorch-gpu-dev all main" > /tmp/intel-for-pytorch-gpu-dev.list
    
    sudo mv /tmp/intel-for-pytorch-gpu-dev.list /etc/apt/sources.list.d
    
  1. Update the APT client package list and repository index:
    sudo apt update
    
  1. Use APT to install the Intel support packages:
    sudo apt install intel-for-pytorch-gpu-dev intel-pti-dev
    

Step 3: Set Up oneAPI Environment Variables

Before you use any oneAPI component, you must have environment variables set to configure important folders and command settings. By default, oneAPI components are put in the /opt/intel/oneapi, so you should configure the oneAPI environment using this command:

source /opt/intel/oneapi/setvars.sh

Consider adding this command to your ~/.bashrc file so it runs every time you log in or create a new shell session.

Install for Ubuntu 22.04

For native Ubuntu, you'll need to have a Linux kernel with support for Intel graphics hardware, which wasn't available when Ubuntu 22.04 was released. You can find out your kernel version with the uname -r  command.  If your kernel version is not 6.7 or higher, you'll need to upgrade the Linux kernel. After upgrading the kernel, as noted in the graphics hardware devices documentation, you'll need to update the GRUB parameters to add the i915.force_probe parameter to the kernel boot.

Step 1: Install Intel Client GPU Drivers

  1. Configure the Ubuntu APT client to add the Intel graphics repository and its key and update the APT client package list and repository index
    sudo apt-get install -y gpg-agent wget
    
    wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
      gpg --yes --dearmor --output /tmp/intel-graphics.gpg
    
    sudo mv /tmp/intel-graphics.gpg /usr/share/keyrings/
    
    echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" > /tmp/intel-gpu-jammy.list
    
    sudo mv /tmp/intel-gpu-jammy.list /etc/apt/sources.list.d/
    
    sudo apt update
    
  1. Install Compute, Media, and Display runtimes
    sudo apt install -y \
      intel-opencl-icd intel-level-zero-gpu level-zero \
      intel-media-va-driver-non-free libmfx1 libmfxgen1 libvpl2 \
      libegl-mesa0 libegl1-mesa libegl1-mesa-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri \
      libglapi-mesa libgles2-mesa-dev libglx-mesa0 libigdgmm12 libxatracker2 mesa-va-drivers \
      mesa-vdpau-drivers mesa-vulkan-drivers va-driver-all vainfo hwinfo clinfo
    

Step 2: Install Intel Support Packages

  1. Download the Intel APT repository’s public key and put it into the /usr/share/keyrings directory:
    wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
      | gpg --dearmor > /tmp/intel-for-pytorch-gpu-dev-keyring.gpg
    
    sudo mv /tmp/intel-for-pytorch-gpu-dev-keyring.gpg /usr/share/keyrings
    
  1. Configure the APT client to add the Intel repository and its key:
    echo "deb [signed-by=/usr/share/keyrings/intel-for-pytorch-gpu-dev-keyring.gpg] https://apt.repos.intel.com/intel-for-pytorch-gpu-dev all main" > /tmp/intel-for-pytorch-gpu-dev.list
    
    sudo mv /tmp/intel-for-pytorch-gpu-dev.list /etc/apt/sources.list.d
    
  1. Update the APT client package list and repository index:
    sudo apt update
    
  1. Use APT to install the Intel support package:
    sudo apt install intel-for-pytorch-gpu-dev intel-pti-dev
    

Step 3: Set Up oneAPI Environment Variables

Before you use any oneAPI component, you must have environment variables set to configure important folders and command settings. By default, oneAPI components are put in the /opt/intel/oneapi, so configure the oneAPI environment using this command:

source /opt/intel/oneapi/setvars.sh

Consider adding this command to your ~/.bashrc file so it runs every time you log in or create a new shell session.

Where to go next?

After installing Intel GPU drivers and the support package, as shown above, you're ready to return to and continue following the upstream PyTorch instructions in the PyTorch Building from Source: Install Dependencies section.

Support

For support questions, look through or post a question to this oneAPI developer support forum.