Skip to content

Commit

Permalink
Build executables into bin/ and data/
Browse files Browse the repository at this point in the history
This commit changes the gpu-setup script behaviour to build the cuda-samples
and gpu-burn projects inside the `build/bin` directory, then copy them
out into the `bin/` and (the necessary data files) into `data/`. For the
cuda-samples executables to work, they need access to the data files,
but they do not take the path to the data dir as an argument; to
circumvent this limitation, I have made wrapper scripts that copy the
necessary file into the temporary working directory that checkbox
creates.

Because of the change in build behaviour, the `gpu-setup` script now runs
mostly as a regular user (to avoid permission issues when cleaning
directories/builds). The expected operation now is to run `./manage.py build`
instead of running the `gpu-setup.sh` script itself. This is more inline
with what is done with the other providers.
  • Loading branch information
pedro-avalos committed Jul 29, 2024
1 parent a854201 commit aca24be
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 26 deletions.
4 changes: 4 additions & 0 deletions providers/gpgpu/bin/gpu_burn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
CUDA_PATH=$(find /usr/local -maxdepth 1 -type d -iname "cuda*")/bin
export PATH=$PATH:$CUDA_PATH
gpu_burn -c $PLAINBOX_PROVIDER_DATA/compare.ptx 14400 | grep -v -e '^[[:space:]]*$' -e "errors:" -e "Summary at"
3 changes: 3 additions & 0 deletions providers/gpgpu/bin/matrixMulDrv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
cp $PLAINBOX_PROVIDER_DATA/matrixMul_kernel64.fatbin .
matrixMulDrv
5 changes: 5 additions & 0 deletions providers/gpgpu/bin/simpleTextureDrv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
cp $PLAINBOX_PROVIDER_DATA/simpleTexture_kernel64.fatbin .
cp $PLAINBOX_PROVIDER_DATA/teapot512.pgm .
cp $PLAINBOX_PROVIDER_DATA/ref_rotated.pgm .
simpleTextureDrv
3 changes: 3 additions & 0 deletions providers/gpgpu/bin/vectorAddDrv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
cp $PLAINBOX_PROVIDER_DATA/vectorAdd_kernel64.fatbin .
vectorAddDrv
3 changes: 2 additions & 1 deletion providers/gpgpu/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.PHONY: all
all: gpu-setup

gpu-setup:
sudo ../../tools/gpu-setup
../../tools/gpu-setup
44 changes: 24 additions & 20 deletions providers/gpgpu/tools/gpu-setup
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/bash

if [[ $EUID -ne 0 ]]; then
echo "ERROR: This script must be run as root"
exit 1
fi

echo "Configuring system for GPU Testing"
echo "**********************************"
echo "*"
Expand Down Expand Up @@ -75,48 +70,57 @@ if [[ $? -ne 0 ]] ; then
echo "ERROR: GPG key import failed. Invalid gpg key?"
exit 1
fi
gpg --yes --no-default-keyring --keyring ./temp-keyring.gpg --export \
sudo gpg --yes --no-default-keyring --keyring ./temp-keyring.gpg --export \
--output /usr/share/keyrings/cuda-archive-keyring.gpg
rm ./temp-keyring.gpg
rm ./temp-keyring.gpg~
rm ./cuda-archive-keyring.gpg

PINFILE="cuda-$OSRELEASE.pin"
wget -O /etc/apt/preferences.d/cuda-repository-pin-600 "$REPO_URL/$PINFILE"
sudo wget -O /etc/apt/preferences.d/cuda-repository-pin-600 "$REPO_URL/$PINFILE"

cat > /etc/apt/sources.list.d/cuda-$OSRELEASE-$ARCH.list <<EOF
sudo tee /etc/apt/sources.list.d/cuda-$OSRELEASE-$ARCH.list << 'EOF'
deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] http://developer.download.nvidia.com/compute/cuda/repos/$OSRELEASE/$ARCH/ /
EOF

# Install necessary files
#apt update
echo "* Installing necessary pacakges"
apt install -y build-essential git
sudo apt install -y build-essential git
## need to break this out to fix issue where cuda installs gdm3
apt install -y --no-install-recommends cuda-toolkit
sudo apt install -y --no-install-recommends cuda-toolkit

#fix the path to get nvcc from the cuda package
CUDA_PATH=$(find /usr/local -maxdepth 1 -type d -iname "cuda*")/bin
export PATH=$PATH:$CUDA_PATH

mkdir -p ../../bin ../../data

# clone cuda-samples repo
echo "* Cloning cuda-samples repo"
CUDA_SAMPLES_DIR=/opt/cuda-samples
git clone https://github.com/nvidia/cuda-samples.git $CUDA_SAMPLES_DIR
git clone https://github.com/nvidia/cuda-samples.git
echo "* Building cuda-samples tests"
cd $CUDA_SAMPLES_DIR/Samples/0_Introduction/matrixMulDrv && make
cd $CUDA_SAMPLES_DIR/Samples/0_Introduction/vectorAddDrv && make
cd $CUDA_SAMPLES_DIR/Samples/1_Utilities/deviceQueryDrv && make
cd $CUDA_SAMPLES_DIR/Samples/0_Introduction/simpleTextureDrv && make
make -C cuda-samples/Samples/0_Introduction/matrixMulDrv
cp cuda-samples/Samples/0_Introduction/matrixMulDrv/matrixMulDrv ../../bin/
cp -r cuda-samples/Samples/0_Introduction/matrixMulDrv/data/* ../../data/
make -C cuda-samples/Samples/0_Introduction/vectorAddDrv
cp cuda-samples/Samples/0_Introduction/vectorAddDrv/vectorAddDrv ../../bin/
cp -r cuda-samples/Samples/0_Introduction/vectorAddDrv/data/* ../../data/
make -C cuda-samples/Samples/1_Utilities/deviceQueryDrv
cp cuda-samples/Samples/1_Utilities/deviceQueryDrv/deviceQueryDrv ../../bin/
make -C cuda-samples/Samples/0_Introduction/simpleTextureDrv
cp -r cuda-samples/Samples/0_Introduction/simpleTextureDrv/data/* ../../data/
cp cuda-samples/Samples/0_Introduction/simpleTextureDrv/simpleTextureDrv ../../bin/
echo "* Building cuda-samples tests completed..."

# get the gpu-burn repo and build it
echo "* Cloning gpu-burn repo"
GPU_BURN_DIR=/opt/gpu-burn
git clone https://github.com/wilicc/gpu-burn.git $GPU_BURN_DIR
cd $GPU_BURN_DIR
git clone https://github.com/wilicc/gpu-burn.git
echo "* Building gpu-burn"
make && echo "* Build completed..."
make -C gpu-burn
cp gpu-burn/gpu_burn ../../bin/
cp gpu-burn/compare.ptx ../../data/
echo "* Build completed..."
echo "*"
echo "* Completed installation. Please reboot the machine now"
echo "* to load the nVidia proprietary drivers"
10 changes: 5 additions & 5 deletions providers/gpgpu/units/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ estimated_duration: 300
requires:
package.name == 'cuda-toolkit'
_summary: GPGPU stress testing
command: cd /opt/gpu-burn/ && ./gpu_burn 14400 | grep -v -e '^[[:space:]]*$' -e "errors:" -e "Summary at"
command: gpu_burn.sh

id: gpgpu/matrix-mul-drv
category_id: gpgpu
Expand All @@ -14,7 +14,7 @@ estimated_duration: 4
requires:
package.name == 'cuda-toolkit'
_summary: GPGPU matrix multiplication
command: cd /opt/cuda-samples/Samples/0_Introduction/matrixMulDrv && ./matrixMulDrv
command: matrixMulDrv.sh

id: gpgpu/vector-add-drv
category_id: gpgpu
Expand All @@ -23,7 +23,7 @@ estimated_duration: 4
requires:
package.name == 'cuda-toolkit'
_summary: GPGPU vector addition
command: cd /opt/cuda-samples/Samples/0_Introduction/vectorAddDrv && ./vectorAddDrv
command: vectorAddDrv.sh

id: gpgpu/device-query-drv
category_id: gpgpu
Expand All @@ -32,7 +32,7 @@ estimated_duration: 4
requires:
package.name == 'cuda-toolkit'
_summary: GPGPU query device
command: cd /opt/cuda-samples/Samples/1_Utilities/deviceQueryDrv && ./deviceQueryDrv
command: deviceQueryDrv

id: gpgpu/simple-texture-drv
category_id: gpgpu
Expand All @@ -41,4 +41,4 @@ estimated_duration: 4
requires:
package.name == 'cuda-toolkit'
_summary: GPGPU simple textures
command: cd /opt/cuda-samples/Samples/0_Introduction/simpleTextureDrv && ./simpleTextureDrv
command: simpleTextureDrv.sh

0 comments on commit aca24be

Please sign in to comment.