Linux Installation Guide

Setting up Development Environment using Spack

Prerequisites

Before starting, ensure you have the following:

  1. NVIDIA GPU with CUDA support (for GPU acceleration)

  2. NVIDIA Driver installed on your system (if using GPU acceleration) - Check with nvidia-smi command - If not installed, follow your distribution’s instructions for NVIDIA driver installation

Installing Spack

  1. Clone Spack repository:

    git clone -c feature.manyFiles=true https://github.com/spack/spack.git
    cd spack
    git checkout releases/v0.21
    
  2. Set up Spack environment:

    # Add to your ~/.bashrc or ~/.zshrc
    export SPACK_ROOT=/path/to/spack
    source $SPACK_ROOT/share/spack/setup-env.sh
    
  3. Verify installation:

    spack --version
    spack compiler find
    

Setting up METADA Environment

  1. Create a new Spack environment:

    spack env create metada
    spack env activate metada
    
  2. Add required packages:

    # Core development tools
    spack add cmake@3.30: ninja gcc
    # GPU acceleration support
    spack add cuda@12.1.0
    # Scientific computing packages
    spack add eigen boost
    # Configuration packages
    spack add yaml-cpp nlohmann-json
    # Testing and development tools
    spack add googletest
    spack add lcov
    
  3. Install ng-log from source (since it’s not available in Spack):

    git clone --depth 1 https://github.com/ng-log/ng-log.git
    cd ng-log
    mkdir build && cd build
    cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$SPACK_ROOT/opt/spack/linux-ubuntu22.04-x86_64/gcc-12.2.0/ng-log-master
    ninja
    ninja install
    cd ../..
    
  4. Configure environment:

    spack.yaml
    # Spack environment configuration for METADA
    spack:
      # Specify package preferences and variants
      specs:
      - cmake@3.10.0:
      - ninja@1.10.0:
      - gcc@11.0.0:
      - cuda@12.1.0
      - eigen@3.4.0:
      - boost@1.74.0: +python +numpy
      - python@3.8.0: +shared
      - py-numpy
      - py-scipy
      - py-matplotlib
      - googletest@1.11.0: +gmock
      - lcov@1.16:
      - clang@15.0.0:
      - yaml-cpp
      - nlohmann-json
    
      # Package configuration
      packages:
        cuda:
          buildable: false
          externals:
          - spec: cuda@12.1.0
            prefix: /usr/local/cuda-12.1
        
        python:
          variants: +shared
          version: [3.8.0:]
    
        googletest:
          variants: +gmock
          version: [1.11.0:]
    
        all:
          compiler: [gcc@11.0.0:]
          providers:
            mpi: [openmpi]
            blas: [openblas]
            lapack: [openblas]
    
      # Compiler configuration
      compilers:
      - compiler:
          spec: gcc@11.0.0
          paths:
            cc: /usr/bin/gcc
            cxx: /usr/bin/g++
            f77: /usr/bin/gfortran
            fc: /usr/bin/gfortran
          flags: {}
          operating_system: ubuntu22.04
          target: x86_64
          modules: []
          environment: {}
          extra_rpaths: []
    
      # View configuration
      view: true
      concretizer:
        unify: true
    
  5. Install the environment:

    spack install
    

IDE Setup

  1. Install VS Code:

    # For Debian/Ubuntu
    sudo apt-get install code
    # For other distributions, download from code.visualstudio.com
    
  2. Install extensions:

    code --install-extension ms-vscode.cpptools
    code --install-extension ms-vscode.cmake-tools
    code --install-extension twxs.cmake
    

Building METADA

  1. Build the project:

    cmake -S . -B build -G Ninja \
      -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_CXX_STANDARD=17 \
      -DCMAKE_PREFIX_PATH=$SPACK_ROOT/opt/spack/linux-ubuntu22.04-x86_64/gcc-12.2.0/ng-log-master
    cmake --build build
    

Running Tests

Execute the test suite:

cd build
ctest --output-on-failure

Troubleshooting

Common issues and solutions:

  • Spack environment issues: Verify environment activation

  • Build failures: Check compiler compatibility

  • Missing dependencies: Use spack spec metada to verify package resolution

  • ng-log issues: Ensure ng-log is properly installed and CMAKE_PREFIX_PATH includes its installation directory