PyTorch* Prerequisites for Intel GPUs

ID 827139
Updated 8/2/2024
Version
Public

A newer version of this document is available. Customers should click here to go to the newest version.

author-image

By

PyTorch Prerequisites for Intel GPUs

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

Developers compiling and building PyTorch 2.5 (for Intel Data Center and Client GPUs) should instead follow the prerequisite instructions for PyTorch 2.5.

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

 

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.

Step 1: Install Intel Data Center GPU Drivers

The Data Center GPU Installation Instructions describe how to install software for Intel® Data Center GPU Max Series systems, along with compute and media runtimes and development packages. 
 

  1. Install the Intel GPU Drivers from the LTS Stream

    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. For PyTorch 2.4 the public LTS version is 803.61.  Be sure to follow all the instructions including 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 the Intel Development Support Package

After the Intel GPU drivers are installed, choose one of these ways to install the Intel development support package: either using a Linux package manager: APT, YUM, or Zypper, or using an offline installation script.  Note that installing the development support package assumes you don't already have existing oneAPI components installed.  You should uninstall them if you do.

For RPM-based distributions such as Red Hat Enterprise Linux Server, YUM is the usual choice. You’ll need to configure YUM to install software packages that aren’t available in the default repositories. These instructions show how to add access to the appropriate Intel repository, along with the public key used to authenticate the downloaded packages.
 

  1. Create an Intel YUM repository information file and move it to the YUM configuration directory:
    
    tee > /tmp/intel-for-pytorch-gpu-dev.repo << EOF
    [intel-for-pytorch-gpu-dev]
    name=Intel for Pytorch GPU dev repository
    baseurl=https://yum.repos.intel.com/intel-for-pytorch-gpu-dev
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
    EOF
    
    sudo mv /tmp/intel-for-pytorch-gpu-dev.repo /etc/yum.repos.d
    
  2. Use YUM to install the Intel development support package:
    
    sudo yum install intel-for-pytorch-gpu-dev-0.5

For SUSE Linux Enterprise Server distributions, Zypper is the usual choice. You’ll need to configure Zypper to install software packages that aren’t available in the default repositories. These instructions show how to add access to the appropriate Intel repository, along with the public key used to authenticate the downloaded packages.
 

  1. The Zypper package manager uses the same rpm packages used by YUM, so add the Intel YUM repository:
    
    sudo zypper addrepo https://yum.repos.intel.com/intel-for-pytorch-gpu-dev intel-for-pytorch-gpu-dev
    
  2. If Zypper was unable to automatically import the Intel repository's public key, use RPM to manually import the key:
    
    rpm --import https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
    
  3. Use Zypper to install the Intel development support package:
    
    sudo zypper install intel-for-pytorch-gpu-dev-0.5
    

For Debian-based Linux distributions such as Ubuntu Server, APT is the usual choice. You’ll need to configure APT to install software packages that aren’t available in the default repositories. These instructions show how to add access to the appropriate Intel repository, along with the public key used to authenticate the downloaded 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
    
  3. 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
    
  4. Update the APT client package list and repository index:
    
    sudo apt update
    
  5. Use APT to install the Intel development support package:
    
    sudo apt install intel-for-pytorch-gpu-dev-0.5
    

Instead of using a package manager, you can install the Intel development package using an offline installation script. The installation script is a file containing all the needed files together with a script that extracts and installs the development package.

IMPORTANT: Use sudo to install files in system directories so they're available globally. Without sudo, files are installed in the current user's home directory.
 

  1. Make sure the necessary tools are available:
    
    sudo apt update
    sudo apt install -y wget
    
  2. Download and install the Intel GPU dependencies for PyTorch development installation script:
    
    cd /tmp
    
    wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/a8532c15-864f-4eac-88f2-a5c7e7998bbd/l_intel-for-pytorch-gpu-dev_p_0.5.2.18_offline.sh
    
    sh ./l_intel-for-pytorch-gpu-dev_p_0.5.2.18_offline.sh
    

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 PyTorch development bundle in your home directory, so try using this command instead:

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

Optionally, if you installed this pytorch-gpu-dev-0.5 package on your system and there are no other versions of pytorch-gpu-dev or oneAPI components installed, you can also use this command to set up the development package environment.  This command will always activate the newest version of pytorch-gpu-dev or oneAPI components installed in the /opt/intel/oneapi/.directory:

source /opt/intel/oneapi/setvars.sh

 

Consider adding the source 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.

1