From 83b07c9966e5fee147ab83ffca734a5b6da13d5a Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 08:22:46 -0400 Subject: [PATCH 01/10] Add OSX support --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++-- src/pytorch/__init__.py | 10 ++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 760f69bd..2ccc82c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,8 @@ defaults: jobs: build: + runs-on: ${{ matrix.os }} name: ${{ matrix.name }} - runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -24,6 +24,7 @@ jobs: # Oldest supported versions - name: Linux (CUDA 10.2, Python 3.8, PyTorch 1.11) + os: ubuntu-18.04 enable_cuda: true cuda: "10.2.89" gcc: "8.5.*" @@ -34,6 +35,7 @@ jobs: # Older supported versions - name: Linux (CUDA 11.2, Python 3.9, PyTorch 1.12) + os: ubuntu-18.04 enable_cuda: true cuda: "11.2.2" gcc: "10.3.*" @@ -44,6 +46,7 @@ jobs: # Latest supported versions (with CUDA) - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) + os: ubuntu-18.04 enable_cuda: true cuda: "11.8.0" gcc: "10.3.*" @@ -54,12 +57,20 @@ jobs: # Latest supported versions (without CUDA) - name: Linux (no CUDA, Python 3.10, PyTorch 2.0) + os: ubuntu-18.04 enable_cuda: false gcc: "10.3.*" python: "3.10.*" pytorch: "2.0.*" torchani: "2.2.*" + # Intel Mac + - name: Mac Intel (no CUDA, Python 3.10, PyTorch 2.0) + os: macos-latest + enable_cuda: false + python: "3.10" + pytorch: "2.0.*" + steps: - name: Check out uses: actions/checkout@v2 @@ -90,7 +101,7 @@ jobs: environment.yml - name: Prepare dependencies (without CUDA) - if: ${{ !matrix.enable_cuda }} + if: ${{ contains(matrix.os, 'ubuntu') && !matrix.enable_cuda }} run: | sed -i -e "/cudatoolkit/c\ # - cudatoolkit" \ -e "/gxx_linux-64/c\ - gxx_linux-64 ${{ matrix.gcc }}" \ @@ -100,6 +111,16 @@ jobs: -e "/pytorch-gpu/c\ - pytorch-cpu ${{ matrix.pytorch }}" \ environment.yml + - name: Prepare dependencies (Mac) + if: ${{ contains(matrix.os, 'macos') }} + run: | + sed -i '' -e "s/- cudatoolkit/# - cudatoolkit/" \ + -e "s/- gxx_linux-64/# - gxx_linux-64/" \ + -e "s/- nvcc_linux-64/# - nvcc_linux-64/" \ + -e "s/- sysroot_linux-64/# - sysroot_linux-64/" \ + -e "s/- python/- python ${{ matrix.python }}.*/" \ + -e "s/- pytorch-gpu/- pytorch-cpu ${{ matrix.pytorch }}/" \ + environment.yml - name: Show dependency file run: cat environment.yml diff --git a/src/pytorch/__init__.py b/src/pytorch/__init__.py index 645d4399..972f64c3 100644 --- a/src/pytorch/__init__.py +++ b/src/pytorch/__init__.py @@ -2,9 +2,15 @@ High-performance PyTorch operations for neural network potentials ''' import os.path -import torch +import sys +import torch.utils.cpp_extension -torch.ops.load_library(os.path.join(os.path.dirname(__file__), 'libNNPOpsPyTorch.so')) +_LIBRARY_NAME = f'NNPOpsPyTorch.{torch.utils.cpp_extension}' + +if not sys.platform.lower().startswith("win"): + _LIBRARY_NAME = f'lib{_LIBRARY_NAME}' + +torch.ops.load_library(os.path.join(os.path.dirname(__file__), _LIBRARY_NAME)) from NNPOps.OptimizedTorchANI import OptimizedTorchANI From 7cf0c810b9c4f494f9493067ebf9a43531bc6ebe Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 08:23:44 -0400 Subject: [PATCH 02/10] Test only OSX for now --- .github/workflows/ci.yml | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ccc82c8..87255d9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,46 +23,46 @@ jobs: include: # Oldest supported versions - - name: Linux (CUDA 10.2, Python 3.8, PyTorch 1.11) - os: ubuntu-18.04 - enable_cuda: true - cuda: "10.2.89" - gcc: "8.5.*" - nvcc: "10.2" - python: "3.8.*" - torchani: "2.2.*" - pytorch: "1.11.*" - - # Older supported versions - - name: Linux (CUDA 11.2, Python 3.9, PyTorch 1.12) - os: ubuntu-18.04 - enable_cuda: true - cuda: "11.2.2" - gcc: "10.3.*" - nvcc: "11.2" - python: "3.9.*" - torchani: "2.2.*" - pytorch: "1.12.*" - - # Latest supported versions (with CUDA) - - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) - os: ubuntu-18.04 - enable_cuda: true - cuda: "11.8.0" - gcc: "10.3.*" - nvcc: "11.8" - python: "3.10.*" - torchani: "2.2.*" - pytorch: "2.0.*" - - # Latest supported versions (without CUDA) - - name: Linux (no CUDA, Python 3.10, PyTorch 2.0) - os: ubuntu-18.04 - enable_cuda: false - gcc: "10.3.*" - python: "3.10.*" - pytorch: "2.0.*" - torchani: "2.2.*" +# - name: Linux (CUDA 10.2, Python 3.8, PyTorch 1.11) +# os: ubuntu-18.04 +# enable_cuda: true +# cuda: "10.2.89" +# gcc: "8.5.*" +# nvcc: "10.2" +# python: "3.8.*" +# torchani: "2.2.*" +# pytorch: "1.11.*" +# +# # Older supported versions +# - name: Linux (CUDA 11.2, Python 3.9, PyTorch 1.12) +# os: ubuntu-18.04 +# enable_cuda: true +# cuda: "11.2.2" +# gcc: "10.3.*" +# nvcc: "11.2" +# python: "3.9.*" +# torchani: "2.2.*" +# pytorch: "1.12.*" +# +# # Latest supported versions (with CUDA) +# - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) +# os: ubuntu-18.04 +# enable_cuda: true +# cuda: "11.8.0" +# gcc: "10.3.*" +# nvcc: "11.8" +# python: "3.10.*" +# torchani: "2.2.*" +# pytorch: "2.0.*" +# +# # Latest supported versions (without CUDA) +# - name: Linux (no CUDA, Python 3.10, PyTorch 2.0) +# os: ubuntu-18.04 +# enable_cuda: false +# gcc: "10.3.*" +# python: "3.10.*" +# pytorch: "2.0.*" +# torchani: "2.2.*" # Intel Mac - name: Mac Intel (no CUDA, Python 3.10, PyTorch 2.0) From 48346a14271fcc65c4b3ab34d5a6f7dea952bd0c Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 08:28:19 -0400 Subject: [PATCH 03/10] Fix OSX dep replacement --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87255d9c..1997a5da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,8 +118,8 @@ jobs: -e "s/- gxx_linux-64/# - gxx_linux-64/" \ -e "s/- nvcc_linux-64/# - nvcc_linux-64/" \ -e "s/- sysroot_linux-64/# - sysroot_linux-64/" \ - -e "s/- python/- python ${{ matrix.python }}.*/" \ - -e "s/- pytorch-gpu/- pytorch-cpu ${{ matrix.pytorch }}/" \ + -e "s/- python 3.10.\*/- python ${{ matrix.python }}.*/" \ + -e "s/- pytorch-gpu 2.0.\*/- pytorch-cpu ${{ matrix.pytorch }}/" \ environment.yml - name: Show dependency file run: cat environment.yml From 56b06a575939ee148f2e7cddac5c5b36dadf409b Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 08:42:16 -0400 Subject: [PATCH 04/10] Clean-up extension detection --- src/pytorch/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pytorch/__init__.py b/src/pytorch/__init__.py index 972f64c3..077b4204 100644 --- a/src/pytorch/__init__.py +++ b/src/pytorch/__init__.py @@ -2,13 +2,11 @@ High-performance PyTorch operations for neural network potentials ''' import os.path -import sys -import torch.utils.cpp_extension +import torch +from torch.utils.cpp_extension import CLIB_PREFIX, IS_MACOS, LIB_EXT -_LIBRARY_NAME = f'NNPOpsPyTorch.{torch.utils.cpp_extension}' - -if not sys.platform.lower().startswith("win"): - _LIBRARY_NAME = f'lib{_LIBRARY_NAME}' +_LIBRARY_EXT = LIB_EXT if not IS_MACOS else ".dylib" +_LIBRARY_NAME = f'{CLIB_PREFIX}NNPOpsPyTorch{_LIBRARY_EXT}' torch.ops.load_library(os.path.join(os.path.dirname(__file__), _LIBRARY_NAME)) From 675754c82e0c0fac9c917fd7786790acfa1c43e6 Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 08:44:04 -0400 Subject: [PATCH 05/10] Clean-up prefix --- src/pytorch/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pytorch/__init__.py b/src/pytorch/__init__.py index 077b4204..66cc421d 100644 --- a/src/pytorch/__init__.py +++ b/src/pytorch/__init__.py @@ -3,10 +3,12 @@ ''' import os.path import torch -from torch.utils.cpp_extension import CLIB_PREFIX, IS_MACOS, LIB_EXT +from torch.utils.cpp_extension import IS_WINDOWS, IS_MACOS, LIB_EXT -_LIBRARY_EXT = LIB_EXT if not IS_MACOS else ".dylib" -_LIBRARY_NAME = f'{CLIB_PREFIX}NNPOpsPyTorch{_LIBRARY_EXT}' +# by default torch assumes OSX has a .so ext, so we need to override +_LIBRARY_SUFFIX = LIB_EXT if not IS_MACOS else ".dylib" +_LIBRARY_PREFIX = '' if IS_WINDOWS else "lib" +_LIBRARY_NAME = f'{_LIBRARY_PREFIX}NNPOpsPyTorch{_LIBRARY_SUFFIX}' torch.ops.load_library(os.path.join(os.path.dirname(__file__), _LIBRARY_NAME)) From 8b8ae54207187bd41bb643d1a0734b480587fd17 Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 08:52:23 -0400 Subject: [PATCH 06/10] Re-enable CI --- .github/workflows/ci.yml | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1997a5da..59260f76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,46 +23,46 @@ jobs: include: # Oldest supported versions -# - name: Linux (CUDA 10.2, Python 3.8, PyTorch 1.11) -# os: ubuntu-18.04 -# enable_cuda: true -# cuda: "10.2.89" -# gcc: "8.5.*" -# nvcc: "10.2" -# python: "3.8.*" -# torchani: "2.2.*" -# pytorch: "1.11.*" -# -# # Older supported versions -# - name: Linux (CUDA 11.2, Python 3.9, PyTorch 1.12) -# os: ubuntu-18.04 -# enable_cuda: true -# cuda: "11.2.2" -# gcc: "10.3.*" -# nvcc: "11.2" -# python: "3.9.*" -# torchani: "2.2.*" -# pytorch: "1.12.*" -# -# # Latest supported versions (with CUDA) -# - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) -# os: ubuntu-18.04 -# enable_cuda: true -# cuda: "11.8.0" -# gcc: "10.3.*" -# nvcc: "11.8" -# python: "3.10.*" -# torchani: "2.2.*" -# pytorch: "2.0.*" -# -# # Latest supported versions (without CUDA) -# - name: Linux (no CUDA, Python 3.10, PyTorch 2.0) -# os: ubuntu-18.04 -# enable_cuda: false -# gcc: "10.3.*" -# python: "3.10.*" -# pytorch: "2.0.*" -# torchani: "2.2.*" + - name: Linux (CUDA 10.2, Python 3.8, PyTorch 1.11) + os: ubuntu-18.04 + enable_cuda: true + cuda: "10.2.89" + gcc: "8.5.*" + nvcc: "10.2" + python: "3.8.*" + torchani: "2.2.*" + pytorch: "1.11.*" + + # Older supported versions + - name: Linux (CUDA 11.2, Python 3.9, PyTorch 1.12) + os: ubuntu-18.04 + enable_cuda: true + cuda: "11.2.2" + gcc: "10.3.*" + nvcc: "11.2" + python: "3.9.*" + torchani: "2.2.*" + pytorch: "1.12.*" + + # Latest supported versions (with CUDA) + - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) + os: ubuntu-18.04 + enable_cuda: true + cuda: "11.8.0" + gcc: "10.3.*" + nvcc: "11.8" + python: "3.10.*" + torchani: "2.2.*" + pytorch: "2.0.*" + + # Latest supported versions (without CUDA) + - name: Linux (no CUDA, Python 3.10, PyTorch 2.0) + os: ubuntu-18.04 + enable_cuda: false + gcc: "10.3.*" + python: "3.10.*" + pytorch: "2.0.*" + torchani: "2.2.*" # Intel Mac - name: Mac Intel (no CUDA, Python 3.10, PyTorch 2.0) From 5b4051a98725febd31bb0a6ec822bf973561b93a Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 09:22:53 -0400 Subject: [PATCH 07/10] Fix ubuntu version --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59260f76..bbfaff54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: # Oldest supported versions - name: Linux (CUDA 10.2, Python 3.8, PyTorch 1.11) - os: ubuntu-18.04 + os: ubuntu-22.04 enable_cuda: true cuda: "10.2.89" gcc: "8.5.*" @@ -35,7 +35,7 @@ jobs: # Older supported versions - name: Linux (CUDA 11.2, Python 3.9, PyTorch 1.12) - os: ubuntu-18.04 + os: ubuntu-22.04 enable_cuda: true cuda: "11.2.2" gcc: "10.3.*" @@ -46,7 +46,7 @@ jobs: # Latest supported versions (with CUDA) - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) - os: ubuntu-18.04 + os: ubuntu-22.04 enable_cuda: true cuda: "11.8.0" gcc: "10.3.*" @@ -57,7 +57,7 @@ jobs: # Latest supported versions (without CUDA) - name: Linux (no CUDA, Python 3.10, PyTorch 2.0) - os: ubuntu-18.04 + os: ubuntu-22.04 enable_cuda: false gcc: "10.3.*" python: "3.10.*" From 4014ff4a2088f666a19e77fdba6d3fdff36a709e Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Sat, 14 Oct 2023 14:00:01 -0400 Subject: [PATCH 08/10] delete rather than comment linux deps in env --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbfaff54..9d1de6ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,13 +114,14 @@ jobs: - name: Prepare dependencies (Mac) if: ${{ contains(matrix.os, 'macos') }} run: | - sed -i '' -e "s/- cudatoolkit/# - cudatoolkit/" \ - -e "s/- gxx_linux-64/# - gxx_linux-64/" \ - -e "s/- nvcc_linux-64/# - nvcc_linux-64/" \ - -e "s/- sysroot_linux-64/# - sysroot_linux-64/" \ + sed -i '' -e "/- cudatoolkit/d" \ + -e "/- gxx_linux-64/d" \ + -e "/- nvcc_linux-64/d" \ + -e "/- sysroot_linux-64/d" \ -e "s/- python 3.10.\*/- python ${{ matrix.python }}.*/" \ -e "s/- pytorch-gpu 2.0.\*/- pytorch-cpu ${{ matrix.pytorch }}/" \ environment.yml + - name: Show dependency file run: cat environment.yml From 1794c6ec7cbc6fac096dafa4698d6cdb2768c90f Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Thu, 19 Oct 2023 07:32:09 -0400 Subject: [PATCH 09/10] use conda compilers on OSX --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d1de6ab..15f557fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,6 +121,8 @@ jobs: -e "s/- python 3.10.\*/- python ${{ matrix.python }}.*/" \ -e "s/- pytorch-gpu 2.0.\*/- pytorch-cpu ${{ matrix.pytorch }}/" \ environment.yml + + echo "- compilers" >> environment.yml - name: Show dependency file run: cat environment.yml From 1665755e7ec34725ce2808950e7c024ed067145d Mon Sep 17 00:00:00 2001 From: SimonBoothroyd Date: Thu, 19 Oct 2023 07:33:19 -0400 Subject: [PATCH 10/10] fix missing space --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15f557fc..188cae81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: -e "s/- pytorch-gpu 2.0.\*/- pytorch-cpu ${{ matrix.pytorch }}/" \ environment.yml - echo "- compilers" >> environment.yml + echo " - compilers" >> environment.yml - name: Show dependency file run: cat environment.yml