... | ... |
@@ -169,7 +169,7 @@ You can use computing resources effectively by executing multiple programs simul |
169 | 169 |
You can execute multiple programs simultaneously as a single job by describing multiple execution commands in a shell script and executing the shell script. |
170 | 170 |
|
171 | 171 |
※This method is for a sequential program or a program that is thread-parallelized by OpenMP or automatic parallelization functions. |
172 |
-※It is not possible to execute multiple MPI programs simultaneously as a single job. |
|
172 |
+※To execute multiple MPI programs simultaneously as a single job, please refer to [How to execute multiple programs simultaneously (MPMD)](#mpmd). |
|
173 | 173 |
|
174 | 174 |
An example of each script is shown below. |
175 | 175 |
|
... | ... |
@@ -286,3 +286,56 @@ case $SLURM_PROCID in |
286 | 286 |
|
287 | 287 |
esac |
288 | 288 |
``` |
289 |
+ |
|
290 |
+## How to execute multiple programs simultaneously (MPMD) |
|
291 |
+ |
|
292 |
+** Job script to be executed by sbatch command (MPI) ** |
|
293 |
+ |
|
294 |
+※The following script is a sample to execute 3 MPI program (4 cores and 4 threads per process) that requires 4 processes concurrently. |
|
295 |
+ |
|
296 |
+```nohighlight |
|
297 |
+#!/bin/bash |
|
298 |
+#============ SBATCH Directives ======= |
|
299 |
+#SBATCH -p gr19999b |
|
300 |
+#SBATCH -t 2:0:0 |
|
301 |
+#SBATCH --rsc p=12:t=4:c=4:m=3G |
|
302 |
+#SBATCH -o %x.%j.out |
|
303 |
+#============ Shell Script ============ |
|
304 |
+srun --multi-prog multiprocess.conf |
|
305 |
+``` |
|
306 |
+ |
|
307 |
+* Specify the queue with the -p option. |
|
308 |
+* Specify the resource to be used with the --rsc option as follows. |
|
309 |
+ * The argument p is the number of processes to be used. |
|
310 |
+ * Specify the number of programs you want to execute concurrently.(If you want to execute 3 MPI programs that use 4 processes concurrently, specify 12 from 4 x 3) |
|
311 |
+ * The argument c is the number of cores to be used per process (program) . |
|
312 |
+ * The program is a 4-thread execution, so specify 4. |
|
313 |
+ * The argument t is the number of threads to be used per process (program) used. |
|
314 |
+ * The program is a 4-thread execution, so specify 4. |
|
315 |
+ * The argument m is the amount of memory per process (program) to be used. |
|
316 |
+* The srun command is specified with the following options. |
|
317 |
+ * In the multi-prog, enter the path to the configuration file (multiprocess.conf) describing the execution of the MPI program to be created below. |
|
318 |
+ |
|
319 |
+** configuration file(multiprocess.conf) ** |
|
320 |
+ |
|
321 |
+```nohighlight |
|
322 |
+## Execute as a 4-process MPI program |
|
323 |
+0-3 ./aaa.out |
|
324 |
+4-7 ./bbb.out |
|
325 |
+8-11 ./ccc.out |
|
326 |
+``` |
|
327 |
+ |
|
328 |
+* In the first column, enter the range of process ID used by the MPI program. (Note that process ID must begin with zero.) |
|
329 |
+* In the second column, enter the path (absolute path or relative path) of the MPI program to be executed with the process ID specified in the first column. |
|
330 |
+ |
|
331 |
+The number of processes used can be changed for each MPI program. |
|
332 |
+For example, if you want the program a1.out to use 4 processes and a2.out to use 8 processes, |
|
333 |
+you can create the following configuration file. |
|
334 |
+However, the number of cores, threads, and memory per process are automatically set to the values specified by the --rsc option, so they cannot be customized for each MPI program. |
|
335 |
+ |
|
336 |
+```nohighlight |
|
337 |
+## Execute as a 4-process MPI program |
|
338 |
+0-3 ./aaa.out |
|
339 |
+## Execute as a 8-process MPI program |
|
340 |
+4-11 ./bbb.out |
|
341 |
+``` |
... | ... |
@@ -176,8 +176,9 @@ srun ./a.out ${SLURM_ARRAY_TASK_ID}.data |
176 | 176 |
1つのジョブの中で、複数のプログラムを同時に実行させることによって、計算資源を有効に利用することができます。 |
177 | 177 |
複数のプログラムを1つのジョブとして同時に実行させるためには、シェルスクリプト中に複数の実行コマンドを記載し、そのシェルスクリプトを実行するようにします。 |
178 | 178 |
|
179 |
-※本手法の対象は、逐次プログラムもしくはOpenMPや自動並列化機能でスレッド並列化したプログラムです。 |
|
180 |
-※複数のMPIプログラムを1つのジョブとして同時に実行させることはできません。 |
|
179 |
+※本手法の対象は、逐次プログラムもしくはOpenMPや自動並列化機能でスレッド並列化したプログラムです。<br> |
|
180 |
+※複数のMPIプログラムを1つのジョブとして同時に実行する場合は、[複数のプログラムを同時に実行する方法(MPMD)](#mpmd)を |
|
181 |
+ご参照下さい。 |
|
181 | 182 |
|
182 | 183 |
各スクリプトの例を以下に記します。 |
183 | 184 |
|
... | ... |
@@ -294,3 +295,63 @@ case $SLURM_PROCID in |
294 | 295 |
|
295 | 296 |
esac |
296 | 297 |
``` |
298 |
+ |
|
299 |
+## 複数のプログラムを同時に実行する方法(MPMD){#mpmd} |
|
300 |
+ |
|
301 |
+** sbatchコマンドで実行するジョブスクリプト(MPI) ** |
|
302 |
+ |
|
303 |
+※下記のスクリプトは、4プロセスを必要とするMPIプログラム(1プロセスあたり4コア、4スレッド)を |
|
304 |
+3つ同時に実行する場合のサンプルです。 |
|
305 |
+ |
|
306 |
+```nohighlight |
|
307 |
+#!/bin/bash |
|
308 |
+#============ SBATCH Directives ======= |
|
309 |
+#SBATCH -p gr19999b |
|
310 |
+#SBATCH -t 2:0:0 |
|
311 |
+#SBATCH --rsc p=12:t=4:c=4:m=3G |
|
312 |
+#SBATCH -o %x.%j.out |
|
313 |
+#============ Shell Script ============ |
|
314 |
+srun --multi-prog ./multiprocess.conf |
|
315 |
+``` |
|
316 |
+ |
|
317 |
+* キューを -p オプションで指定します。 |
|
318 |
+* 使用するリソースを --rsc オプションで下記の通り指定します。 |
|
319 |
+ * 引数pには使用するプロセス数。 |
|
320 |
+ * 同時に実行したいプロセス数の合計(4プロセスを使用するMPIプログラムを3つ同時に実行したい場合は、4×3から12を指定) |
|
321 |
+ * 引数cには利用するプロセス(プログラム)あたりに使用するコア数。 |
|
322 |
+ * プログラムは4スレッド実行ですので、4を指定します。 |
|
323 |
+ * 引数tには利用するプロセス(プログラム)あたりに使用するスレッド数。 |
|
324 |
+ * プログラムは4スレッド実行ですので、4を指定します。 |
|
325 |
+ * 引数mには利用するメモリのプロセス(プログラム)辺りの容量。 |
|
326 |
+* srunコマンドには以下のオプションを指定します。 |
|
327 |
+<!-- |
|
328 |
+ * -n には同時に実行したいプロセス数の合計を記載。$SLURM_DPC_NPROCSという環境変数を記載することで --rscオプションで指定したプロセス数を読み出すことができますので、基本的には変更不要。 |
|
329 |
+ * -c には利用するプロセス(プログラム)あたりに使用するコア数を記載。$SLURM_DPC_CPUSという環境変数を記載することで --rscオプションで指定したコア数を読み出すことができますので、基本的には変更不要。 |
|
330 |
+--> |
|
331 |
+ * --multi-prog には以下で作成するMPIプログラムの実行に関する内容を記述した設定ファイル(multiprocess.conf)へのパスを記載。 |
|
332 |
+ |
|
333 |
+ |
|
334 |
+** 設定ファイル(multiprocess.conf) ** |
|
335 |
+ |
|
336 |
+```nohighlight |
|
337 |
+## 4プロセスを使用してMPIプログラムを実行 |
|
338 |
+0-3 ./aaa.out |
|
339 |
+4-7 ./bbb.out |
|
340 |
+8-11 ./ccc.out |
|
341 |
+``` |
|
342 |
+ |
|
343 |
+* 1列目には、MPIプログラムが使用するプロセスIDのレンジを記載して下さい。(プロセスIDは、0始まりであることに注意) |
|
344 |
+* 2列目には、1列目で指定したプロセスIDで実行するMPIプログラムのパス(絶対パス、相対パスの何れにも対応)を記載して下さい。 |
|
345 |
+ |
|
346 |
+なお、使用するプロセス数はMPIプログラムごとに変更することができます。 |
|
347 |
+例えば、a1.outというプログラムでは4プロセスを使用し、a2.outというプログラムでは8プロセスを使用したいと |
|
348 |
+いった場合は、以下のような設定ファイルを作成することで実現することが可能です。 |
|
349 |
+ただし、1プロセスあたりのコア数、スレッド数、メモリ量については、--rscオプションで指定した値が自動的に |
|
350 |
+設定されるため、MPIプログラムごとにカスタマイズをすることはできません。 |
|
351 |
+ |
|
352 |
+```nohighlight |
|
353 |
+## 4プロセスを使用してMPIプログラムを実行 |
|
354 |
+0-3 ./aaa.out |
|
355 |
+## 8プロセスを使用してMPIプログラムを実行 |
|
356 |
+4-11 ./bbb.out |
|
357 |
+``` |
... | ... |
@@ -88,35 +88,35 @@ Intel MPI のコンパイラでは、 [Intelコンパイラのオプション](/ |
88 | 88 |
-static_mpi | MPIライブラリを静的にリンクします。 |
89 | 89 |
--> |
90 | 90 |
|
91 |
-### 実行{#exec} |
|
91 |
+### 実行方法{#exec} |
|
92 | 92 |
|
93 |
-コンパイルしたMPIプログラムを実行するためには、 会話型処理では **tssrun** コマンドを、バッチ処理では **srun** コマンドを使用します。会話型実行、バッチ実行ともに、並列数は --rsc オプションの引数 p で指定します。詳細は、 [サンプル](#sample) をご覧ください。 |
|
93 |
+コンパイルしたMPIプログラムを実行するためには、 会話型処理またはバッチ処理を利用し、計算ノード上でプログラムを起動する必要があります。 |
|
94 |
+詳細は、 [プログラム実行例](#sample) をご覧ください。 |
|
94 | 95 |
|
95 |
-**実行例(会話型)** |
|
96 |
-```nohighlight |
|
97 |
-$ tssrun --rsc p=2 ./a.out |
|
98 |
-``` |
|
99 | 96 |
|
100 |
-## サンプル{#sample} |
|
101 |
-### 会話型でのMPIプログラム実行{#tss} |
|
102 |
-会話型実行の詳細については、 [会話型処理](/run/interactive) のページをご覧ください。 |
|
97 |
+## プログラム実行例{#sample} |
|
98 |
+ |
|
99 |
+### 会話型処理の実行例{#tss} |
|
100 |
+会話型処理は ** tssrun ** コマンドを使用することで簡易に実行可能です。--rsc オプションにより、確保するリソース量を調整することが可能です。 |
|
101 |
+tssrunコマンドの詳細については、 [会話型処理](/run/interactive) のページをご覧ください。 |
|
103 | 102 |
|
104 |
-* **8並列で実行** |
|
103 |
+** MPIプログラムを8プロセスで実行する場合 ** |
|
105 | 104 |
|
106 | 105 |
```nohighlight |
107 | 106 |
$ tssrun --rsc p=8 ./a.out |
108 | 107 |
``` |
109 | 108 |
|
110 |
-* **スレッド並列と組み合わせて実行(MPI 4並列、OpenMP 8並列)** |
|
109 |
+** ハイブリッド並列の場合(MPI 4プロセス、OpenMP 8スレッド) ** |
|
111 | 110 |
|
112 | 111 |
```nohighlight |
113 | 112 |
$ tssrun --rsc p=4:t=8:c=8 ./a.out |
114 | 113 |
``` |
115 | 114 |
|
116 |
-### バッチでのMPIプログラム実行{#slurm} |
|
117 |
-バッチ実行の詳細については、 [バッチ処理](/run/batch) のページをご覧ください。 |
|
115 |
+### バッチ処理の実行例{#slurm} |
|
116 |
+バッチ処理は、Slurmのオプションと処理内容を記載したジョブスクリプトを用意し、sbatchコマンドで処理を依頼する必要があります。 |
|
117 |
+以下に例を示しますが、オプション等の詳細については、 [バッチ処理](/run/batch) のページをご覧ください。 |
|
118 | 118 |
|
119 |
-* **8並列で実行** |
|
119 |
+** MPIプログラムを8プロセスで実行する場合** |
|
120 | 120 |
|
121 | 121 |
```nohighlight |
122 | 122 |
$ cat sample.sh |
... | ... |
@@ -132,7 +132,7 @@ srun ./a.out |
132 | 132 |
$ sbatch sample.sh |
133 | 133 |
``` |
134 | 134 |
|
135 |
-* **スレッド並列と組み合わせて実行(MPI 4並列、OpenMP 8並列)** |
|
135 |
+** ハイブリッド並列の場合(MPI 4プロセス、OpenMP 8スレッド) ** |
|
136 | 136 |
|
137 | 137 |
```nohighlight |
138 | 138 |
$ cat sample.sh |
... | ... |
@@ -44,19 +44,85 @@ astunparse 1.6.3 |
44 | 44 |
|
45 | 45 |
| Python | 対象システム| 種別 | パッケージ | バージョン | ライブラリ | モジュールファイル | 補足事項 |
46 | 46 |
|--- |--- |--- | --- | --- | --- | --- | --- |
47 |
-| python3.8 | A/B/C | CPU | TensorFlow | 2.11.0 | MKL 2022.3 | tensorflow/2.11.0.py38_intel-2022.3 | Intel Optimized AVX512版 |
|
48 |
-| python3.8 | A/B/C | CPU | MXNet | 1.6.0 | MKL 2022.3 | mxnet/1.6.0.py38_intel-2022.3 | MKL対応版 |
|
49 |
-| python3.8 | A/B/C | CPU | PyTorch | 2.0.1 | MKL 2022.3 | pytorch/2.0.1.py38_intel-2022.3 | intel extension for pytorch あり |
|
50 |
-| python3.8 | A/B/C | CPU | PyTorch | 1.13.1 | MKL 2022.3 | pytorch/1.13.1.py38_intel-2022.3 | intel extension for pytorch あり |
|
47 |
+| python3.8 | A/B/C | CPU | TensorFlow | 2.11.0 | MKL 2022.3 | tensorflow/2.11.0.py38_intel-2022.3 | Intel Optimized AVX512版 |
|
48 |
+| python3.8 | A/B/C | CPU | MXNet | 1.6.0 | MKL 2022.3 | mxnet/1.6.0.py38_intel-2022.3 | MKL対応版 |
|
49 |
+| python3.8 | A/B/C | CPU | PyTorch | 2.0.1 | MKL 2022.3 | pytorch/2.0.1.py38_intel-2022.3 | intel extension for pytorch, Intel oneCCL Bindings for Pytorch |
|
50 |
+| python3.8 | A/B/C | CPU | PyTorch | 1.13.1 | MKL 2022.3 | pytorch/1.13.1.py38_intel-2022.3 | intel extension for pytorch, Intel oneCCL Bindings for Pytorch |
|
51 | 51 |
| python3.8 | G | GPU | TensorFlow | 2.11.0 | CUDA 11.2 | tensorflow/2.11.0.py38_cuda-11.2 | GPU版 TensorRT利用可 |
52 | 52 |
| python3.8 | G | GPU | MXNet | 1.9.1 | CUDA 11.7 | mxnet/1.9.1.py38_cuda-11.7 | GPU版 |
53 | 53 |
| python3.8 | G | GPU | PyTorch | 1.13.1 | CUDA 11.7 | pytorch/1.13.1.py38_cuda-11.7 | GPU版 |
54 | 54 |
|
55 | 55 |
|
56 |
-#### Intel Extension for PyTorch |
|
56 |
+#### Intel Extension for PyTorch の参考資料 |
|
57 | 57 |
* [Documentation](https://intel.github.io/intel-extension-for-pytorch/cpu/latest/index.html) |
58 | 58 |
* [Examples](https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/examples.html) |
59 | 59 |
|
60 |
+#### システムA/B/C 向けの pytorch に関する補足 |
|
61 |
+ |
|
62 |
+システムA/B/C 向けの pytorch は、Intel Extension for Pytorch は Intel oneCCL Bindings for Pytorch を利用します。 |
|
63 |
+以下にサンプルプログラムと、ジョブスクリプトを例を記載していますので、参考にしてください。 |
|
64 |
+各ソフトウェアの使い方の詳細は公式マニュアルをご参照ください。 |
|
65 |
+ |
|
66 |
+##### サンプルプログラム |
|
67 |
+ |
|
68 |
+```python |
|
69 |
+#!/usr/bin/python3.8 |
|
70 |
+ |
|
71 |
+# Reference source |
|
72 |
+# https://github.com/intel/torch-ccl#usage |
|
73 |
+ |
|
74 |
+import os |
|
75 |
+import torch.nn.parallel |
|
76 |
+import torch.distributed as dist |
|
77 |
+import oneccl_bindings_for_pytorch |
|
78 |
+import intel_extension_for_pytorch |
|
79 |
+ |
|
80 |
+os.environ['MASTER_ADDR'] = str(os.environ.get('TORCH_MASTER_ADDR', '127.0.0.1')) |
|
81 |
+os.environ['MASTER_PORT'] = str(os.environ.get('TORCH_MASTER_PORT', '29500')) |
|
82 |
+os.environ['RANK'] = str(os.environ.get('PMI_RANK', 0)) |
|
83 |
+os.environ['WORLD_SIZE'] = str(os.environ.get('PMI_SIZE', 1)) |
|
84 |
+ |
|
85 |
+backend = 'ccl' |
|
86 |
+dist.init_process_group(backend) |
|
87 |
+my_rank = dist.get_rank() |
|
88 |
+my_size = dist.get_world_size() |
|
89 |
+print("my rank = %d my size = %d" % (my_rank, my_size)) |
|
90 |
+ |
|
91 |
+x = torch.ones([2, 2]) |
|
92 |
+y = torch.ones([4, 4]) |
|
93 |
+with torch.autograd.profiler.profile(record_shapes=True) as prof: |
|
94 |
+ for _ in range(10): |
|
95 |
+ dist.all_reduce(x) |
|
96 |
+ dist.all_reduce(y) |
|
97 |
+dist.barrier() |
|
98 |
+print(prof.key_averages(group_by_input_shape=True).table(sort_by="self_cpu_time_total")) |
|
99 |
+``` |
|
100 |
+ |
|
101 |
+##### ジョブスクリプト |
|
102 |
+ |
|
103 |
+```bash |
|
104 |
+#!/bin/bash |
|
105 |
+#============ SBATCH Directives ======= |
|
106 |
+#SBATCH -p gr10001b |
|
107 |
+#SBATCH -t 1:0:0 |
|
108 |
+#SBATCH --rsc p=4:t=1:c=1 |
|
109 |
+#SBATCH -o %x.%A.out |
|
110 |
+ |
|
111 |
+#============ Shell Script ============ |
|
112 |
+ |
|
113 |
+. /usr/share/Modules/init/bash |
|
114 |
+module load pytorch/2.0.1.py38_intel-2022.3 |
|
115 |
+module list |
|
116 |
+ |
|
117 |
+set -x |
|
118 |
+ |
|
119 |
+export CCL_WORKER_COUNT=${OMP_NUM_THREADS} |
|
120 |
+export CCL_WORKER_AFFINITY=$(numactl -s |grep physcpubind: | sed -e 's/physcpubind: //' -e 's/ *$//' -e 's/ /,/g') |
|
121 |
+export TORCH_MASTER_ADDR=${SLURMD_NODENAME}-ib0 |
|
122 |
+ |
|
123 |
+srun python3.8 -u profiling.py |
|
124 |
+``` |
|
125 |
+ |
|
60 | 126 |
## ANACONDA DISTRIBUTION |
61 | 127 |
|
62 | 128 |
Pythonのパッケージ群が利用可能なANACONDA DISTRIBUTION をインストールしています。 |
... | ... |
@@ -221,13 +221,10 @@ $ tssrun ansys222 [options] -i input-file > output-file |
221 | 221 |
バッチジョブで実行するためには、バッチファイルを用意する必要があります。 |
222 | 222 |
スクリプト内でコマンドラインで実行するのと同様にコマンドを記述し、sbatch コマンドでジョブを投入します。 |
223 | 223 |
|
224 |
-ansysの実行コマンドは、コマンドの内部で mpiexec を自動で呼び出すので、srun コマンドは不要です。 |
|
225 |
- |
|
226 |
- |
|
227 | 224 |
#### ジョブスクリプトの例1: SMP |
228 | 225 |
```nohighlight |
229 | 226 |
#!/bin/bash |
230 |
-#============ LSF Options ============ |
|
227 |
+#============ Slurm Options ============ |
|
231 | 228 |
#SBATCH -q gr19999b |
232 | 229 |
#SBATCH -t 1:00:00 |
233 | 230 |
#SBATCH --rsc p=1:t=4:c=4 |
... | ... |
@@ -235,13 +232,14 @@ ansysの実行コマンドは、コマンドの内部で mpiexec を自動で呼 |
235 | 232 |
module load ansysmcfd/2022R2 |
236 | 233 |
ansys222 -j test_${SLURM_JOBID} -b -smp -np ${SLURM_DPC_THREADS} -i test.dat |
237 | 234 |
``` |
235 |
+※ ANSYSの実行コマンドは、コマンドの内部で mpiexec を自動で呼び出すので、srun コマンドは不要です。<br> |
|
238 | 236 |
※ ANSYSのバージョンにより実行コマンド名の語尾(バージョン番号)が異なります。 |
239 | 237 |
|
240 | 238 |
|
241 | 239 |
#### ジョブスクリプトの例2: MPI |
242 | 240 |
```nohighlight |
243 | 241 |
#!/bin/bash |
244 |
-#============ LSF Options ============ |
|
242 |
+#============ Slurm Options ============ |
|
245 | 243 |
#SBATCH -q gr19999b |
246 | 244 |
#SBATCH -t 1:00:00 |
247 | 245 |
#SBATCH --rsc p=4:t=1:c=1 |
... | ... |
@@ -249,10 +247,22 @@ ansys222 -j test_${SLURM_JOBID} -b -smp -np ${SLURM_DPC_THREADS} -i test.dat |
249 | 247 |
module load ansys |
250 | 248 |
ansys222 -j test_${SLURM_JOBID} -b -dis -np ${SLURM_DPC_NPROCS} -i test.dat |
251 | 249 |
``` |
250 |
+※ ANSYSの実行コマンドは、コマンドの内部で mpiexec を自動で呼び出すので、srun コマンドは不要です。<br> |
|
252 | 251 |
※ ANSYSのバージョンにより実行コマンド名の語尾(バージョン番号)が異なります。 |
253 | 252 |
|
253 |
+#### ジョブスクリプトの例3: ANSYS Fluent |
|
254 |
+処理リスト化したファイル(journal.jou)を用意し、3dの倍精度ソルバーで解析を実行する例です。 |
|
255 |
+```nohighlight |
|
256 |
+#!/bin/bash |
|
257 |
+#============ Slurm Options ============ |
|
258 |
+#SBATCH -q gr19999b |
|
259 |
+#SBATCH -t 1:00:00 |
|
260 |
+#SBATCH --rsc p=1:t=4:c=4 |
|
261 |
+#============ Shell Script ============ |
|
262 |
+module load ansysmcfd/2022R2 |
|
254 | 263 |
|
255 |
- |
|
264 |
+srun fluent -g 3ddp -i journal.jou |
|
265 |
+``` |
|
256 | 266 |
|
257 | 267 |
## 参考資料{#references} |
258 | 268 |
|