PyTorch on DeltaAI

DeltaAI provides pre-built PyTorch environments as modules and NVIDIA NGC containers. The recommended approach is to load a module, which gives you a tested conda environment with GPU support, Slingshot 11 networking, and common data-science packages ready to go.


NGC Containers

NVIDIA NGC containers are available at /sw/user/NGC_containers/. List available PyTorch containers:

ls /sw/user/NGC_containers/pytorch_*

The most recent container is pytorch_26.01-py3.sif.

#!/bin/bash
#SBATCH --account=account_name
#SBATCH --partition=ghx4
#SBATCH --nodes=1
#SBATCH --gpus-per-node=1
#SBATCH --time=00:20:00

srun apptainer run --nv \
     --bind /projects \
     /sw/user/NGC_containers/pytorch_26.01-py3.sif \
     python3 my_script.py

Note

NGC containers bundle their own CUDA runtime and libraries. For multi-node container jobs, additional bind mounts for Cray MPICH and Slingshot libraries are required – see Containers.


Installing PyTorch in Your Own Environment

If you need a PyTorch version that is not available as a module, you can install into your own conda or venv environment. Use the stable release index, not the nightly index.

# Create a fresh conda environment
module load python/miniforge3_pytorch       # any version -- this only provides conda
conda create -p ~/my_pytorch python=3.12 -y
conda activate ~/my_pytorch

# Install PyTorch with CUDA 13.0 support (aarch64 wheels available)
pip install torch torchvision torchaudio \
    --index-url https://download.pytorch.org/whl/cu130

To find wheel availability for other CUDA versions or older releases, check the PyTorch previous versions page. Not every CUDA variant publishes aarch64 wheels.

If your custom environment needs multi-node MPI support, build mpi4py from source against Cray MPICH:

MPICC="cc -shared" pip install --no-cache-dir --no-binary mpi4py mpi4py

Confirm it linked correctly before running a multi-node job (run on a compute node):

ldd $(python -c "import mpi4py.MPI as m; print(m.__file__)") | grep -E "mpi|fabric"

Expect libmpi_gnu_123.so.12 and libmpi_gtl_cuda.so.0 resolving from /opt/cray/pe/lib64/, and libfabric.so.1 from /opt/cray/libfabric/. A generic libmpi.so, or a libfabric resolving inside your environment, means the build did not pick up Cray MPICH.

Warning

Never conda install mpi4py. The conda package links against its own MPI and pulls in a conda libfabric that shadows the Slingshot one. Neither substitution reports an error – inter-node traffic silently degrades to a TCP fallback.

Building Custom CUDA Extensions

torch.utils.cpp_extension compiles custom CUDA kernels against whatever CUDA_HOME points at, and CUDA_HOME is always set on DeltaAI – by the default cudatoolkit module under python/miniforge3_pytorch/2.10.0, and by the site cuda/13.1.1 module that 2.11.0 and 2.12.0 load themselves. Check which toolkit you are building against before you compile:

module load python/miniforge3_pytorch/2.12.0
conda activate base
echo $CUDA_HOME        # points to the system CUDA toolkit
python -c "from torch.utils.cpp_extension import CUDAExtension; print('OK')"

Note

Under the 2.11.0 and 2.12.0 modules, CUDA_HOME resolves to /sw/user/cudatoolkits/installs/cuda-13.1.1 while the PyTorch wheel itself bundles the CUDA 13.0 runtime, so an extension you build is compiled against a slightly newer toolkit than the one torch ships. Record both versions alongside any extension you distribute to other users, and rebuild the extension when you move it to a different PyTorch module.