From 123fed90eaae14bba417fe6772a5f74cd39b7f13 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Wed, 5 Jun 2024 11:56:56 +0200 Subject: [PATCH 1/3] Make ftorch a required package for CMake in all examples. --- examples/1_SimpleNet/CMakeLists.txt | 2 +- examples/2_ResNet18/CMakeLists.txt | 2 +- examples/3_MultiGPU/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/1_SimpleNet/CMakeLists.txt b/examples/1_SimpleNet/CMakeLists.txt index 0a7af4b0..bdbc9085 100644 --- a/examples/1_SimpleNet/CMakeLists.txt +++ b/examples/1_SimpleNet/CMakeLists.txt @@ -11,7 +11,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) endif() -find_package(FTorch) +find_package(FTorch REQUIRED) message(STATUS "Building with Fortran PyTorch coupling") # Fortran example diff --git a/examples/2_ResNet18/CMakeLists.txt b/examples/2_ResNet18/CMakeLists.txt index 9148cb57..a1da18cf 100644 --- a/examples/2_ResNet18/CMakeLists.txt +++ b/examples/2_ResNet18/CMakeLists.txt @@ -11,7 +11,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) endif() -find_package(FTorch) +find_package(FTorch REQUIRED) message(STATUS "Building with Fortran PyTorch coupling") # Fortran example diff --git a/examples/3_MultiGPU/CMakeLists.txt b/examples/3_MultiGPU/CMakeLists.txt index 5ae80636..5a3cab8a 100644 --- a/examples/3_MultiGPU/CMakeLists.txt +++ b/examples/3_MultiGPU/CMakeLists.txt @@ -11,7 +11,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) endif() -find_package(FTorch) +find_package(FTorch REQUIRED) find_package(MPI REQUIRED) message(STATUS "Building with Fortran PyTorch coupling") From f49734c01c9a5cf4a10ca5cb12ea535e60af10da Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Wed, 5 Jun 2024 12:03:08 +0200 Subject: [PATCH 2/3] Update coupling guidance in online docs to make FTorch REQUIRED when coupling in CMake. --- pages/cmake.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/cmake.md b/pages/cmake.md index 6fb0b7ef..0e9b438c 100644 --- a/pages/cmake.md +++ b/pages/cmake.md @@ -112,7 +112,7 @@ If doing this you need to include the following in the `CMakeLists.txt` file to find the FTorch installation and link it to the executable. ```CMake -find_package(FTorch) +find_package(FTorch REQUIRED) target_link_libraries( PRIVATE FTorch::ftorch ) message(STATUS "Building with Fortran PyTorch coupling") ``` From 697671103178c3c39f24f8308e5054c81ac78ae8 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Wed, 5 Jun 2024 12:11:54 +0200 Subject: [PATCH 3/3] Update testing workflow to add torch location to prefix path. --- .github/workflows/test_suite.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml index acb41286..da4b57b8 100644 --- a/.github/workflows/test_suite.yml +++ b/.github/workflows/test_suite.yml @@ -41,11 +41,13 @@ jobs: 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 Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages/torch export BUILD_DIR=$(pwd)/src/build mkdir ${BUILD_DIR} cd ${BUILD_DIR} - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_BUILD_TESTS=TRUE + echo Building in ${BUILD_DIR} + echo Torch in ${Torch_DIR} + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_BUILD_TESTS=TRUE -DCMAKE_PREFIX_PATH=${Torch_DIR} cmake --build . cmake --install .