|
1 | | -#!/bin/bash |
2 | | -# Script used in CI and CD pipeline |
| 1 | +#!/usr/bin/env bash |
| 2 | +# Script used only in CD pipeline |
3 | 3 |
|
4 | | -set -ex |
5 | | - |
6 | | -ver() { |
7 | | - printf "%3d%03d%03d%03d" $(echo "$1" | tr '.' ' '); |
8 | | -} |
| 4 | +set -eou pipefail |
9 | 5 |
|
10 | 6 | function do_install() { |
11 | 7 | rocm_version=$1 |
@@ -36,55 +32,6 @@ function do_install() { |
36 | 32 | fi |
37 | 33 | popd |
38 | 34 | ) |
| 35 | +} |
39 | 36 |
|
40 | | -# Magma build scripts need `python` |
41 | | -ln -sf /usr/bin/python3 /usr/bin/python |
42 | | - |
43 | | -ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') |
44 | | -case "$ID" in |
45 | | - almalinux) |
46 | | - yum install -y gcc-gfortran |
47 | | - ;; |
48 | | - *) |
49 | | - echo "No preinstalls to build magma..." |
50 | | - ;; |
51 | | -esac |
52 | | - |
53 | | -MKLROOT=${MKLROOT:-/opt/conda/envs/py_$ANACONDA_PYTHON_VERSION} |
54 | | - |
55 | | -# "install" hipMAGMA into /opt/rocm/magma by copying after build |
56 | | -if [[ $(ver $ROCM_VERSION) -ge $(ver 7.0) ]]; then |
57 | | - git clone https://github.com/ROCm/utk-magma.git -b release/2.9.0_rocm70 magma |
58 | | - pushd magma |
59 | | - # version 2.9 + ROCm 7.0 related updates |
60 | | - git checkout 91c4f720a17e842b364e9de41edeef76995eb9ad |
61 | | -else |
62 | | - git clone https://bitbucket.org/icl/magma.git |
63 | | - pushd magma |
64 | | - # Version 2.7.2 + ROCm related updates |
65 | | - git checkout a1625ff4d9bc362906bd01f805dbbe12612953f6 |
66 | | -fi |
67 | | - |
68 | | -cp make.inc-examples/make.inc.hip-gcc-mkl make.inc |
69 | | -echo 'LIBDIR += -L$(MKLROOT)/lib' >> make.inc |
70 | | -if [[ -f "${MKLROOT}/lib/libmkl_core.a" ]]; then |
71 | | - echo 'LIB = -Wl,--start-group -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -Wl,--end-group -lpthread -lstdc++ -lm -lgomp -lhipblas -lhipsparse' >> make.inc |
72 | | -fi |
73 | | -echo 'LIB += -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib -Wl,--rpath,$(MKLROOT)/lib -Wl,--rpath,/opt/rocm/magma/lib -ldl' >> make.inc |
74 | | -echo 'DEVCCFLAGS += --gpu-max-threads-per-block=256' >> make.inc |
75 | | -export PATH="${PATH}:/opt/rocm/bin" |
76 | | -if [[ -n "$PYTORCH_ROCM_ARCH" ]]; then |
77 | | - amdgpu_targets=`echo $PYTORCH_ROCM_ARCH | sed 's/;/ /g'` |
78 | | -else |
79 | | - amdgpu_targets=`rocm_agent_enumerator | grep -v gfx000 | sort -u | xargs` |
80 | | -fi |
81 | | -for arch in $amdgpu_targets; do |
82 | | - echo "DEVCCFLAGS += --offload-arch=$arch" >> make.inc |
83 | | -done |
84 | | -# hipcc with openmp flag may cause isnan() on __device__ not to be found; depending on context, compiler may attempt to match with host definition |
85 | | -sed -i 's/^FOPENMP/#FOPENMP/g' make.inc |
86 | | -make -f make.gen.hipMAGMA -j $(nproc) |
87 | | -LANG=C.UTF-8 make lib/libmagma.so -j $(nproc) MKLROOT="${MKLROOT}" |
88 | | -make testing/testing_dgemm -j $(nproc) MKLROOT="${MKLROOT}" |
89 | | -popd |
90 | | -mv magma /opt/rocm |
| 37 | +do_install $1 |
0 commit comments