diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 760f69b..188cae8 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-22.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-22.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-22.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-22.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,19 @@ jobs: -e "/pytorch-gpu/c\ - pytorch-cpu ${{ matrix.pytorch }}" \ environment.yml + - name: Prepare dependencies (Mac) + if: ${{ contains(matrix.os, 'macos') }} + run: | + 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 + + echo " - compilers" >> environment.yml + - name: Show dependency file run: cat environment.yml diff --git a/src/pytorch/__init__.py b/src/pytorch/__init__.py index 645d439..66cc421 100644 --- a/src/pytorch/__init__.py +++ b/src/pytorch/__init__.py @@ -3,8 +3,14 @@ ''' import os.path import torch +from torch.utils.cpp_extension import IS_WINDOWS, IS_MACOS, LIB_EXT -torch.ops.load_library(os.path.join(os.path.dirname(__file__), 'libNNPOpsPyTorch.so')) +# 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 NNPOps.OptimizedTorchANI import OptimizedTorchANI