Skip to content

Commit

Permalink
Add GitHub Actions action that builds LBANN (#2418)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun authored Jan 12, 2024
1 parent 196b0cb commit 2756920
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 15 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/build-cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: LBANN CPU

on:
push:
branches: develop
pull_request:
branches: develop
merge_group:
branches: develop

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc] # , clang

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libyaml-dev cmake lmod ninja-build
sudo apt-get install -y libblas-dev libopenblas-dev liblapacke-dev
sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev
python -m pip install --upgrade pip
- name: Restore cached Spack-built dependencies
id: cache-spack
uses: actions/cache/restore@v3
with:
path: |
~/.spack
spack
key: ${{ runner.os }}-${{ matrix.compiler }}-spackdeps

- name: Build and install LBANN dependencies
if: steps.cache-spack.outputs.cache-hit != 'true'
run: |
source /usr/share/lmod/lmod/init/bash
git clone -c feature.manyFiles=true https://github.com/spack/spack.git
cd spack
git checkout 73858df14dc3f0e701814c84bb8bd6b72f80a806 # Use a tried and true version of Spack
cd ..
source spack/share/spack/setup-env.sh
scripts/build_lbann.sh -d --dependencies-only -l ci -- +numpy +unit_tests %${{ matrix.compiler }}
- name: Cache Spack-built dependencies
id: cache-spack-save
uses: actions/cache/save@v3
with:
path: |
~/.spack
spack
key: ${{ runner.os }}-${{ matrix.compiler }}-spackdeps

- name: Build LBANN
run: |
source /usr/share/lmod/lmod/init/bash
source spack/share/spack/setup-env.sh
scripts/build_lbann.sh -r -l ci --ci -- +numpy +unit_tests %${{ matrix.compiler }}
- name: Test Catch2
run: |
cd builds/*/build
./unit_test/helpers_tests
./unit_test/seq-catch-tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ spack_environments/users/

# we don't want to collect slurm output
**/slurm-*.out

# Ignore default lbann output experiment directory names
????????_??????_lbann*/
6 changes: 4 additions & 2 deletions scripts/build_lbann.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fi
SPACK_INSTALL_DEPENDENCIES_ONLY=
# List of packages to install at the root level with LBANN
SPACK_EXTRA_ROOT_PACKAGES=
EXTRA_NINJA_FLAGS=

CONFIG_FILE_NAME=

Expand Down Expand Up @@ -120,7 +121,7 @@ while :; do
--ci)
# We want all compilation errors
LBANN_WARNINGS_AS_ERRORS="TRUE"
EXTRA_NINJA_FLAGS="-k 0"
EXTRA_NINJA_FLAGS="${EXTRA_NINJA_FLAGS} -k 0"
;;
--ci-pip)
PIP_EXTRAS="${PIP_EXTRAS} ${LBANN_HOME}/ci_test/requirements.txt"
Expand Down Expand Up @@ -174,6 +175,7 @@ while :; do
-j|--build-jobs)
if [ -n "${2}" ]; then
BUILD_JOBS="-j${2}"
EXTRA_NINJA_FLAGS="${EXTRA_NINJA_FLAGS} -j${2}"
shift
else
echo "\"${1}\" option requires a non-empty option argument" >&2
Expand Down Expand Up @@ -1119,7 +1121,7 @@ EOF
echo "I have found and will use ${MATCHED_CONFIG_FILE}"
CONFIG_FILE_NAME=${MATCHED_CONFIG_FILE}
if [[ ! -e "${LBANN_BUILD_PARENT_DIR}/${CONFIG_FILE_NAME}" ]]; then
echo "Overwritting exising CMake config file in ${LBANN_BUILD_PARENT_DIR}/${CONFIG_FILE_NAME}"
echo "Overwriting exising CMake config file in ${LBANN_BUILD_PARENT_DIR}/${CONFIG_FILE_NAME}"
fi
# Save the config file in the build directory
CMD="mv ${MATCHED_CONFIG_FILE_PATH} ${LBANN_BUILD_PARENT_DIR}/${CONFIG_FILE_NAME}"
Expand Down
1 change: 1 addition & 0 deletions scripts/customize_build_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ set_center_specific_spack_dependencies()
esac
else
echo "No center found and no center-specified CENTER_DEPENDENCIES for ${spack_arch_target} at ${center}."
CENTER_COMPILER="%gcc" # Relatively safe default choice
fi
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function find_cmake_config_file() {

HOST=$(hostname)
HOST=${HOST//[[:digit:]]/}
HOST=${HOST//\-/}
HOST=$(echo $HOST | sed 's/\(.*\)-$/\1/')

[[ -z "${SYS_TYPE}" ]] && SYS=${SPACK_ARCH} || SYS="${SYS_TYPE}"

if [[ "${center_compiler}" =~ .*"%".*"@".* ]]; then
Expand Down
32 changes: 24 additions & 8 deletions src/data_ingestion/readers/data_reader_mnist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ void load_mnist_data(const std::string imagepath,
}

int magicnum1, numitems1;
fread(&magicnum1, 4, 1, fplbl);
fread(&numitems1, 4, 1, fplbl);
if (!fread(&magicnum1, 4, 1, fplbl)) {
LBANN_ERROR("Invalid MNIST file format (1)");
}
if (!fread(&numitems1, 4, 1, fplbl)) {
LBANN_ERROR("Invalid MNIST file format (2)");
}
__swapEndianInt((unsigned int&)magicnum1);
__swapEndianInt((unsigned int&)numitems1);

Expand All @@ -122,10 +126,18 @@ void load_mnist_data(const std::string imagepath,
}

int magicnum2, numitems2, imgwidth, imgheight;
fread(&magicnum2, 4, 1, fpimg);
fread(&numitems2, 4, 1, fpimg);
fread(&imgwidth, 4, 1, fpimg);
fread(&imgheight, 4, 1, fpimg);
if (!fread(&magicnum2, 4, 1, fpimg)) {
LBANN_ERROR("Invalid MNIST file format (3)");
}
if (!fread(&numitems2, 4, 1, fpimg)) {
LBANN_ERROR("Invalid MNIST file format (4)");
}
if (!fread(&imgwidth, 4, 1, fpimg)) {
LBANN_ERROR("Invalid MNIST file format (5)");
}
if (!fread(&imgheight, 4, 1, fpimg)) {
LBANN_ERROR("Invalid MNIST file format (6)");
}
__swapEndianInt((unsigned int&)magicnum2);
__swapEndianInt((unsigned int&)numitems2);
__swapEndianInt((unsigned int&)imgwidth);
Expand All @@ -147,8 +159,12 @@ void load_mnist_data(const std::string imagepath,
m_image_data.resize(numitems1);
for (int n = 0; n < numitems1; n++) {
m_image_data[n].resize(1 + (imgwidth * imgheight));
fread(&m_image_data[n][0], 1, 1, fplbl);
fread(&m_image_data[n][1], imgwidth * imgheight, 1, fpimg);
if (!fread(&m_image_data[n][0], 1, 1, fplbl)) {
LBANN_ERROR("Invalid MNIST file format (7)");
}
if (!fread(&m_image_data[n][1], imgwidth * imgheight, 1, fpimg)) {
LBANN_ERROR("Invalid MNIST file format (8)");
}
}
fclose(fpimg);
fclose(fplbl);
Expand Down
3 changes: 3 additions & 0 deletions src/execution_algorithms/kfac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ bool KFAC::train_mini_batch(ExeContextType& kfac_context,
data_coordinator& dc)
{
LBANN_CALIPER_MARK_FUNCTION;
#ifdef LBANN_HAS_GPU
bool profile = true;
#endif

auto& sgd_context = kfac_context.get_sgd_execution_context();
auto current_epoch = sgd_context.get_epoch();

Expand Down
1 change: 1 addition & 0 deletions src/utils/amp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace {
bool isfinite(__half x) { return std::isfinite((float)x); }
} // namespace
#endif
using std::isfinite;

namespace lbann {
namespace amp {
Expand Down
6 changes: 2 additions & 4 deletions src/utils/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,15 @@ namespace file {

std::string extract_parent_directory(const std::string& path)
{
std::vector<char> buffer(path.size() + 1);
std::vector<char> buffer(path.size() + 1, '\0');
path.copy(buffer.data(), path.size());
buffer.back() = '\0';
return ::dirname(buffer.data());
}

std::string extract_base_name(const std::string& path)
{
std::vector<char> buffer(path.size() + 1);
std::vector<char> buffer(path.size() + 1, '\0');
path.copy(buffer.data(), path.size());
buffer.back() = '\0';
return ::basename(buffer.data());
}

Expand Down

0 comments on commit 2756920

Please sign in to comment.