Update example 5 to fix mismatching TorchScript and executable names. #47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workflow to run the FTorch test suite on a CUDA enabled runner | |
| name: Test suite (Ubuntu CUDA) | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on pushes to the "main" branch, i.e., PR merges | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - '.github/workflows/test_suite_ubuntu_cuda.yml' | |
| # Library source files | |
| - 'src/*.fypp' | |
| - 'src/*.f90' | |
| - 'src/*.F90' | |
| - 'src/*.c' | |
| - 'src/*.cpp' | |
| - 'src/*.h' | |
| # Unit tests | |
| - 'test/unit/*.pf' | |
| # Integration tests | |
| - 'examples/**/*.py' | |
| - 'examples/**/*.f90' | |
| # Build system | |
| - '**CMakeLists.txt' | |
| - '**requirements.txt' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/test_suite_ubuntu_cuda.yml' | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Cancel jobs running if new commits are pushed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| # Write permissions are not required | |
| permissions: {} | |
| # Workflow run - one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| test-suite-ubuntu-cuda: | |
| # The type of runner that the job will run on | |
| runs-on: GPU-runner | |
| strategy: | |
| fail-fast: true | |
| # Terminate the job if it runs for more than 15 minutes | |
| timeout-minutes: 15 | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - name: Checkout code | |
| with: | |
| persist-credentials: false | |
| uses: actions/checkout@v4 | |
| - name: Install Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' # Use 3.13 as no PyTorch wheels for 3.14 yet. | |
| - name: Install PyTorch | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m venv ftorch | |
| . ftorch/bin/activate | |
| # CUDA v12.9 chosen as latest supported by PyTorch | |
| # Check this is <= what GPU-runner has installed (backwards compatible) | |
| pip install torch torchvision --index-url https://download.pytorch.org/whl/cu129 | |
| - name: Install cmake and NVIDIA dev toolkit | |
| run: | | |
| sudo apt update | |
| sudo apt install -y cmake nvidia-cuda-toolkit | |
| # Currently used by example7_mpi | |
| - name: Install an MPI distribution | |
| run: | | |
| sudo apt install -y openmpi-bin openmpi-common libopenmpi-dev | |
| - name: Install pFUnit | |
| run: | | |
| export FC=/usr/bin/gfortran | |
| # TODO: Avoid version pinning (needed because version appears in install path) | |
| git clone -b v4.12.0 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git | |
| mkdir pFUnit/build | |
| cd pFUnit/build | |
| # MPI support is currently not needed for the unit testing | |
| cmake .. -DSKIP_MPI=YES | |
| make -j 4 install | |
| - name: Build FTorch | |
| run: | | |
| . ftorch/bin/activate | |
| VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))") | |
| export Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages | |
| export BUILD_DIR=$(pwd)/build | |
| # NOTE: The pFUnit version (pinned during installation above) is used in the install path. | |
| export PFUNIT_DIR=$(pwd)/pFUnit/build/installed/PFUNIT-4.12 | |
| mkdir ${BUILD_DIR} | |
| cd ${BUILD_DIR} | |
| cmake .. \ | |
| -DPython_EXECUTABLE="$(which python)" \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \ | |
| -DCMAKE_BUILD_TESTS=TRUE \ | |
| -DGPU_DEVICE=CUDA \ | |
| -DMULTI_GPU=OFF \ | |
| -DCMAKE_PREFIX_PATH="${PFUNIT_DIR};${Torch_DIR}" \ | |
| -DCMAKE_Fortran_FLAGS="-std=f2008" | |
| cmake --build . | |
| cmake --install . | |
| - name: Run unit tests | |
| run: | | |
| . ftorch/bin/activate | |
| cd build | |
| ctest --verbose --tests-regex unit | |
| - name: Run integration tests | |
| run: | | |
| . ftorch/bin/activate | |
| cd build | |
| ctest --verbose --tests-regex example |