Skip to content

Commit

Permalink
Merge pull request #318 from mir-group/install/yu
Browse files Browse the repository at this point in the history
Compilers and libraries from conda instead of module load
  • Loading branch information
YuuuXie authored Aug 13, 2022
2 parents 859b854 + 2f1284d commit 41eb63b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 32 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ExternalProject_Add(
INSTALL_COMMAND ""
)
if (NOT FLARE_PYTHON_VERSION)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5)
set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5)
endif()
find_package(PythonLibsNew ${FLARE_PYTHON_VERSION} REQUIRED)

Expand Down Expand Up @@ -157,6 +157,12 @@ add_dependencies(flare eigen_project)
# Link to json.
target_link_libraries(flare PUBLIC nlohmann_json::nlohmann_json)

# Add conda include directories
if (DEFINED ENV{CONDA_PREFIX})
message(STATUS "Adding conda include directories.")
include_directories($ENV{CONDA_PREFIX}/include)
endif()

# Link to OpenMP.
if (DEFINED ENV{OMP_LOC})
target_link_libraries(flare PUBLIC $ENV{OMP_LOC})
Expand Down
22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,17 @@ All the tutorials take a few minutes to run on a normal desktop computer or lapt

## Installation
### Pip installation
If you're installing on a compute cluster, make sure to load the following modules first:
```
module load cmake/3.17.3-fasrc01 python/3.6.3-fasrc01 gcc/9.3.0-fasrc01
```

FLARE can be installed in two different ways.
1. Download and install automatically:
```
pip install mir-flare
```
2. Download this repository and install (required for unit tests):
```
git clone https://github.com/mir-group/flare
cd flare
pip install .
```
Please check the [installation guide here](https://mir-group.github.io/flare/installation/install.html).
This will take a few minutes on a normal desktop computer or laptop.

### Developer's installation guide
For developers, please check the [installation guide](https://mir-group.github.io/flare_pp/installation.html).
For developers, please check the [installation guide](https://mir-group.github.io/flare/installation/install.html#developer-s-installation-guide).

### Compiling LAMMPS
See [documentation on compiling LAMMPS with FLARE](https://mir-group.github.io/flare/installation/lammps.html)

### Trouble shooting
If you have problem compiling and installing the code, please check the [FAQs](https://mir-group.github.io/flare_pp/faqs.html) to see if your problem is covered. Otherwise, please open an issue or contact us.
If you have problem compiling and installing the code, please check the [FAQs](https://mir-group.github.io/flare/installation/install.html#trouble-shooting) to see if your problem is covered. Otherwise, please open an issue or contact us.

## System requirements
### Software dependencies
Expand Down
70 changes: 59 additions & 11 deletions docs/source/installation/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,41 @@ Installation of FLARE
Requirements
************

If you're installing on a compute cluster, make sure to load the following modules first:
1. Create a new conda environment to install flare

.. code-block:: bash
module load cmake/3.17.3-fasrc01 python/3.6.3-fasrc01 gcc/9.3.0-fasrc01
conda create --name flare python=3.8
conda activate flare
**********************
Installation using pip
**********************
2. Use conda to install compilers and dependencies for flare

Pip can automatically fetch the source code from PyPI_ and install.
* Option 1: If you want to install flare with mkl

.. code-block:: bash
conda install -y gcc gxx cmake mkl-devel mkl-service openmp -c conda-forge
* Option 2: If you want to install flare with openblas + lapacke

.. code-block:: bash
$ pip install mir-flare
conda install -y gcc gxx cmake openmp liblapacke openblas -c conda-forge
For non-admin users
* Option 3: You can load modules if your machine have already installed them

.. code-block:: bash
$ pip install --upgrade --user mir-flare
.. _PyPI: https://pypi.org/project/mir-flare/
module load cmake/3.17.3 gcc/9.3.0 intel-mkl/2017.2.174
3. Download flare code from github repo and pip install

.. code-block:: bash
git clone -b development https://github.com/mir-group/flare.git
cd flare
pip install .
******************************
Developer's installation guide
Expand Down Expand Up @@ -60,6 +72,42 @@ Finally, add the path of ``flare`` to ``PYTHONPATH``, such that you can ``import
An alternative way is setting ``sys.path.append(<flare path>)`` in your python script.


***********************
Test FLARE installation
***********************

After the installation is done, you can leave the current folder and in the python console, try

.. code-block:: ipython
>>> import flare
>>> flare.__file__
'/xxx/.conda/envs/flare/lib/python3.8/site-packages/flare/__init__.py'
>>> import flare.bffs.sgp
You can also check that the flare C++ library is linked to mkl (or openblas and lapacke) and openmp by

.. code-block:: bash
ldd /xxx/.conda/envs/flare/lib/python3.8/site-packages/flare/bffs/sgp/_C_flare.*.so
where it is expected to show libmkl (or libopenblas), libgomp etc.

****************
Trouble shooting
****************

* If it fails to build mir-flare during pip install, check whether you have done `conda install cxx-compiler`, then it sometimes does not find the correct g++, i.e. `which gcc` gives the conda’s gcc, while `which g++` still gives the local one. In such case, try `conda uninstall cxx-compiler gxx`, and then redo `conda install gxx -c conda-forge`

* If you get the error that `mkl.h` is not found during pip install, first check `conda list` that `mkl-include` is installed in the current environment. You can also use your own mkl headers by setting environment variable `MKL_INCLUDE` to the directory

* If you manage to install flare, but get warning when `import flare.bffs.sgp`, then please check

* `which pip` should show that `pip` is in the `.conda/envs/flare/bin/` directory, instead of others

* the `ldd` command above should show the linked libraries in the `.conda/envs/flare` directory


*****************************************
Acceleration with multiprocessing and MKL
*****************************************
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy >=1.18, <=1.20.3
numpy >=1.18, <1.23
scipy
memory_profiler
numba
Expand Down

0 comments on commit 41eb63b

Please sign in to comment.