Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
eea4323
initial test
stefdoerr Apr 8, 2025
3563cc8
nearly working
stefdoerr Apr 8, 2025
9f1804b
still having issues with linking
stefdoerr Apr 17, 2025
0f733e4
fixed linking issues
stefdoerr Apr 17, 2025
1389289
cleanup
stefdoerr Apr 17, 2025
cb87ea7
revert to simtk now that it's included in the unofficial openmm package
stefdoerr Apr 24, 2025
9e974ae
unused envvar
stefdoerr Apr 24, 2025
91ea0a7
first working build for CPU
stefdoerr Apr 24, 2025
4733f59
CI
stefdoerr Apr 24, 2025
a55dc16
try without tag first
stefdoerr Apr 24, 2025
f44a1f4
executable sh script
stefdoerr Apr 24, 2025
f60e742
windows path
stefdoerr Apr 24, 2025
6118161
fixes
stefdoerr Apr 24, 2025
de7abbd
fix CPU linux builds
stefdoerr Apr 24, 2025
472f11b
more builds
stefdoerr Apr 25, 2025
8e6b271
all cuda versions
stefdoerr Apr 25, 2025
027768b
windows bash scripts
stefdoerr Apr 25, 2025
8d9c2d9
try installing gfortran for aarch64
stefdoerr Apr 25, 2025
a2a528a
try different package
stefdoerr Apr 25, 2025
31d0739
drop cuda 12.4 since it's no longer supported by pytorch
stefdoerr Apr 25, 2025
64aa967
build for Windows
stefdoerr Apr 25, 2025
269a6be
fix the arch list for cuda 12.8
stefdoerr Apr 25, 2025
98cc67e
some more cmake flags for Windows
stefdoerr Apr 25, 2025
99e080f
more fixes for Windows
stefdoerr Apr 25, 2025
bd7aa16
win fix
stefdoerr Apr 25, 2025
a5f5134
different openmm path
stefdoerr Apr 25, 2025
05f9683
fix opencl path
stefdoerr Apr 25, 2025
f7b3a5d
fix windows openmm library import
stefdoerr Apr 25, 2025
a1698c6
fix test issues on Windows
stefdoerr Apr 25, 2025
517ab20
fix cuda compiler paths
stefdoerr Apr 25, 2025
236245e
better escaping of CUDA paths on Windows
stefdoerr Apr 25, 2025
9a3493c
better escaping of CUDA paths on Windows
stefdoerr Apr 25, 2025
7ea16c5
jc with these path escapes in Windows
stefdoerr Apr 25, 2025
7c9431c
one more try
stefdoerr Apr 25, 2025
9464de7
try one more variant
stefdoerr Apr 25, 2025
7a8dbbb
more escaping attempts
stefdoerr Apr 25, 2025
5dcc678
fix OSX opencl detection
stefdoerr Apr 28, 2025
9f7e9b8
try one more quoting method for windows
stefdoerr Apr 28, 2025
f71d12d
libgfortran5 for aarch64 linux
stefdoerr Apr 28, 2025
2c95a24
fixes for OSX Linux aarch64 and windows
stefdoerr Apr 28, 2025
fd7429a
correct the loader paths for OSX
stefdoerr Apr 28, 2025
7209647
install tree
stefdoerr Apr 28, 2025
d37cc79
debug libgfortran issue
stefdoerr Apr 28, 2025
097e1f4
cp works differently on osx apparently
stefdoerr Apr 28, 2025
e3f88c6
try symlinking libgfortran
stefdoerr Apr 28, 2025
754b109
osx and cp...
stefdoerr Apr 28, 2025
946451c
try with bat file on Windows
stefdoerr Apr 28, 2025
c61af0d
bat again
stefdoerr Apr 28, 2025
9ba2741
these quotes will drive me insane
stefdoerr Apr 28, 2025
b0f9011
backslash heaven
stefdoerr Apr 28, 2025
b2c7dec
alternative approach with a symlink
stefdoerr Apr 28, 2025
f20d82f
ugh
stefdoerr Apr 28, 2025
2577a9f
no forward slashes in cmd commands
stefdoerr Apr 28, 2025
4333393
try again
stefdoerr Apr 28, 2025
f62742c
list bin directory
stefdoerr Apr 28, 2025
e1b29a1
more debuggging
stefdoerr Apr 28, 2025
164ee1b
mv instead of symlink
stefdoerr Apr 28, 2025
075b83c
more attempts
stefdoerr Apr 28, 2025
1b3fd7a
try fixing cuda library path
stefdoerr Apr 28, 2025
5040c91
list lib folder
stefdoerr Apr 28, 2025
33b7610
dig deeper
stefdoerr Apr 28, 2025
b3e7de5
dig deeper
stefdoerr Apr 28, 2025
342e061
try again
stefdoerr Apr 28, 2025
752bd78
installing nvtx which was missing for CUDA::nvToolsExt
stefdoerr Apr 28, 2025
ddcde39
windows linker is missing c10
stefdoerr Apr 28, 2025
b11c25f
add torch to the build dependencies
stefdoerr Apr 28, 2025
41df68c
remove torch from build deps and inrease build verbosity
stefdoerr Apr 28, 2025
f1fa256
try with windows macros
stefdoerr Apr 29, 2025
5a3048a
try a few more things
stefdoerr Apr 29, 2025
4c8e1d8
try until something sticks
stefdoerr Apr 29, 2025
dcf4794
try with all the libraries
stefdoerr Apr 29, 2025
fbf750c
try again
stefdoerr Apr 29, 2025
0b6f391
cleanup after making windows work
stefdoerr Apr 29, 2025
752c768
update CI
stefdoerr Apr 29, 2025
03f4b2a
check if we can move the before_build to before_all
stefdoerr Apr 29, 2025
a008337
no before_build
stefdoerr Apr 29, 2025
9e1c0e0
cleanup
stefdoerr Apr 29, 2025
7a3567d
cleanup osx script
stefdoerr Apr 29, 2025
06f3a50
install specific macos sdk and force minimum version
stefdoerr Apr 29, 2025
a8c8b9d
use clang as compiler
stefdoerr Apr 29, 2025
9969bb3
add compiler and linker flags
stefdoerr Apr 29, 2025
2316c1b
try again as before
stefdoerr Apr 29, 2025
0656d8a
cleanup the env of mac
stefdoerr Apr 29, 2025
753b898
change order
stefdoerr Apr 29, 2025
3bbe676
cleanup
stefdoerr Apr 29, 2025
2d4bfd6
changed order
stefdoerr Apr 29, 2025
3c9fa63
cleanuyp
stefdoerr Apr 29, 2025
09fef1b
try again
stefdoerr Apr 29, 2025
0b333fb
forgot to save
stefdoerr Apr 29, 2025
6fa7721
rm -f
stefdoerr Apr 29, 2025
8ca3c2c
restore CI
stefdoerr Apr 29, 2025
2c2194d
correct rpaths
stefdoerr Apr 29, 2025
9b29635
use before_build again
stefdoerr Apr 29, 2025
0dd139a
maybe windows cp doesn't overwrite files
stefdoerr Apr 29, 2025
ffa042b
build/install still remaining?
stefdoerr Apr 29, 2025
f2f53a2
Revert "build/install still remaining?"
stefdoerr Apr 29, 2025
a9c83ae
Revert "maybe windows cp doesn't overwrite files"
stefdoerr Apr 29, 2025
54082e1
Revert "use before_build again"
stefdoerr Apr 29, 2025
c16976a
fix rpaths and add pypi libcudart install dependency
stefdoerr Apr 30, 2025
e878d56
fix the cudart exclusion in auditwheel repait
stefdoerr Apr 30, 2025
d32f207
don't have openmm as a dep of openmm-torch so that we can be flexible…
stefdoerr Aug 26, 2025
065827b
update windows machine
stefdoerr Aug 26, 2025
49affce
try a different approach
stefdoerr Aug 26, 2025
6b2bdd5
simplify building for just cu11 and cu12
stefdoerr Aug 26, 2025
ed8950e
older compiler for cuda 12.0
stefdoerr Aug 27, 2025
6a3f919
fix windows building
stefdoerr Aug 27, 2025
0fd573a
older toolset
stefdoerr Aug 27, 2025
c5e307a
older torch
stefdoerr Aug 27, 2025
4ee75e5
cannot go older than torch 2.7.1
stefdoerr Aug 27, 2025
792972d
no hardcoded runtime versionsg
stefdoerr Aug 27, 2025
ce15db8
12.4 minimum version
stefdoerr Aug 27, 2025
48593c4
12.6 minimum
stefdoerr Aug 27, 2025
6542229
try again with 2.6.0 and cuda 12.4
stefdoerr Aug 27, 2025
d0803bf
try with previous abi
stefdoerr Aug 27, 2025
ae41d32
Revert "try with previous abi"
stefdoerr Aug 27, 2025
d0df140
Revert "try again with 2.6.0 and cuda 12.4"
stefdoerr Aug 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 191 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build wheels and publish

on:
workflow_dispatch:
workflow_call:

jobs:
build:
name: Build wheels on ${{ matrix.os }}-${{ matrix.accelerator }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-2022, macos-latest]
accelerator: [cpu, cu118, cu126] #, cu128]
exclude:
- os: ubuntu-24.04-arm
accelerator: cu118
- os: ubuntu-24.04-arm
accelerator: cu126
# - os: ubuntu-24.04-arm
# accelerator: cu128
- os: macos-latest
accelerator: cu118
- os: macos-latest
accelerator: cu126
# - os: macos-latest
# accelerator: cu128

steps:
- name: Free space of Github Runner (otherwise it will fail by running out of disk)
if: matrix.os == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "/usr/local/.ghcup"
sudo rm -rf "/usr/local/julia1.9.2"
sudo rm -rf "/usr/local/lib/android"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.23.0

- name: Activate MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.29
if: matrix.os == 'windows-2022'

- name: "Install dependencies with choco"
uses: crazy-max/ghaction-chocolatey@v3
if: matrix.os == 'windows-2022'
with:
args: install jom

- name: Build wheels
if: matrix.os != 'windows-2022'
shell: bash -l {0}
run: python -m cibuildwheel python/ --output-dir wheelhouse
env:
ACCELERATOR: ${{ matrix.accelerator }}

- name: Build wheels
if: matrix.os == 'windows-2022'
shell: cmd # Use cmd on Windows to avoid bash environment taking priority over MSVC variables
run: python -m cibuildwheel python/ --output-dir wheelhouse
env:
DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building
ACCELERATOR: ${{ matrix.accelerator }}

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.accelerator }}-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

publish-to-public-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
strategy:
fail-fast: false
matrix:
accelerator: [cpu, cu118, cu126] #, hip, cu124, cu126, cu128]

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: "${{ matrix.accelerator }}-cibw-wheels*"
path: dist/
merge-multiple: true

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PUBLIC_PYPI_API_TOKEN }}
skip-existing: true

# publish-to-accelera-pypi:
# name: >-
# Publish Python 🐍 distribution 📦 to Acellera PyPI
# needs:
# - build
# runs-on: ubuntu-latest
# permissions: # Needed for GCP authentication
# contents: "read"
# id-token: "write"
# strategy:
# fail-fast: false
# matrix:
# accelerator: [cpu, cu118, cu126] #, cu128]

# steps:
# - uses: actions/checkout@v4 # Needed for GCP authentication for some reason

# - name: Set up Cloud SDK
# uses: google-github-actions/auth@v2
# with:
# workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
# service_account: ${{ secrets.GCP_PYPI_SERVICE_ACCOUNT }}

# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# pattern: "${{ matrix.accelerator }}-cibw-wheels*"
# path: dist/
# merge-multiple: true

# - name: Publish distribution 📦 to Acellera PyPI
# run: |
# pip install build twine keyring keyrings.google-artifactregistry-auth
# pip install -U packaging
# twine upload --repository-url https://us-central1-python.pkg.dev/pypi-packages-455608/${{ matrix.accelerator }} dist/* --verbose --skip-existing

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- build
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true

- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.whl

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--notes ""

- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"
9 changes: 9 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Whole

on: [push]

jobs:
publish:
if: startsWith(github.event.ref, 'refs/tags/v')
uses: ./.github/workflows/publish.yml
secrets: inherit
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ SET_TARGET_PROPERTIES(${SHARED_NN_TARGET}
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(${SHARED_NN_TARGET} OpenMM)
TARGET_LINK_LIBRARIES(${SHARED_NN_TARGET} "${TORCH_LIBRARIES}")
SET_TARGET_PROPERTIES(${SHARED_NN_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN;$ORIGIN/../../torch/lib;$ORIGIN/../../nvidia/cuda_nvrtc/lib")
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_NN_TARGET})

# install headers
Expand Down
1 change: 1 addition & 0 deletions platforms/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ IF (APPLE)
SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES LINK_FLAGS "-F/Library/Frameworks -framework CUDA ${EXTRA_COMPILE_FLAGS}")
ENDIF (APPLE)

SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN;$ORIGIN/..;$ORIGIN/../../../nvidia/cuda_runtime/lib/;$ORIGIN/../../../torch/lib;")
INSTALL(TARGETS ${SHARED_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/plugins)

SUBDIRS (tests)
1 change: 1 addition & 0 deletions platforms/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES
COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY ${EXTRA_COMPILE_FLAGS}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")

SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN;$ORIGIN/..;$ORIGIN/../../../torch/lib;")
INSTALL(TARGETS ${SHARED_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/plugins)

SUBDIRS (tests)
Expand Down
1 change: 1 addition & 0 deletions platforms/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES
COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY ${EXTRA_COMPILE_FLAGS}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")

SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN;$ORIGIN/..;$ORIGIN/../../../torch/lib;")
INSTALL(TARGETS ${SHARED_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/plugins)

SUBDIRS (tests)
Expand Down
1 change: 1 addition & 0 deletions platforms/reference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES
COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY ${EXTRA_COMPILE_FLAGS}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")

SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN;$ORIGIN/..;$ORIGIN/../../../torch/lib;")
INSTALL(TARGETS ${SHARED_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/plugins)

SUBDIRS (tests)
8 changes: 4 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
COMMAND "${PYTHON_EXECUTABLE}" -m pip install .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
# add_custom_command(TARGET PythonInstall
# COMMAND "${PYTHON_EXECUTABLE}" -m pip install .
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
# )
4 changes: 4 additions & 0 deletions python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
graft openmm/
graft openmmtorch/
prune tests
prune cibuildwheel_support
123 changes: 123 additions & 0 deletions python/cibuildwheel_support/before_all_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#! /bin/bash

set -e
set -x

# Install dependencies with yum
dnf install -y zip opencl-headers ocl-icd tree

# Check if we are running on aarch64
if [ "$(uname -m)" == "aarch64" ]; then
dnf install -y libgfortran
ln -s /usr/lib64/libgfortran.so.5.0.0 /usr/lib64/libgfortran-0b50f350.so.5.0.0
fi

# Configure pip to use PyTorch extra-index-url for CPU
mkdir -p $HOME/.config/pip
echo "[global]
extra-index-url = https://download.pytorch.org/whl/cpu" > $HOME/.config/pip/pip.conf

if [ "$ACCELERATOR" == "cu118" ]; then
# Install CUDA 11.8
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo

dnf install --setopt=obsoletes=0 -y \
cuda-compiler-11-8-11.8.0-1 \
cuda-libraries-11-8-11.8.0-1 \
cuda-libraries-devel-11-8-11.8.0-1 \
cuda-toolkit-11-8-11.8.0-1 \
gcc-toolset-11

ln -s cuda-11.8 /usr/local/cuda
ln -s /opt/rh/gcc-toolset-11/root/usr/bin/gcc /usr/local/cuda/bin/gcc
ln -s /opt/rh/gcc-toolset-11/root/usr/bin/g++ /usr/local/cuda/bin/g++
ln -s /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so /usr/lib/libcuda.so.1

# Configure pip to use PyTorch extra-index-url for CUDA 11.8
mkdir -p $HOME/.config/pip
echo "[global]
extra-index-url = https://download.pytorch.org/whl/cu118" > $HOME/.config/pip/pip.conf

pip install openmm-unofficial-cu11 torch==2.7.1
elif [ "$ACCELERATOR" == "cu126" ]; then
# Install CUDA 12.6
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo

dnf install --setopt=obsoletes=0 -y \
cuda-compiler-12-6-12.6.3-1\
cuda-libraries-12-6-12.6.3-1 \
cuda-libraries-devel-12-6-12.6.3-1 \
cuda-toolkit-12-6-12.6.3-1 \
gcc-toolset-13

ln -s cuda-12.6 /usr/local/cuda
ln -s /opt/rh/gcc-toolset-13/root/usr/bin/gcc /usr/local/cuda/bin/gcc
ln -s /opt/rh/gcc-toolset-13/root/usr/bin/g++ /usr/local/cuda/bin/g++
ln -s /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so /usr/lib/libcuda.so.1

# Configure pip to use PyTorch extra-index-url for CUDA 12.6
mkdir -p $HOME/.config/pip
echo "[global]
extra-index-url = https://download.pytorch.org/whl/cu126" > $HOME/.config/pip/pip.conf

pip install openmm-unofficial-cu12 torch==2.7.1
elif [ "$ACCELERATOR" == "hip" ]; then
# Install HIP 6.2
dnf install -y https://repo.radeon.com/amdgpu-install/6.2.2/el/8.10/amdgpu-install-6.2.60202-1.el8.noarch.rpm
dnf install -y rocm-device-libs hip-devel hip-runtime-amd hipcc
pip install openmm-unofficial-cpu torch==2.7.1
else
pip install openmm-unofficial-cpu torch==2.7.1
fi

#################
SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])')

CMAKE_FLAGS=""
if [ "$ACCELERATOR" == "cu118" ] || [ "$ACCELERATOR" == "cu126" ]; then
ARCH_LIST=$(python -c "import torch; print(';'.join([f'{y[:-1]}.{y[-1]}' for y in [x[3:] for x in torch._C._cuda_getArchFlags().split() if x.startswith('sm_')]]))")
# CMakeLists.txt seems to ignore the CMAKE_CUDA_ARCHITECTURES variable, instead, it is overwritten by TORCH_CUDA_ARCH_LIST
ARCH_LIST_FMT=$(python -c "import torch; print(';'.join([y for y in [x[3:] for x in torch._C._cuda_getArchFlags().split() if x.startswith('sm_')]]))")
export CUDA_HOME="/usr/local/cuda"
CMAKE_FLAGS=" -DTORCH_CUDA_ARCH_LIST=${ARCH_LIST}"
CMAKE_FLAGS+=" -DCMAKE_CUDA_ARCHITECTURES=${ARCH_LIST_FMT}"
CMAKE_FLAGS+=" -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME}"
CMAKE_FLAGS+=" -DCMAKE_CUDA_COMPILER=${CUDA_HOME}/bin/nvcc"
fi

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=/usr/include/CL"
CMAKE_FLAGS+=" -DOPENCL_LIBRARY=/usr/lib64/libOpenCL.so.1"
fi

# Configure build with Cmake
mkdir -p build
mkdir -p install
cd build

echo $CMAKE_FLAGS
export LD_LIBRARY_PATH=/usr/lib/:/usr/local/cuda/targets/x86_64-linux/lib/:$LD_LIBRARY_PATH

cmake .. \
-DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE=Release \
-DOPENMM_DIR=${SITE_PACKAGES}/openmm \
-DPYTORCH_DIR=${SITE_PACKAGES}/torch \
-DTorch_DIR=${SITE_PACKAGES}/torch/share/cmake/Torch \
-DNN_BUILD_OPENCL_LIB=ON \
${CMAKE_FLAGS}

# Build OpenMMTorch
make -j4 install
make -j4 PythonInstall

cd ..

cp build/python/setup.py python/
cp build/python/openmmtorch.py python/openmmtorch/
cp build/python/TorchPluginWrapper.cpp python/openmmtorch/
cp -r install/include python/openmmtorch/

# Copy the libraries of openmm
mkdir -p python/openmm/
cp -r install/lib python/openmm/lib
13 changes: 13 additions & 0 deletions python/cibuildwheel_support/before_all_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash

set -e
set -x

brew install swig tree

# Configure pip to use PyTorch extra-index-url for CPU
mkdir -p $HOME/.config/pip
echo "[global]
extra-index-url = https://download.pytorch.org/whl/cpu" > $HOME/.config/pip/pip.conf

cp python/setup.py $HOME/setup.py.bkp
Loading
Loading