Skip to content

Commit

Permalink
Add create_swapfile task
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Jul 25, 2022
1 parent 0957b4c commit 1bffdd8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ See `defaults/main.yml`
- role: marvel-nccr.aiida-cws
vars:
aiida_timezone_name: Europe/Zurich # to set a certain timezone for AiiDA
aiida_create_swapfile: true # create a swapfile for RAM overflow, non-containers only
aiida_allow_mpi_on_root: true # containers only
```
Expand All @@ -54,7 +55,7 @@ If you want to install SLURM and use it as the scheduler, you can use e.g.:
- role: marvel-nccr.aiida-cws
vars:
aiida_timezone_name: Europe/Zurich
aiida_allow_mpi_on_root: true
aiida_create_swapfile: true
aiida_conda_code_computer: local_slurm_conda
```
Expand Down Expand Up @@ -226,7 +227,7 @@ Please direct inquiries regarding Quantum Mobile and associated ansible roles to
- jupyter lab launcher
- rest api service
- check everything still works with non-root user install
- understand set up of `swapfile` (doesn't seem to work on docker), plus other steps from `marvel-nccr.simulationbase`
- migrate tasks from `marvel-nccr.simulationbase` (understand `hostname.yml`, which is non-container only, and `clean.yml`)
- Get <https://github.com/quanshengwu/wannier_tools> on Conda, to replace `marvel-nccr.wannier_tools`

- run code tests (how to check success <https://github.com/aiidateam/aiida-common-workflows/issues/289>?):
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ aiida_release_notes: "${HOME}/aiida_release_notes.ini"
aiida_temp_folder: /tmp
aiida_data_folder_temp: "${HOME}/.local/share/aiida"
aiida_allow_mpi_on_root: false # should only be set for containers
aiida_create_swapfile: false
aiida_apt_packages:
- vim # required for manual verdi code/computer setup
- ssh # required by MPI
Expand Down
32 changes: 32 additions & 0 deletions tasks/create_swapfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# When the computer doesn't have enough RAM to hold everything it needs,
# it can move some it doesn't need immediately to the hard drive.
# It's incredibly slow, but it's usually considered better than the computer crashing.
# This is required by many simulation codes.
# see: https://www.techtarget.com/searchwindowsserver/definition/swap-file-swap-space-or-pagefile
# note this can not be added in a container, since there the underlying OS handles memory

- name: "Check if swapfile exists"
stat: path=/swapfile
register: swapfile_stat

- block:

- name: "Create swapfile"
become: true
command: "dd if=/dev/zero of=/swapfile bs=1M count=1024"

- name: "Make the swapfile a valid swap"
become: true
command: "mkswap /swapfile"

- name: "Use the swapfile"
become: true
command: "swapon /swapfile"

- name: "Put a line in fstab to ensure swap is used at boot time"
become: true
lineinfile:
path: "/etc/fstab"
line: "/swapfile swap swap defaults 0 0"

when: not swapfile_stat.stat.exists
4 changes: 4 additions & 0 deletions tasks/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
name: "{{ aiida_timezone_name }}"
when: aiida_timezone_name is defined

- name: Setup swapfile RAM "overspill"
include_tasks: create_swapfile.yml
when: aiida_create_swapfile

- name: Set user environmental variables
# OMP_NUM_THREADS: https://github.com/marvel-nccr/quantum-mobile/issues/187
# MAMBA_NO_BANNER: https://github.com/mamba-org/mamba/issues/587#issuecomment-762998474
Expand Down

0 comments on commit 1bffdd8

Please sign in to comment.