-
Notifications
You must be signed in to change notification settings - Fork 152
/
serverless-batch-mpi.yaml
167 lines (154 loc) · 5.15 KB
/
serverless-batch-mpi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
blueprint_name: serverless-batch-mpi
vars:
project_id: ## Set GCP Project ID Here ##
deployment_name: batch-wrf
region: us-central1
zone: us-central1-c
instance_image:
family: hpc-rocky-linux-8
project: cloud-hpc-image-public
deployment_groups:
- group: primary
modules:
- id: network1
source: modules/network/pre-existing-vpc
### Software & Script Installation ###
- id: sharefs
source: modules/file-system/filestore
use: [network1]
settings:
local_mount: /share
- id: spack-setup
source: community/modules/scripts/spack-setup
settings:
spack_ref: v0.19.0
install_dir: /share/spack
- id: spack-execute
source: community/modules/scripts/spack-execute
use: [spack-setup]
settings:
data_files:
- destination: /tmp/projections-config.yaml
content: |
modules:
default:
tcl:
hash_length: 0
all:
conflict:
- '{name}'
projections:
all: '{name}/{version}-{compiler.name}-{compiler.version}'
- destination: /share/spack/wrfv3_env.yaml
content: |
spack:
definitions:
- compilers:
- mpis:
- mpi_packages:
- [email protected] build_type=dm+sm compile_type=em_real nesting=basic ~pnetcdf
specs:
- matrix:
- - $mpis
- - $%compilers
- matrix:
- - $mpi_packages
- - $%compilers
- - $^mpis
commands: |
# Un-comment and update mirror_url to install from spack cache
# if ! spack mirror list | grep -q gcs_cache; then
# spack mirror add --scope site gcs_cache gs://optionally_set_spack_cache_bucket
# fi
# spack buildcache keys --install --trust
spack config --scope defaults add config:build_stage:/share/spack/spack-stage
spack config --scope defaults add -f /tmp/projections-config.yaml
spack install [email protected] target=x86_64
spack load [email protected] target=x86_64
spack compiler find --scope site
if ! spack env list | grep -q wrfv3; then
spack env create wrfv3 /share/spack/wrfv3_env.yaml
spack env activate wrfv3
spack concretize
spack install
fi
- id: spack-build-startup
source: modules/scripts/startup-script
settings:
runners:
- $(spack-execute.spack_runner)
- type: shell
destination: wrfv3_setup.sh
content: |
#!/bin/bash
source /share/spack/share/spack/setup-env.sh
spack env activate wrfv3
chmod -R a+rwX /share/spack/var/spack/environments/wrfv3
mkdir -p /share/wrfv3
chmod a+rwx /share/wrfv3
cd /share/wrfv3
wget --no-verbose https://www2.mmm.ucar.edu/wrf/bench/conus12km_v3911/bench_12km.tar.bz2
tar xjf bench_12km.tar.bz2
- type: data
destination: /share/wrfv3/submit_wrfv3.sh
content: |
#!/bin/bash
source /share/spack/share/spack/setup-env.sh
spack env activate wrfv3
if [ $BATCH_TASK_INDEX = 0 ]
then
mkdir --parents /share/jobs/${BATCH_JOB_ID}
cd /share/jobs/${BATCH_JOB_ID}
cp /share/wrfv3/bench_12km/* .
WRF=`spack location -i wrf`
ln -s $WRF/run/* .
mpirun -hostfile $BATCH_HOSTS_FILE -np 60 -ppn 30 /share/jobs/${BATCH_JOB_ID}/wrf.exe
fi
- type: shell
destination: shutdown.sh
content: |
#!/bin/bash
if [ ! -f /etc/block_auto_shutdown ]; then
touch /etc/block_auto_shutdown
shutdown -h +1
fi
# must restart vm to re-initiate subsequent installs
- id: spack-builder
source: modules/compute/vm-instance
use: [network1, sharefs, spack-build-startup]
settings:
name_prefix: spack-builder
add_deployment_name_before_prefix: true
machine_type: c2-standard-16
allow_automatic_updates: false
### Batch Modules ###
- id: batch-job
source: modules/scheduler/batch-job-template
use: [network1, sharefs]
settings:
runnables:
- script: . /share/wrfv3/submit_wrfv3.sh;
machine_type: c2-standard-60
task_count: 2
mpi_mode: true
allow_automatic_updates: false
- id: batch-login
source: modules/scheduler/batch-login-node
use: [spack-setup, batch-job]
outputs: [instructions]