Hi Mo,

I was building PyTorch and noticed that Magma [1] is a dependency for some configurations. There is a magma package with NVIDIA GPU support in contrib [2], but we don't have an AMD GPU version packaged for Debian. It took a bit of trial and error to successfully build the library, so I thought I'd share instructions for building magma with AMD GPU support:

sudo apt-get -y install git build-essential libopenblas-dev gfortran hipcc 
librocblas-dev libhipblas-dev librocsparse-dev libhipsparse-dev
git clonehttps://github.com/icl-utk-edu/magma.git
cd magma
git checkout v2.8.0
echo -e 'BACKEND = hip\nFORT = true\nGPU_TARGET = gfx803 gfx900 gfx906 gfx908 
gfx90a gfx1010 gfx1030 gfx1100 gfx1101 gfx1102' > make.inc
sed -i '1s/python$/python3/' tools/codegen.py
sed -i 's/hip::host/hip::device/' CMakeLists.txt
make generate
CXX=hipcc cmake -S. -Bbuild -DBLA_VENDOR=OpenBLAS 
-DAMDGPU_TARGETS="gfx803;gfx900;gfx906;gfx908;gfx90a;gfx1010;gfx1030;gfx1100;gfx1101;gfx1102"
 -DMAGMA_ENABLE_HIP=ON
make -j16 -C build

I've only tested on my local workstation, but the above commands _should_ result in a magma library that runs on any discrete AMD GPU since Vega (excluding MI300).

This AMD GPU build takes a long time so it would be nice to provide a binary package. I'd be happy to help maintain the magma package, but I think I will need your help to get it started. In particular, it's not clear to me how to organize the package sources to minimize duplicate work between the NVIDIA and AMD variants. I'm also unsure of what conventions to follow for package naming.

Sincerely,
Cory Bloor

[1]: https://github.com/icl-utk-edu/magma
[2]: https://tracker.debian.org/pkg/magma

Reply via email to