diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a21e0652..8b0f5019 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,8 @@ jobs: matrix: include: - name: Linux (CUDA 13.0, Python 3.14, PyTorch 2.12) - os: ubuntu-22.04 + os: ubuntu-24.04 + env: ubuntu-24.04 cuda-version: "13.0" gcc-version: "10.3.*" nvcc-version: "13.0" @@ -31,22 +32,26 @@ jobs: pytorch-version: "2.12.*" opencl: true - - name: MacOS ARM (Python 3.11, PyTorch 2.4) - os: macos-latest + - name: Linux (HIP, Python 3.14, PyTorch 2.12) + os: ubuntu-24.04 + env: ubuntu-24.04-hip cuda-version: "" - gcc-version: "" + hip-version: "7" + gcc-version: "10.3.*" nvcc-version: "" - python-version: "3.11" - pytorch-version: "2.4.*" + python-version: "3.14" + pytorch-version: "2.12.*" opencl: false - - name: MacOS Intel (Python 3.13, PyTorch 2.5) - os: macos-15-intel + - name: MacOS ARM (Python 3.11, PyTorch 2.4) + os: macos-latest + env: macos-latest cuda-version: "" + hip-version: "" gcc-version: "" nvcc-version: "" - python-version: "3.13" - pytorch-version: "2.5.*" + python-version: "3.11" + pytorch-version: "2.4.*" opencl: false @@ -60,7 +65,7 @@ jobs: with: cuda: ${{ matrix.cuda-version }}.0 linux-local-args: '["--toolkit", "--override"]' - if: startsWith(matrix.os, 'ubuntu') + if: matrix.cuda-version != '' - name: "Install OpenCL on Ubuntu (if needed)" if: matrix.opencl == true @@ -70,6 +75,14 @@ jobs: if: startsWith(matrix.os, 'ubuntu') uses: jlumbroso/free-disk-space@main + - name: "Install HIP 7 on Linux (if needed)" + if: matrix.hip-version == '7' + run: | + wget https://repo.radeon.com/amdgpu-install/7.2.4/ubuntu/noble/amdgpu-install_7.2.4.70204-1_all.deb + sudo apt install ./amdgpu-install_7.2.4.70204-1_all.deb + sudo apt update + sudo apt install rocm + - name: "Install SDK on MacOS (if needed)" run: source devtools/scripts/install_macos_sdk.sh if: startsWith(matrix.os, 'macos') @@ -79,7 +92,7 @@ jobs: with: tokenPrefix: '@' tokenSuffix: '@' - files: devtools/conda-envs/build-${{ matrix.os }}.yml + files: devtools/conda-envs/build-${{ matrix.env }}.yml env: CUDATOOLKIT_VERSION: ${{ matrix.cuda-version }} GCC_VERSION: ${{ matrix.gcc-version }} @@ -90,7 +103,7 @@ jobs: name: "Install dependencies with Mamba" with: activate-environment: build - environment-file: devtools/conda-envs/build-${{ matrix.os }}.yml + environment-file: devtools/conda-envs/build-${{ matrix.env }}.yml miniforge-variant: Miniforge3 use-mamba: true python-version: ${{ matrix.python-version }} @@ -107,17 +120,20 @@ jobs: run: | mkdir build cd build - SHLIB_EXT=".so" if [[ ${{ matrix.os }} == macos-* ]]; then SHLIB_EXT=".dylib" fi - + if [[ ${{ matrix.env }} == *hip ]]; then + export PYTORCH_ROCM_ARCH=gfx1201 + export CXX=hipcc + fi + export SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])') cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \ - -DOPENMM_DIR=${CONDA_PREFIX} \ - -DTorch_DIR=${CONDA_PREFIX}/lib/python${{ matrix.python-version }}/site-packages/torch/share/cmake/Torch \ + -DCMAKE_INSTALL_PREFIX=${SITE_PACKAGES}/OpenMM.libs \ + -DOPENMM_DIR=${SITE_PACKAGES}/OpenMM.libs \ + -DTorch_DIR=${SITE_PACKAGES}/torch/share/cmake/Torch \ -DNN_BUILD_OPENCL_LIB=ON \ -DCUDAToolkit_ROOT="${{steps.cuda-toolkit.outputs.CUDA_PATH}}" \ -DCMAKE_CUDA_COMPILER="${{steps.cuda-toolkit.outputs.CUDA_PATH}}/bin/nvcc" @@ -132,23 +148,26 @@ jobs: - name: "List plugins" shell: bash -l {0} run: | - export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib/python${{ matrix.python-version }}/site-packages/torch/lib:${LD_LIBRARY_PATH}" + export SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])') + export LD_LIBRARY_PATH="${SITE_PACKAGES}/torch/lib:${SITE_PACKAGES}/OpenMM.libs/lib:${LD_LIBRARY_PATH}" python -c "import openmm as mm; print('---Loaded---', *mm.pluginLoadedLibNames, '---Failed---', *mm.Platform.getPluginLoadFailures(), sep='\n')" - name: "Run C++ test" shell: bash -l {0} run: | - export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib/python${{ matrix.python-version }}/site-packages/torch/lib:${LD_LIBRARY_PATH}" + export SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])') + export LD_LIBRARY_PATH="${SITE_PACKAGES}/torch/lib:${SITE_PACKAGES}/OpenMM.libs/lib:${LD_LIBRARY_PATH}" cd build if [[ ${{ matrix.opencl }} == true ]]; then source /opt/intel/oneapi/setvars.sh fi - ctest --output-on-failure --exclude-regex "TestCuda|TestOpenCL" + ctest --output-on-failure --exclude-regex "TestCuda|TestOpenCL|TestHip" - name: "Run Python test" shell: bash -l {0} run: | - export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib/python${{ matrix.python-version }}/site-packages/torch/lib:${LD_LIBRARY_PATH}" + export SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])') + export LD_LIBRARY_PATH="${SITE_PACKAGES}/torch/lib:${SITE_PACKAGES}/OpenMM.libs/lib:${LD_LIBRARY_PATH}" cd python/tests if [[ ${{ matrix.opencl }} == true ]]; then source /opt/intel/oneapi/setvars.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e06a866..f29fc301 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,8 @@ # The version number is set here and copied to anywhere it is needed. SET(OPENMM_TORCH_VERSION 1.5 CACHE STRING "The version of OpenMM-Torch that will be built." FORCE) -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 3.31) +PROJECT(OpenMM-Torch) # We need to know where OpenMM is installed so we can access the headers and libraries. SET(OPENMM_DIR "/usr/local/openmm" CACHE PATH "Where OpenMM is installed") @@ -129,7 +130,7 @@ add_custom_target(CopyTestFiles ALL DEPENDS ${COPIED_TEST_FILES}) ADD_SUBDIRECTORY(platforms/reference) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") -FIND_PACKAGE(OpenCL QUIET) +FIND_PACKAGE(OPENCL QUIET) IF(OPENCL_FOUND) SET(NN_BUILD_OPENCL_LIB ON CACHE BOOL "Build implementation for OpenCL") ELSE(OPENCL_FOUND) diff --git a/devtools/conda-envs/build-macos-15-intel.yml b/devtools/conda-envs/build-macos-15-intel.yml deleted file mode 100644 index 6fb479b6..00000000 --- a/devtools/conda-envs/build-macos-15-intel.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: build -channels: - - conda-forge -dependencies: - - cmake - - compilers - - make - - openmm >=8.2 - - pip - - pytest - - python - - pytorch-cpu @PYTORCH_VERSION@ - - swig diff --git a/devtools/conda-envs/build-macos-latest.yml b/devtools/conda-envs/build-macos-latest.yml index 6fb479b6..18877300 100644 --- a/devtools/conda-envs/build-macos-latest.yml +++ b/devtools/conda-envs/build-macos-latest.yml @@ -5,9 +5,10 @@ dependencies: - cmake - compilers - make - - openmm >=8.2 - pip - pytest - python - - pytorch-cpu @PYTORCH_VERSION@ - swig + - pip: + - openmm >= 8.5 + - torch == @PYTORCH_VERSION@ diff --git a/devtools/conda-envs/build-ubuntu-24.04-hip.yml b/devtools/conda-envs/build-ubuntu-24.04-hip.yml new file mode 100644 index 00000000..86de4eb3 --- /dev/null +++ b/devtools/conda-envs/build-ubuntu-24.04-hip.yml @@ -0,0 +1,17 @@ +name: build +channels: + - conda-forge +dependencies: + - cmake + - gxx_linux-64 @GCC_VERSION@ + - make + - pip + - pytest + - python + - swig + - sysroot_linux-64 2.17 + - libxcrypt + - pip: + - --extra-index-url https://download.pytorch.org/whl/rocm7.2 + - openmm[hip7] >=8.5 + - torch == @PYTORCH_VERSION@ diff --git a/devtools/conda-envs/build-ubuntu-22.04.yml b/devtools/conda-envs/build-ubuntu-24.04.yml similarity index 70% rename from devtools/conda-envs/build-ubuntu-22.04.yml rename to devtools/conda-envs/build-ubuntu-24.04.yml index 3582f3e3..db3c7efb 100644 --- a/devtools/conda-envs/build-ubuntu-22.04.yml +++ b/devtools/conda-envs/build-ubuntu-24.04.yml @@ -3,17 +3,17 @@ channels: - conda-forge dependencies: - cmake - - cuda-version @CUDATOOLKIT_VERSION@ - gxx_linux-64 @GCC_VERSION@ - make - nnpops - ocl-icd - - openmm >=8.1 - pip - pytest - python - - pytorch-gpu @PYTORCH_VERSION@ - swig - sysroot_linux-64 2.17 - torchani - libxcrypt + - pip: + - openmm[cuda13] >= 8.5 + - torch == @PYTORCH_VERSION@ diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d7675cdc..b88b9101 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -24,7 +24,7 @@ add_custom_target(PythonInstall DEPENDS "${WRAP_FILE}" "${CMAKE_CURRENT_SOURCE_ set(NN_PLUGIN_HEADER_DIR "${CMAKE_SOURCE_DIR}/openmmapi/include") set(NN_PLUGIN_LIBRARY_DIR "${CMAKE_BINARY_DIR}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py) -add_custom_command(TARGET PythonInstall +add_custom_command(TARGET PythonInstall POST_BUILD COMMAND "${PYTHON_EXECUTABLE}" -m pip install . WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )