diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 00000000..faf22a4c --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,201 @@ +Installing with conda +--------------------- + +We provide [conda](https://docs.conda.io/) packages for Linux and MacOS via [`conda-forge`](https://conda-forge.org/), which can be installed from the [conda-forge channel](https://anaconda.org/conda-forge/openmm-torch): +```bash +conda install -c conda-forge openmm-torch +``` +If you don't have `conda` available, we recommend installing [Miniconda for Python 3](https://docs.conda.io/en/latest/miniconda.html) to provide the `conda` package manager. + + +Building from source +-------------------- + +Depending on your environment there are different instructions to follow: + - Linux (NO CUDA): This is for Linux OS when you do have have, or do not want to use CUDA. + - Linux (CUDA): This is for Linux OS when you have CUDA installed and have a CUDA device you want to use. + - MacOS + +### Linux (NO CUDA) + + +#### Prerequisites + +- Minconda https://docs.conda.io/en/latest/miniconda.html#linux-installers + + +#### Build & install + +1. Get the source code + + ``` + git clone https://github.com/openmm/openmm-torch.git + cd openmm-torch + ``` + + +3. Create and activate a conda environment using the provided environment file + + + ``` + conda env create -n openmm-torch -f linux_cpu.yaml + conda activate openmm-torch + ``` + +4. Configure + ``` + mkdir build && cd build + + # set the Torch_DIR path + export Torch_DIR="$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)')" + + cmake .. -DOPENMM_DIR=$CONDA_PREFIX \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX + ``` + +6. Build + ``` + make + make PythonInstall + ``` + +7. Test + ``` + make test + ``` + +8. Install + ``` + make install + ``` + +Your built version of openmm-torch will now be available in your conda environment. You can test this by trying to import `openmmtorch` into `python`. + +``` +python -c "from openmmtorch import TorchForce" +``` +Should complete without error. + + +### Linux (CUDA) + + +#### Prerequisites + +- Minconda https://docs.conda.io/en/latest/miniconda.html#linux-installers +- CUDA Toolkit https://developer.nvidia.com/cuda-downloads + +#### Build & install + +1. Get the source code + + ``` + git clone https://github.com/openmm/openmm-torch.git + cd openmm-torch + ``` + + +2. Make sure your `$CUDA_HOME` path is set correctly to the path of your CUDA installation + + ``` + echo $CUDA_HOME + ``` + +3. Create and activate a conda environment using the provided environment file + + ``` + conda env create -n openmm-torch -f linux_cuda.yaml + conda activate openmm-torch + ``` + + + +4. Configure + ``` + mkdir build && cd build + + # set the Torch_DIR path + export Torch_DIR="$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)')" + + cmake .. -DOPENMM_DIR=$CONDA_PREFIX \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX + ``` + +6. Build + ``` + make + make PythonInstall + ``` + +7. Test + ``` + make test + ``` + +8. Install + ``` + make install + ``` + +Your built version of openmm-torch will now be available in your conda environment. You can test this by trying to import `openmmtorch` into `python`. + +``` +python -c "from openmmtorch import TorchForce" +``` +Should complete without error. + + +### MacOS + +#### Prerequisites + +- Minconda https://docs.conda.io/en/latest/miniconda.html#macos-installers + + +1. Get the source code + + ``` + git clone https://github.com/openmm/openmm-torch.git + cd openmm-torch + ``` + +2. Create and activate a conda environment using the provided environment file + + ``` + conda env create -n openmm-torch -f macOS.yaml + conda activate openmm-torch + ``` + +4. Configure + ``` + mkdir build && cd build + + # set the Torch_DIR path + export Torch_DIR="$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)')" + + cmake .. -DOPENMM_DIR=$CONDA_PREFIX \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX + ``` + +6. Build + ``` + make + make PythonInstall + ``` + +7. Test + ``` + make test + ``` + +8. Install + ``` + make install + ``` + +Your built version of openmm-torch will now be available in your conda environment. You can test this by trying to import `openmmtorch` into `python`. + +``` +python -c "from openmmtorch import TorchForce" +``` +Should complete without error. diff --git a/README.md b/README.md index 08e752c0..62e2151f 100644 --- a/README.md +++ b/README.md @@ -27,43 +27,8 @@ If you don't have `conda` available, we recommend installing [Miniconda for Pyth Building from source -------------------- -This plugin uses [CMake](https://cmake.org/) as its build system. -Before compiling you must install [LibTorch](https://pytorch.org/cppdocs/installing.html), which is the PyTorch C++ API, by following the instructions at https://pytorch.org. -You can then follow these steps: +If you need to build from source look at [INSTALL.md](./INSTALL.md). -1. Create a directory in which to build the plugin. - -2. Run the CMake GUI or `ccmake`, specifying your new directory as the build directory and the top -level directory of this project as the source directory. - -3. Press "Configure". (Do not worry if it produces an error message about not being able to find PyTorch.) - -4. Set `OPENMM_DIR` to point to the directory where OpenMM is installed. This is needed to locate -the OpenMM header files and libraries. If you are unsure of what directory this is, the following -script will print it out. - -```python -from simtk import openmm -import os -print(os.path.dirname(openmm.version.openmm_library_path)) -``` - -5. Set `PYTORCH_DIR` to point to the directory where you installed the LibTorch. - -6. Set `CMAKE_INSTALL_PREFIX` to the directory where the plugin should be installed. Usually, -this will be the same as `OPENMM_DIR`, so the plugin will be added to your OpenMM installation. - -7. If you plan to build the OpenCL platform, make sure that `OPENCL_INCLUDE_DIR` and -`OPENCL_LIBRARY` are set correctly, and that `NN_BUILD_OPENCL_LIB` is selected. - -8. If you plan to build the CUDA platform, make sure that `CUDA_TOOLKIT_ROOT_DIR` is set correctly -and that `NN_BUILD_CUDA_LIB` is selected. - -9. Press "Configure" again if necessary, then press "Generate". - -10. Use the build system you selected to build and install the plugin. For example, if you -selected Unix Makefiles, type `make install` to install the plugin, and `make PythonInstall` to -install the Python wrapper. Using the OpenMM PyTorch plugin =============================== diff --git a/linux_cpu.yml b/linux_cpu.yml new file mode 100644 index 00000000..676bd6db --- /dev/null +++ b/linux_cpu.yml @@ -0,0 +1,18 @@ +name: build +channels: + - conda-forge +dependencies: + - cmake + - gxx_linux-64 + - make + #- nnpops + - ocl-icd + - openmm >=7.7 + - pip + - pocl + - pytest + - python + - pytorch-cpu + - swig <4.1 + - sysroot_linux-64 2.17 + - torchani \ No newline at end of file diff --git a/linux_cuda.yml b/linux_cuda.yml new file mode 100644 index 00000000..31ddf50f --- /dev/null +++ b/linux_cuda.yml @@ -0,0 +1,19 @@ +name: build +channels: + - conda-forge +dependencies: + - cmake + - cudatoolkit + - gxx_linux-64 + - make + - nnpops + - ocl-icd + - openmm >=7.7 + - pip + - pocl + - pytest + - python + - pytorch-gpu + - swig <4.1 + - sysroot_linux-64 2.17 + - torchani \ No newline at end of file diff --git a/macOS.yml b/macOS.yml new file mode 100644 index 00000000..493c0551 --- /dev/null +++ b/macOS.yml @@ -0,0 +1,15 @@ +name: build +channels: + - conda-forge +dependencies: + - cmake + - compilers + - khronos-opencl-icd-loader + - make + - openmm >=7.7 + - pip + - pocl + - pytest + - python + - pytorch-cpu + - swig <4.1