PyTorch* Prerequisites for Intel GPUs

ID 827139
Updated 10/28/2024
Version
Public

author-image

By

PyTorch Prerequisites for Intel GPUs

These prerequisites let you compile and build PyTorch* 2.5 with optimizations for Intel Data Center or Client GPUs.

Developers compiling and building PyTorch 2.4 (for Intel Data Center GPUs only) should instead follow the prerequisite instructions for 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, when building PyTorch 2.4 or 2.5, or
  • Intel Client GPUs or CPUs with integrated GPUs such as Intel® Core™ Ultra Processors with Intel® Arc™ Graphics, when building PyTorch 2.5.

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, which collects a subset of oneAPI components needed for building and running PyTorch.

  • Profiling Tools Interfaces for Intel GPU (PTI for GPU) package, which provides Kineto (part of the PyTorch profiler) with the interfaces it needs to collect 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") release stream since this is where new hardware enablement first appears for early adopters who want to evaluate new features.

Important: Follow the instructions to configure the GPU driver's installation repository to the rolling release stream (and not the LTS stream) as described in the GPU driver installation instructions.

  1. Install the Intel GPU Drivers

    Use the instructions in the Linux OS-specific tabs within the Data Center GPU installation instructions for installing the Intel GPU drivers, based on the Linux distribution you're using. Be sure to follow all the instructions including selecting the right release stream and adding your user to the render node group

  2. 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. Note that installing the development support package assumes you don't already have existing oneAPI components installed. You should uninstall them if you do.

 

Step 3: Set Up oneAPI Environment Variables

Before you use any oneAPI component installed by the PyTorch development bundle, use this command to configure environment variables, important folders, and command settings.

source /opt/intel/oneapi/pytorch-gpu-dev-0.5/oneapi-vars.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/pytorch-gpu-dev-0.5/oneapi-vars.sh

Similarly, activate the PTI component using this command:

source $ONEAPI_ROOT/../pti/0.9/env/vars.sh
export Pti_DIR=$ONEAPI_ROOT/../pti/0.9/lib/cmake/pti

Consider adding these commands to your ~/.bashrc file so they run every time you log in or create a new shell session.

Build for Intel Client GPUs

The following OS releases and the corresponding Intel Client GPUs and CPUs with integrated GPUs are supported in PyTorch 2.5:

OS Version Supported Client GPUs
Ubuntu 22.04, WSL2 (Ubuntu 22.04) Intel® Arc™ Graphics family
Ubuntu 24.04, WSL2 (Ubuntu 24.04)

Intel® Core™ Ultra processor family with Intel® Graphics

Intel® Arc™ Graphics family

Windows 11 Family, Windows 10 (22H2)

Intel® Core™ Ultra processor family with Intel® Graphics

Intel® Core™ Ultra mobile processor family with Intel® Graphics

Intel® Arc™ Graphics family

 

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 that collects a subset of oneAPI components needed for building and running PyTorch.

  • Profiling Tools Interfaces for Intel GPU (PTI for GPU) package, which 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.

Install for Windows 10/11

Step 1: Install Intel Client GPU Drivers

Follow the instructions in the Intel® & 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 the following to download the PyTorch dev support package. Then double-click on the downloaded exe files to run it and follow the instructions to install:

Step 3: Set Up oneAPI Environment

Before you use any oneAPI component installed by the PyTorch development bundle, use these two commands to configure environment variables, important folders, and command settings for the dev bundle packages:

"C:\Program Files (x86)\Intel\oneAPI\pytorch-gpu-dev-0.5\oneapi-vars.bat"
"C:\Program Files (x86)\Intel\oneAPI\ocloc\2024.2\env\vars.bat"

These commands must be run every time you log in or create a new shell session.

 

Install for Ubuntu 22.04 on Intel® Arc™ Graphics family 

Support for Ubuntu 22.04 (only Intel® Arc™ Graphics family) and Ubuntu 24.04

Step 1: Install Intel Client GPU Drivers

Refer to the Client GPU installation instructions for installing the Intel GPU drivers with specific guidance for Ubuntu 22.04 or Ubuntu 24.04). Be sure to follow all the instructions, including selecting the right release stream and adding your user to the render node group.

Step 2: Optional GPU Hardware Verification

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

Step 3: Install Intel Support Packages

  1. Make sure the necessary tools to add repository access are available:
    sudo apt update 
    sudo apt install -y gpg-agent wget 
  2. 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-0.5 intel-pti-dev-0.9
    

Step 3: Set Up oneAPI Environment Variables

Before you use any oneAPI component installed by the PyTorch development bundle, use this command to configure environment variables, important folders, and command settings

source /opt/intel/oneapi/pytorch-gpu-dev-0.5/oneapi-vars.sh

Activate the PTI component using this command:

source /opt/intel/oneapi/pti/0.9/env/vars.sh

Consider adding these commands to your ~/.bashrc file so they run every time you log in or create a new shell session.

Install for WSL2

Support for Windows Subsystem for Linux (WSL2) is experimental.

Step 1: Install Intel Client GPU Drivers

When using WSL2 (running Ubuntu 22.04 or Ubuntu 24.04) , 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® & 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. The Ubuntu 22.04 or Ubuntu 24.04 repositories do not contain compute packages for various Intel graphics products. To install these packages, you can use Intel's dedicated package repository.

  • For Ubuntu 24.04 driver installation guidance, use the Client GPU Installation instructions for Ubuntu 24.04.

  • The driver installation instructions below provide guidance for Ubuntu 22.04. 

    # Install the Intel graphics GPG public key
    wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
      sudo gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
    
    # Configure the repositories.intel.com package repository
    echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" | \
      sudo tee /etc/apt/sources.list.d/intel-gpu-jammy.list
    
    # Update the package repository meta-data
    sudo apt update
    
    # Install the compute-related packages
    sudo apt-get install -y libze1 intel-level-zero-gpu intel-opencl-icd clinfo libze-dev intel-ocloc

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 two Intel support packages:
    sudo apt install intel-for-pytorch-gpu-dev-0.5 intel-pti-dev-0.9
    

Step 3: Set Up oneAPI Environment Variables

Before you use any oneAPI component installed by the PyTorch development bundle, use this command to configure environment variables, important folders, and command settings

source /opt/intel/oneapi/pytorch-gpu-dev-0.5/oneapi-vars.sh

Activate the PTI component using this command:

source /opt/intel/oneapi/pti/0.9/env/vars.sh

Consider adding these commands to your ~/.bashrc file so they run every time you log in or create a new shell session.

Where to go next?

After installing Intel GPU drivers and the two support packages, 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.