Bare Metal Cloud (BMC) GPU servers provide the hardware for machine learning workloads using Intel Max GPUs. This tutorial covers GPU verification, Intel oneAPI Base Toolkit installation, and setup options for TensorFlow and PyTorch. You can also use a preconfigured PyTorch Docker image to get started without installing the framework on the server.
Prerequisites
A deployed GPU server configuration with Ubuntu Jammy. If you selected Custom OS, see Install a Custom OS first. Connect to the server via SSH.
Step 1: View GPU Topology and Driver Details
The server has two Intel MAX 1100 GPU cards and a preinstalled GPU driver. To view the card topology, run:
xpu-smi topology -mCode language: Bash (bash)
The output shows the system's GPU topology in matrix form, illustrating how the GPU cards are interconnected and how data flows between them.
To view the preconfigured driver details, run:
modinfo i915Code language: Bash (bash)
The output shows the i915 kernel module, which manages the Intel graphics driver. It has details such as module parameters, dependencies, and license information.
View PyTorch Docker Image and Run Container
If using the PyTorch GPU server, the machine learning library Docker image is preinstalled and ready to run on the server:
1. To see the Docker image, use:
docker imagesCode language: Bash (bash)
The output shows the image details, including the repository and tag (required to run the container).
2. Run the container with the docker run command:
docker run --rm -it --privileged --device=/dev/dri --ipc=host [repository]:[tag] bashCode language: Bash (bash)
The command attaches to the container as root. It immediately switches to the Bash shell inside the container.
3. To check the PyTorch version and view the XPU details, run the following inside the container:
#python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__); [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())];"Code language: Bash (bash)
The command shows the PyTorch version, the Intel extension version, and the data for each XPU device.
Step 2: Install Intel oneAPI Base Toolkit
The Intel oneAPI Base Toolkit is a collection of tools for optimizing machine learning across different hardware. It provides a unified API that (with minimal adjustments) works across various architectures.
To install the toolkit, do the following:
1. Update the APT package list:
sudo apt updateCode language: Bash (bash)
2. Set up the repository:
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/nullCode language: Bash (bash)
The command downloads the repository key and adds it to the system keyring.
3. Add the entry to APT sources:
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.listCode language: Bash (bash)
The command adds the signed entry and enables use of the repository.
4. Update the package list:
sudo apt updateCode language: Bash (bash)
The list now includes the newly added source.
5. Install the base toolkit with:
sudo apt install intel-basekitCode language: Bash (bash)
The command installs the latest available toolkit.
6. Set up the oneAPI environment variables by running these shell scripts:
- Data Parallel C++ (DPC++) Compiler (oneDPL):
source /opt/intel/oneapi/compiler/latest/env/vars.shCode language: Bash (bash)
- Math Kernel Library (oneMKL):
source /opt/intel/oneapi/mkl/latest/env/vars.shCode language: Bash (bash)
- MPI Library:
source /opt/intel/oneapi/mpi/latest/env/vars.shCode language: Bash (bash)
- Collective Communications Library (oneCCL):
source /opt/intel/oneapi/ccl/latest/env/vars.shCode language: Bash (bash)
These are the minimum requirements for the Intel extension to work with either TensorFlow or PyTorch. Add other components as needed, such as the oneDNN library for deep neural networks or oneTBB for parallelizing compute-intensive workloads.
Step 3: Set Up Machine Learning Libraries
PyTorch and TensorFlow are popular machine learning libraries that support Intel GPUs. Both work with Python and it is recommended to use the venv module to isolate environments.
Install the Python venv module with:
sudo apt install python3.10-venvCode language: Bash (bash)
This module lets you create isolated virtual environments for Python development.
Next, depending on your requirements, install and set up either TensorFlow or PyTorch. The sections below provide step-by-step installation instructions specifically tailored for Intel AI workloads.
Option 1: TensorFlow for GPU
To install TensorFlow with the Intel extension for TensorFlow support:
1. Create a virtual environment for the installation:
python3 -m venv tensorflow_testCode language: Bash (bash)
This command creates an isolated environment for package installation, as TensorFlow recommends.
2. Run the activation script to activate the virtual environment:
source tensorflow_test/bin/activateCode language: Bash (bash)
3. Upgrade PIP to the latest version:
pip install --upgrade pipCode language: Bash (bash)
4. Install TensorFlow using PIP:
pip install tensorflow==2.15.0Code language: Bash (bash)
Adjust the version number to match the oneAPI base toolkit version.
5. Install the Intel extension for TensorFlow:
pip install --upgrade intel-extension-for-tensorflow[xpu]Code language: Bash (bash)
The Intel extension is specifically tailored for Intel-based AI workloads.
6. Confirm the setup worked. Run the following command:
python3 -c "import tensorflow as tf; import intel_extension_for_tensorflow as itex; print(tf.__version__); print(itex.__version__); [print(f'[{device}]: {tf.config.experimental.get_device_details(device)}') for device in tf.config.experimental.list_physical_devices('XPU')];"Code language: Bash (bash)
The script imports TensorFlow and the Intel extension for TensorFlow. It prints the versions of these two libraries and the device details.
The output shows that the Intel extension for TensorFlow GPU has been loaded and lists the two available XPU devices.
Option 2: PyTorch for GPU
To install and set up PyTorch and the Intel extension for PyTorch, do the following:
1. Create a virtual environment:
python3 -m venv torch_testCode language: Bash (bash)
This isolates the installation from the rest of the system.
2. Activate the environment:
source torch_test/bin/activateCode language: Bash (bash)
The terminal changes to the torch_test environment.
3. Upgrade PIP with:
pip install --upgrade pipCode language: Bash (bash)
4. Install PyTorch inside the environment:
python -m pip install torch==2.1.0.post2 torchvision==0.16.0.post2 torchaudio==2.1.0.post2 intel-extension-for-pytorch==2.1.30+xpu oneccl_bind_pt==2.1.300+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/Code language: Bash (bash)
The command installs torch, torchvision, torchaudio, and the Intel extension for PyTorch. Ensure the versions match the installed oneAPI version.
Note
Installing torchvision and torchaudio is optional. Check project requirements to install only the required packages.
5. Confirm the installation worked with the following:
python3 -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__); [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())];"Code language: Bash (bash)
The script imports PyTorch and the Intel extension libraries. It prints their versions and the details for the two XPU devices.