Building PyTorch for Battlemage on Ubuntu 24.04.2

Articles in English

I have been building PyTorch on Ubuntu 22.04, and I successfully built it on Ubuntu 24.04.2 as well. Here is a report on the process.

The following steps are the same as those for Ubuntu 22.04.

sudo apt -y update
sudo apt install -y curl
sudo apt install -y build-essential
#!/bin/bash

# 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 noble unified" | \
  sudo tee /etc/apt/sources.list.d/intel-gpu-noble.list

# Update the package repository metadata
sudo apt update

# Install the compute-related packages
sudo apt-get install -y libze-intel-gpu1 libze1 intel-opencl-icd clinfo intel-gsc
sudo apt-get install -y libze-dev intel-ocloc

sudo usermod -aG render $USER
sudo usermod -aG video $USER
#!/bin/bash

sudo apt update -y

wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null

echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list

sudo apt update -y

sudo apt install -y intel-oneapi-base-toolkit
sudo apt install ffmpeg
cd ~
mkdir -p install
cd install
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh 
echo "export PATH=~/miniconda3/bin:$PATH" >> "$HOME/.bashrc"
echo "source ~/miniconda3/etc/profile.d/conda.sh" >> "$HOME/.bashrc"
source ~/.bashrc
#Update Conda to the Latest Version
conda update -n base -c defaults conda

#Set Conda-Forge as the Default Channel
conda config --add channels conda-forge
conda config --set channel_priority strict

#Create a Conda Environment
conda create -n env_test python=3.10
source activate env_test

#Update All Packages
conda update --all
cd ~
mkdir -p pytorch_build
cd pytorch_build

#Add the Following to .bashrc
echo "source /opt/intel/oneapi/setvars.sh" >> "$HOME/.bashrc"
source ~/.bashrc
source activate env_test
wget https://github.com/intel/intel-extension-for-pytorch/raw/v2.5.10%2Bxpu/scripts/compile_bundle.sh
time bash compile_bundle.sh /opt/intel/oneapi/compiler/latest /opt/intel/oneapi/mkl/latest /opt/intel/oneapi/ccl/latest /opt/intel/oneapi/mpi/latest /opt/intel/oneapi/pti/latest lnl-m 2> >(tee -a error_log.txt >&2)

When the build is successful, a dist folder is created inside each of the following directories within the pytorch_build folder in the home directory:

  • intel-extension-for-pytorch
  • audio
  • pytorch
  • torch-ccl
  • vision

The binary files (WHL files) are generated inside these dist folders, so I will consolidate them into one place.

Since this process is almost the same as in my previous post, there isn’t much more to write about.

Thanks for reading!

コメント

タイトルとURLをコピーしました