How to Install and Use PyTorch on Intel Arc

PyTorch is an extension that speeds up your ML model training process using your Intel Arc GPU. Setting up PyTorch on a Windows machine with Intel is a complicated process that needs some additional software and hardware tweaking.

YTECHB has an Intel Arc machine that we tested to check if PyTorch could improve our model training speed and responses. It took a bit of time to get everything working, but the results were much better than those of relying on the CPU alone.

Letโ€™s take a look at the requirements before discussing them further.

Requirements

  • Intel Arc GPUs
  • Intel Graphics driver
  • Microsoft Visual C++ Redistributable package
  • Latest Python version

Installing PyTorch on Intel Arc PC

Before beginning the installation, weโ€™ll have to configure a few things, and enabling Resizable Bar is one of those. It will unleash your GPU’s full potential, and you must enable it from the BIOS. Entering the BIOS is pretty easy. Restart your PC and press the F-key (could be F2, F10, or even ESC) to enter the BIOS.

Since the key varies with manufacturers, check the official page to find out yours. Once you are in the BIOS, enable the Above 4G Decoding and Re-Size BAR Support options. Hunt for them in various subsections and activate them. Apply the changes and boot to the desktop.

Now, install the latest version of your Arc GPU drivers from the official website, and you can verify that Resizable Bar is active using the driverโ€™s GUI interface. While installing the driver, youโ€™ll see an option to install the Intel Graphics Software. Select it.

installing intel graphics software app for arc gpu

Since youโ€™ll use Arc GPU, a dedicated component, disabling the integrated one is a wise choice. Otherwise, you might encounter errors while trying to access Arc with PyTorch. To do so, launch Device Manager and expand the Display Adapters section. Right-click on the Integrated GPU and select the Disable device option.

disabling iGPU in Windows 11 using device manager

The last leg of this pre-installation needs the latest version of Microsoft Visual C++ Redistributable.

It is a library that apps use to work properly on Windows OS, and you can download and install it from the official site. You might have the package preinstalled when you added a new game from Steam.

Installing PyTorch

Weโ€™ll use the Mamba package manager to get things moving. Launch a new PowerShell window and enter the following commands one by one:

Invoke-WebRequest -Uri "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe" -OutFile "Miniforge3-Windows-x86_64.exe"
Start-Process -FilePath "Miniforge3-Windows-x86_64.exe" -ArgumentList "/S /InstallationType=JustMe /AddToPath=0 /RegisterPython=0" -Wait
Remove-Item "Miniforge3-Windows-x86_64.exe"

Activate the mamba environment with the following command:

%USERPROFILE%\mambaforge\Scripts\activate

After that, run the following command to create a Python environment and install packages, and extensions:

mamba create --name pytorch-arc python=3.11 -y
mamba activate pytorch-arc
mamba install libuv -y

pip install torch==2.3.1+cxx11.abi torchvision==0.18.1+cxx11.abi torchaudio==2.3.1+cxx11.abi intel-extension-for-pytorch==2.3.110+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/

Next, install the training code dependencies:

pip install jupyter matplotlib pandas pillow timm torcheval torchtnt tqdm
pip install cjm_pandas_utils cjm_psl_utils cjm_pil_utils cjm_pytorch_utils cjm_torchvision_tfms

Now, your training code dependencies are set up. You can begin downloading models from GitHub and start the training process.

Whenever you want to import the PyTorch extension, do it the following way:

import torch
import intel_extension_for_pytorch as ipex
print(f'PyTorch Version: {torch.version}')
print(f'Intel PyTorch Extension Version: {ipex.version}')

This sums up the post on installing PyTorch and running it on your Intel Arc GPU. The next phase is to train the AI models and check the performance difference between your old and new setup. However, using a GPU will boost the output time by a significant margin.

Related Articles:

Explore Stories

AUTHOR.

Photo of author

Abhishek Mishra

Abhishek fell in love with computers and consumer electronics a decade back. He has extensively covered popular operating systems, apps, and web services for the last five years at trusted publications including WindowsLatest, MakeUseOf, and Fossbytes. At YTECHB, he pens elaborate guides, emerging tech topics, and listicles.

Leave a Comment

Share to...