From 2e50cd013c40c6de4c78d976437d72a7dc76a40f Mon Sep 17 00:00:00 2001 From: niklundgren Date: Wed, 10 Aug 2022 17:25:46 -0700 Subject: [PATCH 1/6] Fixed variables in flare/dft_interface/cp2k_util.py to be consistent with arguments passed by the otf module, and with the rest of the dft utils --- flare/dft_interface/cp2k_util.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/flare/dft_interface/cp2k_util.py b/flare/dft_interface/cp2k_util.py index 6a8164513..ed13c5405 100644 --- a/flare/dft_interface/cp2k_util.py +++ b/flare/dft_interface/cp2k_util.py @@ -24,19 +24,19 @@ def run_dft_par( dft_input, structure, dft_loc, - ncpus=1, + n_cpus=1, dft_out="dft.out", npool=None, mpi="mpi", **dft_kwargs, ): """run DFT calculation with given input template - and atomic configurations. if ncpus == 1, it executes serial run. + and atomic configurations. if n_cpus == 1, it executes serial run. :param dft_input: input template file name :param structure: atomic configuration :param dft_loc: relative/absolute executable of the DFT code - :param ncpus: # of CPU for mpi + :param n_cpus: # of CPU for mpi :param dft_out: output file name :param npool: not used :param mpi: not used @@ -46,11 +46,11 @@ def run_dft_par( newfilename = edit_dft_input_positions(dft_input, structure) dft_command = f"{dft_loc} -i {newfilename}" - if ncpus > 1: + if n_cpus > 1: if mpi == "mpi": - dft_command = f"mpirun -np {ncpus} {dft_command}" + dft_command = f"mpirun -np {n_cpus} {dft_command}" else: - dft_command = f"srun -n {ncpus} {dft_command}" + dft_command = f"srun -n {n_cpus} {dft_command}" # output.write_to_output(dft_command+'\n') with open(dft_out, "w+") as fout: @@ -65,7 +65,7 @@ def run_dft_en_par( dft_input: str, structure, dft_loc: str, - ncpus: int, + n_cpus: int, dft_out: str = "dft.out", npool: int = None, mpi: str = "mpi", @@ -77,7 +77,7 @@ def run_dft_en_par( :param dft_input: input template file name :param structure: atomic configuration :param dft_loc: relative/absolute executable of the DFT code - :param ncpus: # of CPU for mpi + :param n_cpus: # of CPU for mpi :param dft_out: output file name :param npool: not used :param mpi: not used @@ -87,8 +87,8 @@ def run_dft_en_par( newfilename = edit_dft_input_positions(dft_input, structure) dft_command = f"{dft_loc} -i {newfilename} > {dft_out}" - if ncpus > 1: - dft_command = f"mpirun -np {ncpus} {dft_command}" + if n_cpus > 1: + dft_command = f"mpirun -np {n_cpus} {dft_command}" # output.write_to_output(dft_command+'\n') call(dft_command, shell=True) os.remove(newfilename) From d128876073fafd62fb105ae22e22023a4f3b36d7 Mon Sep 17 00:00:00 2001 From: YuuuXie Date: Thu, 11 Aug 2022 23:01:36 -0400 Subject: [PATCH 2/6] remove numpy version upper bound --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f2c1fd1ef..fe9cef5dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy >=1.18, <=1.20.3 +numpy >=1.18 scipy memory_profiler numba From 807ca5682748fdfe95b847b102fe966f4c1dace2 Mon Sep 17 00:00:00 2001 From: YuuuXie Date: Thu, 11 Aug 2022 23:01:56 -0400 Subject: [PATCH 3/6] add conda dir to cmake --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6410c9567..4e75e687b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) From c280344bd7a8d87e05fce4b498f2509e3dc687a7 Mon Sep 17 00:00:00 2001 From: YuuuXie Date: Fri, 12 Aug 2022 15:15:38 -0400 Subject: [PATCH 4/6] add numpy upper limit 1.22 for numba --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fe9cef5dd..4f6cf6233 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy >=1.18 +numpy >=1.18, <1.23 scipy memory_profiler numba From 44b31b89dc96041ce8ca15d74d4a1c9882fd621b Mon Sep 17 00:00:00 2001 From: Yu Xie Date: Fri, 12 Aug 2022 16:47:58 -0400 Subject: [PATCH 5/6] add python 3.8 to cmakelists --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e75e687b..1bb1d6daa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) From e73501b47d13111a5e01f69d7abedd16d241bbbe Mon Sep 17 00:00:00 2001 From: YuuuXie Date: Fri, 12 Aug 2022 22:02:53 -0400 Subject: [PATCH 6/6] add installation guide --- README.md | 22 ++------- docs/source/installation/install.rst | 70 +++++++++++++++++++++++----- 2 files changed, 62 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index d7abc7667..b6c08a578 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/source/installation/install.rst b/docs/source/installation/install.rst index 85536730f..d125aa678 100644 --- a/docs/source/installation/install.rst +++ b/docs/source/installation/install.rst @@ -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 @@ -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()`` 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 *****************************************