Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 2e5d128

Browse files
committed
Build magma without conda and push tarball
First step towards removing conda from magma builds. This still relies on the python conda image to do the builds, as that image already contains the required dependencies and various versions of cuda. Use a build script to build magma, instead of conda-build, to produce the binary tarball without the rest of the conda package. Upload the package to downloads.pytorch.org instead of the anaconda pytorch channel (TBD). This will require an update to the "install_conda.sh" script so that magma can be installed from that tarball directly. Signed-off-by: Andrea Frittoli <[email protected]>
1 parent 000a40b commit 2e5d128

File tree

4 files changed

+52
-23
lines changed

4 files changed

+52
-23
lines changed

magma/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
SHELL=/usr/bin/env bash
22

3+
DOCKER_CMD ?= docker
34
DESIRED_CUDA ?= 11.8
45
PACKAGE_NAME ?= magma-cuda118
56
CUDA_ARCH_LIST ?= -gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90
67

7-
DOCKER_RUN = set -eou pipefail; docker run --rm -i \
8+
DOCKER_RUN = set -eou pipefail; ${DOCKER_CMD} run --rm -i \
89
-v $(shell git rev-parse --show-toplevel):/builder \
910
-w /builder \
1011
-e DESIRED_CUDA=${DESIRED_CUDA} \

magma/build_magma.sh

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,52 @@
22

33
set -eou pipefail
44

5-
# Create a folder to be packaged
6-
PACKAGE_DIR=magma/${PACKAGE_NAME}
7-
PACKAGE_FILES=magma/package_files
8-
mkdir ${PACKAGE_DIR}
9-
cp ${PACKAGE_FILES}/build.sh ${PACKAGE_DIR}/build.sh
10-
cp ${PACKAGE_FILES}/meta.yaml ${PACKAGE_DIR}/meta.yaml
11-
cp ${PACKAGE_FILES}/thread_queue.patch ${PACKAGE_DIR}/thread_queue.patch
12-
cp ${PACKAGE_FILES}/cmakelists.patch ${PACKAGE_DIR}/cmakelists.patch
13-
cp ${PACKAGE_FILES}/getrf_shfl.patch ${PACKAGE_DIR}/getrf_shfl.patch
14-
cp ${PACKAGE_FILES}/getrf_nbparam.patch ${PACKAGE_DIR}/getrf_nbparam.patch
15-
cp ${PACKAGE_FILES}/CMake.patch ${PACKAGE_DIR}/CMake.patch
5+
# Environment variables
6+
# The script expects DESIRED_CUDA and PACKAGE_NAME to be set
7+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8+
MAGMA_VERSION=2.6.1
169

17-
conda install -yq conda-build conda-verify
18-
. ./conda/switch_cuda_version.sh "${DESIRED_CUDA}"
19-
(
20-
set -x
21-
conda build --output-folder magma/output "${PACKAGE_DIR}"
22-
)
10+
# Folders for the build
11+
PACKAGE_FILES=${ROOT_DIR}/magma/package_files # source patches and metadata
12+
PACKAGE_DIR=${ROOT_DIR}/magma/${PACKAGE_NAME} # build workspace
13+
PACKAGE_OUTPUT=${ROOT_DIR}/magma/output # where tarballs are stored
14+
PACKAGE_BUILD=${PACKAGE_DIR}/build # where the content of the tarball is prepared
15+
PACKAGE_RECIPE=${PACKAGE_BUILD}/info/recipe
16+
PACKAGE_LICENSE=${PACKAGE_BUILD}/info/license
17+
mkdir -p ${PACKAGE_DIR} ${PACKAGE_OUTPUT}/linux-64 ${PACKAGE_BUILD} ${PACKAGE_RECIPE} ${PACKAGE_LICENSE}
18+
19+
# Fetch magma sources and verify checksum
20+
pushd ${PACKAGE_DIR}
21+
curl -LO http://icl.utk.edu/projectsfiles/magma/downloads/magma-${MAGMA_VERSION}.tar.gz
22+
tar zxf magma-${MAGMA_VERSION}.tar.gz
23+
sha256sum --check < ${PACKAGE_FILES}/magma-${MAGMA_VERSION}.sha256
24+
popd
25+
26+
# Select cuda version
27+
. ${ROOT_DIR}/conda/switch_cuda_version.sh "${DESIRED_CUDA}"
28+
29+
# Apply patches and build
30+
pushd ${PACKAGE_DIR}/magma-${MAGMA_VERSION}
31+
patch < ${PACKAGE_FILES}/CMake.patch
32+
patch < ${PACKAGE_FILES}/cmakelists.patch
33+
patch -p0 < ${PACKAGE_FILES}/thread_queue.patch
34+
patch -p1 < ${PACKAGE_FILES}/getrf_shfl.patch
35+
patch -p1 < ${PACKAGE_FILES}/getrf_nbparam.patch
36+
# The build.sh script expects to be executed from the sources root folder
37+
INSTALL_DIR=${PACKAGE_BUILD} ${PACKAGE_FILES}/build.sh
38+
popd
39+
40+
# Package recipe, license and tarball
41+
# Folder and package name are backward compatible for the build workflow
42+
cp ${PACKAGE_FILES}/build.sh ${PACKAGE_RECIPE}/build.sh
43+
cp ${PACKAGE_FILES}/meta.yaml ${PACKAGE_RECIPE}/meta.yaml
44+
cp ${PACKAGE_FILES}/thread_queue.patch ${PACKAGE_RECIPE}/thread_queue.patch
45+
cp ${PACKAGE_FILES}/cmakelists.patch ${PACKAGE_RECIPE}/cmakelists.patch
46+
cp ${PACKAGE_FILES}/getrf_shfl.patch ${PACKAGE_RECIPE}/getrf_shfl.patch
47+
cp ${PACKAGE_FILES}/getrf_nbparam.patch ${PACKAGE_RECIPE}/getrf_nbparam.patch
48+
cp ${PACKAGE_FILES}/CMake.patch ${PACKAGE_RECIPE}/CMake.patch
49+
cp ${PACKAGE_FILES}/magma-${MAGMA_VERSION}.sha256 ${PACKAGE_RECIPE}/magma-${MAGMA_VERSION}.sha256
50+
cp ${PACKAGE_DIR}/magma-${MAGMA_VERSION}/COPYRIGHT ${PACKAGE_LICENSE}/COPYRIGHT
51+
pushd ${PACKAGE_BUILD}
52+
tar cjf ${PACKAGE_OUTPUT}/linux-64/${PACKAGE_NAME}-${MAGMA_VERSION}-1.tar.gz include lib info
53+
popd

magma/package_files/build.sh

100644100755
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
export CMAKE_LIBRARY_PATH=$PREFIX/lib:$PREFIX/include:$CMAKE_LIBRARY_PATH
2-
export CMAKE_PREFIX_PATH=$PREFIX
3-
export PATH=$PREFIX/bin:$PATH
4-
51
CUDA__VERSION=$(nvcc --version|sed -n 4p|cut -f5 -d" "|cut -f1 -d",")
62
if [ "$CUDA__VERSION" != "$DESIRED_CUDA" ]; then
73
echo "CUDA Version is not $DESIRED_CUDA. CUDA Version found: $CUDA__VERSION"
@@ -10,7 +6,7 @@ fi
106

117
mkdir build
128
cd build
13-
cmake .. -DUSE_FORTRAN=OFF -DGPU_TARGET="All" -DCMAKE_INSTALL_PREFIX=$PREFIX -DCUDA_ARCH_LIST="$CUDA_ARCH_LIST"
9+
cmake .. -DUSE_FORTRAN=OFF -DGPU_TARGET="All" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCUDA_ARCH_LIST="$CUDA_ARCH_LIST"
1410
make -j$(getconf _NPROCESSORS_CONF)
1511
make install
1612
cd ..
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6cd83808c6e8bc7a44028e05112b3ab4e579bcc73202ed14733f66661127e213 magma-2.6.1.tar.gz

0 commit comments

Comments
 (0)