Unverified Commit e6007c8c authored by Adam Fekete's avatar Adam Fekete Committed by GitHub
Browse files

Merge pull request #4 from modl-uclouvain/tuto_part1

Tuto part1
parents 725f92b6 953eb53d
# mongodb instance folder
db/
......@@ -5,6 +6,9 @@ db/
tutorials/flow_sic_relax
tutorials/launcher_*/
# VSCode IDE
.vscode
# https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
......
......@@ -24,7 +24,7 @@ RUN apt-get update \
WORKDIR /tmp
ARG abinit_version="9.4.0"
COPY configs/abinit_config.ac9 /tmp/abinit-${abinit_version}/build/abinit_config.ac9
COPY configs/abinit/abinit_config.ac9 /tmp/abinit-${abinit_version}/build/abinit_config.ac9
RUN wget -k "https://www.abinit.org/sites/default/files/packages/abinit-${abinit_version}.tar.gz" \
&& tar xzf abinit-${abinit_version}.tar.gz \
......@@ -38,11 +38,34 @@ RUN wget -k "https://www.abinit.org/sites/default/files/packages/abinit-${abinit
FROM jupyter/scipy-notebook
LABEL maintainer="Gian-Marco Rignanese <gian-marco.rignanese@uclouvain.be>"
# Setup slurm
# ===========
USER root
RUN apt-get update \
&& apt install -y --no-install-recommends \
slurmd slurm-client slurmctld \
&& rm -rf /var/lib/apt/lists/*
COPY configs/slurm/slurm.conf /etc/slurm-llnl/slurm.conf
COPY configs/slurm/start_slurm.sh /usr/local/bin/before-notebook.d/
# https://github.com/yuwata/slurm-fedora/blob/master/slurm-setuser.in
RUN mkdir -p /run/munge \
&& chown -R jovyan /run/munge /etc/munge /var/lib/munge /var/log/munge \
&& mkdir -p /var/run/slurm-llnl \
&& chown -R jovyan /var/run/slurm-llnl /var/lib/slurm-llnl /var/log/slurm-llnl
USER $NB_UID
# Abinit installation
# ===================
# # 1. MPI libraries - choice for Open MPI: mpi-default-bin openmpi-bin libopenmpi3
# # 2. math libraries - choice for lapack and blas: liblapack3 libblas3
# # 3. mandatory libraries: libhdf5-103 libnetcdf15 libnetcdff7 libpnetcdf0d libxc5 libfftw3-bin libxml2
# - MPI libraries - choice for Open MPI: mpi-default-bin openmpi-bin libopenmpi3
# - math libraries - choice for lapack and blas: liblapack3 libblas3
# - mandatory libraries: libhdf5-103 libnetcdf15 libnetcdff7 libpnetcdf0d libxc5 libfftw3-bin libxml2
USER root
......@@ -62,46 +85,34 @@ ENV PATH=/opt/abinit/bin:$PATH
# Install Python 3 packages
# =========================
# fireworks's depenecies: flask-paginate gunicorn pymongo
# pseudo_dojo's depenecies: periodic-table-plotter atomicfile
# Depenecies:
# - fireworks: flask-paginate gunicorn pymongo
# - pseudo_dojo: periodic-table-plotter atomicfile
RUN conda install --quiet --yes \
'abipy' \
'jupyter-server-proxy' \
'flask-paginate' 'gunicorn' 'pymongo' \
'periodic-table-plotter' 'atomicfile' \
&& pip install --no-cache-dir jupyter-jsmol fireworks \
&& pip install --no-cache-dir jupyter-jsmol \
&& pip install --no-cache-dir git+https://github.com/modl-uclouvain/fireworks.git \
&& pip install --no-cache-dir jupyter-fireworks-proxy \
&& pip install --no-cache-dir git+https://github.com/gpetretto/abiflows.git@develop \
&& conda clean --all -f -y \
&& fix-permissions "${CONDA_DIR}" \
&& fix-permissions "/home/${NB_USER}"
# Pseudo-dojo
# ===========
# Install a "lightweight" version of Pseudo-dojo
COPY --chown=$NB_UID:$NB_GID pseudo_dojo /opt/pseudo_dojo
WORKDIR /opt/pseudo_dojo
RUN pip install -e .
# Setup slurm
# ===========
USER root
RUN apt-get update \
&& apt install -y --no-install-recommends \
slurmd slurm-client slurmctld \
&& rm -rf /var/lib/apt/lists/*
COPY configs/slurm.conf /etc/slurm-llnl/slurm.conf
COPY configs/start_slurm.sh /usr/local/bin/before-notebook.d/
# https://github.com/yuwata/slurm-fedora/blob/master/slurm-setuser.in
RUN mkdir -p /run/munge \
&& chown -R jovyan /run/munge /etc/munge /var/lib/munge /var/log/munge \
&& mkdir -p /var/run/slurm-llnl \
&& chown -R jovyan /var/run/slurm-llnl /var/lib/slurm-llnl /var/log/slurm-llnl
# Setup home folder
# =================
USER $NB_UID
WORKDIR $HOME
COPY --chown=$NB_UID:$NB_GID configs/abipy .abinit/abipy
COPY --chown=$NB_UID:$NB_GID configs/fireworks .fireworks
COPY --chown=$NB_UID:$NB_GID tutorials tutorials
fw_policy:
autoparal: True
rerun_same_dir: False
allow_local_restart: False
mpirun_cmd: mpirun
max_restarts: 30
abipy_manager: /home/jovyan/.abinit/abipy/manager.yml
## Local runner ##############
# policy:
# autoparal: 0
hardware: &hardware
num_nodes: 1
sockets_per_node: 1
cores_per_socket: 4
mem_per_node: 16 Gb
job: &job
mpi_runner: "mpirun"
# pre_run: "export PATH=$HOME/git_repos/abinit/build_gcc/src/98_main:$PATH"
qadapters: # List of `qadapters` objects (just one in this simplified example)
- priority: 2
queue:
qtype: shell # "Submit" jobs via the shell.
qname: localhost # "Submit" to the localhost queue
# (it's a fake queue in this case)
limits:
timelimit: 01:00:00 # Time-limit for each task.
max_cores: 4 # Max number of cores that can be used by a single task.
hint_cores: 2
hardware: *hardware
job: *job
- priority: 1
queue:
qname: debug
qtype: slurm
limits:
timelimit: 2:00:0
min_cores: 1
max_cores: 2
min_mem_per_proc: 1
hardware: *hardware
job: *job
##############################
PRINT_FW_JSON: True
LAUNCHPAD_LOC: /home/jovyan/.fireworks/my_launchpad.yaml
FWORKER_LOC: /home/jovyan/.fireworks/my_fworker.yaml
QUEUEADAPTER_LOC: /home/jovyan/.fireworks/my_qadapter.yaml
SUBMIT_SCRIPT_NAME: FW_submit.script
QUEUE_UPDATE_INTERVAL: 3
EXCEPT_DETAILS_ON_RERUN: True
REMOVE_USELESS_DIRS: True
#!/bin/bash -l
#SBATCH --nodes=$${nodes}
#SBATCH --ntasks=$${ntasks}
#SBATCH --ntasks-per-node=$${ntasks_per_node}
#SBATCH --ntasks-per-core=$${ntasks_per_core}
#SBATCH --core-spec=$${core_spec}
#SBATCH --exclude=$${exclude_nodes}
#SBATCH --cpus-per-task=$${cpus_per_task}
#SBATCH --gpus-per-task=$${gpus_per_task}
#SBATCH --gres=$${gres}
#SBATCH --qos=$${qos}
#SBATCH --time=$${walltime}
#SBATCH --time-min=$${time_min}
#SBATCH --partition=$${queue}
#SBATCH --account=$${account}
#SBATCH --job-name=$${job_name}
#SBATCH --license=$${license}
#SBATCH --output=$${job_name}-%j.out
#SBATCH --error=$${job_name}-%j.error
#SBATCH --constraint=$${constraint}
#SBATCH --signal=$${signal}
#SBATCH --mem=$${mem}
#SBATCH --mem-per-cpu=$${mem_per_cpu}
#SBATCH --mail-type=$${mail_type}
#SBATCH --mail-user=$${mail_user}
$${pre_rocket}
cd $${launch_dir}
$${rocket_launch}
$${post_rocket}
name: jovyan_worker
category: ''
query: '{}'
_fw_name: CommonAdapter
_fw_q_type: SLURM
_fw_template_file: /home/jovyan/.fireworks/SLURM_template.txt
rocket_launch: rlaunch singleshot
ntasks: 1
walltime: '02:0:0'
queue: debug
account: null
job_name: null
pre_rocket: null
post_rocket: null
......@@ -45,5 +45,5 @@ SlurmctldLogFile=/var/log/slurm-llnl/slurmctld.log
SlurmdLogFile=/var/log/slurm-llnl/slurmd.log
# COMPUTE NODES
NodeName=localhost CPUs=1 State=UNKNOWN
NodeName=localhost CPUs=4 State=UNKNOWN
PartitionName=debug Nodes=localhost Default=YES MaxTime=INFINITE State=UP
version: '3.1'
services:
workflows-workshop:
# build: .
image: workflows-workshop:latest
restart: always
user: root
environment:
# - NB_UID=1001
- GRANT_SUDO=yes
- OMPI_MCA_btl_vader_single_copy_mechanism=none
ports:
- 8888:8888
- 5000:5000
depends_on:
- mongo
volumes:
- ./tutorials:/home/jovyan/tutorials
mongo:
image: mongo
restart: always
# environment:
# - MONGO_INITDB_ROOT_USERNAME=admin
# - MONGO_INITDB_ROOT_PASSWORD=secret
# ports:
# - 27017:27017 # opening port for development only!
volumes:
- ./db:/data/db
# mongo-express: # mongo-express only for development only!
# image: mongo-express
# restart: always
# ports:
# - 8081:8081
# environment:
# - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
# - ME_CONFIG_MONGODB_ADMINPASSWORD=secret
# depends_on:
# - mongo
......@@ -2,39 +2,15 @@ version: '3.1'
services:
workflows-workshop:
# build: .
image: workflows-workshop:latest
restart: always
user: root
environment:
# - NB_UID=1001
- GRANT_SUDO=yes
- OMPI_MCA_btl_vader_single_copy_mechanism=none
ports:
- 8888:8888
- 5000:5000
depends_on:
- mongo
volumes:
- ./tutorials:/home/jovyan/tutorials
mongo:
image: mongo
restart: always
# environment:
# - MONGO_INITDB_ROOT_USERNAME=admin
# - MONGO_INITDB_ROOT_PASSWORD=secret
# ports:
# - 27017:27017 # opening port for development only!
volumes:
- ./db:/data/db
# mongo-express: # mongo-express only for development only!
# image: mongo-express
# restart: always
# ports:
# - 8081:8081
# environment:
# - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
# - ME_CONFIG_MONGODB_ADMINPASSWORD=secret
# depends_on:
# - mongo
%% Cell type:markdown id:exempt-cloud tags:
# Abinit - quickstart
https://abinit.github.io/abipy/flow_gallery/run_sic_relax.html#sphx-glr-flow-gallery-run-sic-relax-py
%% Cell type:code id:necessary-budapest tags:
``` python
!abicheck.py
```
%% Cell type:markdown id:chronic-invention tags:
## Relaxation Flow
This example shows how to build a very simple Flow for the structural relaxation of SiC. One could use a similar logic to perform multiple relaxations with different input parameters…
%% Cell type:code id:handmade-dividend tags:
``` python
import abipy.abilab as abilab
import abipy.data as data
import abipy.flowtk as flowtk
def build_flow(workdir):
pseudos = data.pseudos("14si.pspnc", "6c.pspnc")
structure = data.structure_from_ucell("SiC")
# Initialize the input
relax_inp = abilab.AbinitInput(structure, pseudos=pseudos)
# Set variables
relax_inp.set_vars(
ecut=20,
paral_kgb=1,
iomode=3,
# Relaxation part
ionmov=2,
optcell=1,
strfact=100,
ecutsm=0.5, # Important!
dilatmx=1.15, # Important!
toldff=1e-6,
tolmxf=1e-5,
ntime=100,
)
# K-points sampling
shiftk = [
[0.5,0.5,0.5],
[0.5,0.0,0.0],
[0.0,0.5,0.0],
[0.0,0.0,0.5]
]
relax_inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=shiftk)
# Initialize the flow
flow = flowtk.Flow(workdir)
# Register the task.
flow.register_relax_task(relax_inp)
return flow
```
%% Cell type:markdown id:related-music tags:
Build and run the flow:
%% Cell type:code id:steady-fellowship tags:
``` python
flow = build_flow('flow_sic_relax')
flow.rmtree()
scheduler = flow.make_scheduler()
scheduler.start()
```
%% Cell type:markdown id:confirmed-space tags:
To visualize the evolution of the lattice parameters during the structura relaxation use:
%% Cell type:code id:raising-valuable tags:
``` python
abifile = abilab.abiopen('flow_sic_relax/w0/t0/outdata/out_HIST.nc')
abifile.plot();
```
%% Cell type:code id:changing-bennett tags:
``` python
```
%% Cell type:code id:passing-mineral tags:
``` python
```
%% Cell type:code id:prescribed-mexico tags:
``` python
```
## Local runner ##############
# policy:
# autoparal: 0
qadapters: # List of `qadapters` objects (just one in this simplified example)
- priority: 1
queue:
qtype: shell # "Submit" jobs via the shell.
qname: localhost # "Submit" to the localhost queue
# (it's a fake queue in this case)
job:
mpi_runner: "mpirun"
# pre_run: "export PATH=$HOME/git_repos/abinit/build_gcc/src/98_main:$PATH"
limits:
timelimit: 01:00:00 # Time-limit for each task.
max_cores: 4 # Max number of cores that can be used by a single task.
hint_cores: 2
hardware:
num_nodes: 1
sockets_per_node: 1
cores_per_socket: 4
mem_per_node: 16 Gb