From d4476435f597fe6e3c500e4a4fee8d8819dd403b Mon Sep 17 00:00:00 2001 From: Peter Eastman Date: Mon, 27 May 2024 09:26:16 -0700 Subject: [PATCH] Attempts at fixing CI (#144) * Try to fix CI on Linux * Don't install POCL on Mac * Don't install khronos-opencl-icd-loader * Update OpenMM version * Updated tested versions * Fixed version number * Install correct packages for CUDA 12 * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Try different method of installing CUDA * Try not installing CUDA packages from conda * Debugging * Debugging * Debugging * Debugging * Debugging * Don't build OpenCL on Mac * Don't try to run tests that can't run correctly * Update C++ version and minimum macOS version * Debugging * Debugging * Debugging * Debugging * Debugging * Debugging * Fixed working directory for tests * Fixes to testing * Try using PyTorch 2.3 * Try using PyTorch 2.2 * Switch back to PyTorch 2.1 --- .github/workflows/CI.yml | 43 ++++++++++++++-------- CMakeLists.txt | 2 +- devtools/conda-envs/build-macos-11.yml | 4 +- devtools/conda-envs/build-ubuntu-22.04.yml | 3 +- python/setup.py | 6 +-- python/tests/TestTorchForce.py | 8 ++-- serialization/tests/CMakeLists.txt | 2 +- 7 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f2bd6a44..ce130600 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,24 +22,13 @@ jobs: fail-fast: false matrix: include: - # Oldest supported versions - # NOTE: renable CUDA 10.2 when it supported by NNPOps (https://github.com/conda-forge/nnpops-feedstock/pull/8) - - name: Linux (CUDA 11.0, Python 3.7, PyTorch 1.11) - os: ubuntu-22.04 - cuda-version: "11.0.3" - gcc-version: "8.5.*" - nvcc-version: "11.0" - python-version: "3.7" - pytorch-version: "1.11.*" - - # Latest supported versions - - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.0) + - name: Linux (CUDA 11.8, Python 3.10, PyTorch 2.1) os: ubuntu-22.04 cuda-version: "11.8.0" gcc-version: "10.3.*" nvcc-version: "11.8" python-version: "3.10" - pytorch-version: "2.0.*" + pytorch-version: "2.1.*" - name: MacOS (Python 3.9, PyTorch 1.9) os: macos-11 @@ -55,12 +44,36 @@ jobs: uses: actions/checkout@v2 - name: "Install CUDA Toolkit on Linux (if needed)" - uses: Jimver/cuda-toolkit@v0.2.10 + uses: Jimver/cuda-toolkit@v0.2.15 with: cuda: ${{ matrix.cuda-version }} linux-local-args: '["--toolkit", "--override"]' if: startsWith(matrix.os, 'ubuntu') + - name: Manage disk space + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo mkdir -p /opt/empty_dir || true + for d in \ + /opt/ghc \ + /opt/hostedtoolcache \ + /usr/lib/jvm \ + /usr/local/.ghcup \ + /usr/local/lib/android \ + /usr/local/share/powershell \ + /usr/share/dotnet \ + /usr/share/swift \ + ; do + sudo rsync --stats -a --delete /opt/empty_dir/ $d || true + done + sudo apt-get purge -y -f firefox \ + google-chrome-stable \ + microsoft-edge-stable + sudo apt-get autoremove -y >& /dev/null + sudo apt-get autoclean -y >& /dev/null + sudo docker image prune --all --force + df -h + - name: "Install SDK on MacOS (if needed)" run: source devtools/scripts/install_macos_sdk.sh if: startsWith(matrix.os, 'macos') @@ -130,7 +143,7 @@ jobs: run: | export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib/python${{ matrix.python-version }}/site-packages/torch/lib:${LD_LIBRARY_PATH}" cd build - ctest --output-on-failure --exclude-regex TestCuda + ctest --output-on-failure --exclude-regex "TestCuda|TestOpenCL" - name: "Run Python test" shell: bash -l {0} diff --git a/CMakeLists.txt b/CMakeLists.txt index 8573ec30..d99ae2f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ SET(CMAKE_PREFIX_PATH "${PYTORCH_DIR}") FIND_PACKAGE(Torch REQUIRED) # Specify the C++ version we are building for. -SET (CMAKE_CXX_STANDARD 14) +SET (CMAKE_CXX_STANDARD 17) # Set flags for linking on mac IF(APPLE) diff --git a/devtools/conda-envs/build-macos-11.yml b/devtools/conda-envs/build-macos-11.yml index c02c224d..92c0c169 100644 --- a/devtools/conda-envs/build-macos-11.yml +++ b/devtools/conda-envs/build-macos-11.yml @@ -4,11 +4,9 @@ channels: dependencies: - cmake - compilers - - khronos-opencl-icd-loader - make - - openmm >=7.7 + - openmm >=8.1 - pip - - pocl - pytest - python - pytorch-cpu @PYTORCH_VERSION@ diff --git a/devtools/conda-envs/build-ubuntu-22.04.yml b/devtools/conda-envs/build-ubuntu-22.04.yml index ffd4d2f7..1cc25bbc 100644 --- a/devtools/conda-envs/build-ubuntu-22.04.yml +++ b/devtools/conda-envs/build-ubuntu-22.04.yml @@ -9,7 +9,7 @@ dependencies: - nnpops - nvcc_linux-64 @NVCC_VERSION@ - ocl-icd - - openmm >=7.7 + - openmm >=8.1 - pip - pocl - pytest @@ -18,3 +18,4 @@ dependencies: - swig - sysroot_linux-64 2.17 - torchani + - libxcrypt diff --git a/python/setup.py b/python/setup.py index 4d03efe2..8b7c8eae 100644 --- a/python/setup.py +++ b/python/setup.py @@ -9,12 +9,12 @@ torch_dir, _ = os.path.split('@TORCH_LIBRARY@') # setup extra compile and link arguments on Mac -extra_compile_args = ['-std=c++14'] +extra_compile_args = ['-std=c++17'] extra_link_args = [] if platform.system() == 'Darwin': - extra_compile_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] - extra_link_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7', '-Wl', '-rpath', openmm_dir+'/lib', '-rpath', torch_dir] + extra_compile_args += ['-stdlib=libc++', '-mmacosx-version-min=10.13'] + extra_link_args += ['-stdlib=libc++', '-mmacosx-version-min=10.13', '-Wl', '-rpath', openmm_dir+'/lib', '-rpath', torch_dir] extension = Extension(name='_openmmtorch', sources=['TorchPluginWrapper.cpp'], diff --git a/python/tests/TestTorchForce.py b/python/tests/TestTorchForce.py index ed358722..177551e7 100644 --- a/python/tests/TestTorchForce.py +++ b/python/tests/TestTorchForce.py @@ -21,7 +21,7 @@ def testConstructors(model_file): ('../../tests/forces.pt', True, False), ('../../tests/forces.pt', True, True)]) @pytest.mark.parametrize('use_cv_force', [True, False]) -@pytest.mark.parametrize('platform', ['Reference', 'CPU', 'CUDA', 'OpenCL']) +@pytest.mark.parametrize('platform', [mm.Platform.getPlatform(i).getName() for i in range(mm.Platform.getNumPlatforms())]) def testForce(model_file, output_forces, use_module_constructor, use_cv_force, platform): if pt.cuda.device_count() < 1 and platform == 'CUDA': @@ -54,8 +54,10 @@ def testForce(model_file, output_forces, use_module_constructor, use_cv_force, p # Compute the forces and energy. integ = mm.VerletIntegrator(1.0) - platform = mm.Platform.getPlatformByName(platform) - context = mm.Context(system, integ, platform) + try: + context = mm.Context(system, integ, mm.Platform.getPlatformByName(platform)) + except: + pytest.skip(f'Unable to create Context with {platform}') context.setPositions(positions) state = context.getState(getEnergy=True, getForces=True) diff --git a/serialization/tests/CMakeLists.txt b/serialization/tests/CMakeLists.txt index 50f5761f..10f79250 100644 --- a/serialization/tests/CMakeLists.txt +++ b/serialization/tests/CMakeLists.txt @@ -12,6 +12,6 @@ FOREACH(TEST_PROG ${TEST_PROGS}) ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_NN_TARGET}) SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_COMPILE_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") - ADD_TEST(${TEST_ROOT} ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT}) + ADD_TEST(NAME "${TEST_ROOT}" COMMAND "${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") ENDFOREACH(TEST_PROG ${TEST_PROGS})