Skip to content

Commit 24a6f7e

Browse files
author
Raimondas Galvelis
authored
Merge pull request #34 from raimis/ci
CI for NNPOps
2 parents 44e4282 + eb5d7eb commit 24a6f7e

File tree

6 files changed

+86
-5
lines changed

6 files changed

+86
-5
lines changed

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-18.04
12+
strategy:
13+
matrix:
14+
include:
15+
- cuda: 10.2.89
16+
gcc: 8.5.0
17+
nvcc: 10.2
18+
python: 3.8
19+
pytorch: 1.7.1
20+
- cuda: 11.2.2
21+
gcc: 10.3.0
22+
nvcc: 11.2
23+
python: 3.9
24+
pytorch: 1.8.0 # Cannot test with PyTorch 1.9, because of https://github.com/aiqm/torchani/issues/598
25+
26+
steps:
27+
- name: Check out
28+
uses: actions/checkout@v2
29+
30+
- name: Install CUDA Toolkit
31+
uses: Jimver/cuda-toolkit@v0.2.4
32+
with:
33+
cuda: ${{ matrix.cuda }}
34+
35+
- name: Install Miniconda
36+
uses: conda-incubator/setup-miniconda@v2
37+
with:
38+
activate-environment: ""
39+
auto-activate-base: true
40+
miniforge-variant: Miniforge3
41+
42+
- name: Install dependencies
43+
shell: bash -l {0}
44+
run: |
45+
sed -i -e "/cudatoolkit/c\ - cudatoolkit ${{ matrix.cuda }}" \
46+
-e "/gxx_linux-64/c\ - gxx_linux-64 ${{ matrix.gcc }}" \
47+
-e "/nvcc_linux-64/c\ - nvcc_linux-64 ${{ matrix.nvcc }}" \
48+
-e "/python/c\ - python ${{ matrix.python }}" \
49+
-e "/pytorch-gpu/c\ - pytorch-gpu ${{ matrix.pytorch }}" \
50+
environment.yml
51+
conda env create -n nnpops -f environment.yml
52+
53+
- name: Configure, compile, and install
54+
shell: bash -l {0}
55+
run: |
56+
conda activate nnpops
57+
mkdir build && cd build
58+
cmake .. \
59+
-DTorch_DIR=$CONDA_PREFIX/lib/python${{ matrix.python }}/site-packages/torch/share/cmake/Torch \
60+
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
61+
make install
62+
63+
- name: Test
64+
shell: bash -l {0}
65+
run: |
66+
conda activate nnpops
67+
cd build
68+
ctest --verbose --exclude-regex TestCuda

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ foreach(TEST_PATH ${TEST_PATHS})
2929
add_test(${TEST_NAME} ${TEST_NAME})
3030
endforeach()
3131

32-
add_test(TestSymmetryFunctions pytest ${CMAKE_SOURCE_DIR}/src/pytorch/TestSymmetryFunctions.py)
33-
add_test(TestBatchedNN pytest ${CMAKE_SOURCE_DIR}/src/pytorch/TestBatchedNN.py)
32+
add_test(TestBatchedNN pytest -v ${CMAKE_SOURCE_DIR}/src/pytorch/TestBatchedNN.py)
33+
add_test(TestSymmetryFunctions pytest -v ${CMAKE_SOURCE_DIR}/src/pytorch/TestSymmetryFunctions.py)
3434

3535
install(TARGETS ${LIBRARY} DESTINATION ${Python_SITEARCH}/${NAME})
3636
install(FILES src/pytorch/__init__.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $ make install
5959

6060
- Run the tests
6161
```bash
62-
$ ctest
62+
$ ctest --verbose
6363
```
6464

6565
## Usage

environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ channels:
22
- conda-forge
33
dependencies:
44
- cmake
5-
- gxx_linux-64 <=10
5+
- cudatoolkit 11.2.2
6+
- gxx_linux-64 10.3.0
67
- make
78
- mdtraj
8-
- nvcc_linux-64
9+
- nvcc_linux-64 11.2
910
- torchani 2.2
1011
- pytest
1112
- python 3.9

src/pytorch/TestBatchedNN.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test_import():
3838
@pytest.mark.parametrize('molFile', ['1hvj', '1hvk', '2iuz', '3hkw', '3hky', '3lka', '3o99'])
3939
def test_compare_with_native(deviceString, molFile):
4040

41+
if deviceString == 'cuda' and not torch.cuda.is_available():
42+
pytest.skip('CUDA is not available')
43+
4144
from NNPOps.BatchedNN import TorchANIBatchedNN
4245

4346
device = torch.device(deviceString)
@@ -70,6 +73,9 @@ def test_compare_with_native(deviceString, molFile):
7073
@pytest.mark.parametrize('molFile', ['1hvj', '1hvk', '2iuz', '3hkw', '3hky', '3lka', '3o99'])
7174
def test_model_serialization(deviceString, molFile):
7275

76+
if deviceString == 'cuda' and not torch.cuda.is_available():
77+
pytest.skip('CUDA is not available')
78+
7379
from NNPOps.BatchedNN import TorchANIBatchedNN
7480

7581
device = torch.device(deviceString)

src/pytorch/TestSymmetryFunctions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test_import():
3838
@pytest.mark.parametrize('molFile', ['1hvj', '1hvk', '2iuz', '3hkw', '3hky', '3lka', '3o99'])
3939
def test_compare_with_native(deviceString, molFile):
4040

41+
if deviceString == 'cuda' and not torch.cuda.is_available():
42+
pytest.skip('CUDA is not available')
43+
4144
from NNPOps.SymmetryFunctions import TorchANISymmetryFunctions
4245

4346
device = torch.device(deviceString)
@@ -70,6 +73,9 @@ def test_compare_with_native(deviceString, molFile):
7073
@pytest.mark.parametrize('molFile', ['1hvj', '1hvk', '2iuz', '3hkw', '3hky', '3lka', '3o99'])
7174
def test_model_serialization(deviceString, molFile):
7275

76+
if deviceString == 'cuda' and not torch.cuda.is_available():
77+
pytest.skip('CUDA is not available')
78+
7379
from NNPOps.SymmetryFunctions import TorchANISymmetryFunctions
7480

7581
device = torch.device(deviceString)

0 commit comments

Comments
 (0)