NYCU CSIT HPC service
Access login node
ssh <username>@hpclogin[01-05].cs.nycu.edu.tw
Setup environment
Note
若課程有任何軟體需求,請助教來信告知
若有先告知課程軟體需求,會根據需求產生對應套件環境,命名規則為/shared/manifest/guix/profile/<course name>-env
Example
以"平行程式設計"課程作範例
有兩種選擇,第一種是 profile 設定
- Add following lines to
~/.bashrc
GUIX_PROFILE="/shared/manifest/guix/profile/pp-env"
if test -f $GUIX_PROFILE/etc/profile; then
. "$GUIX_PROFILE/etc/profile"
fi
第二種則是另開環境
-
guix shell -p /shared/manifest/guix/profile/pp-env
若要離開環境只要下exit
即可
Submit job
Caution
- 無法直接使用
srun
指令是正常的,請使用sbatch
指令用腳本發送 job- 須確保程式中讀寫的檔案以及程式本身在 NFS 中,否則會執行異常或看不到結果
To simply put, just prepare your script, then use sbatch <script name>.sh
to submit job
Examples
Submit a MPI job
- 準備好程式
-
mpi.cpp
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
MPI_Init(NULL, NULL);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);
printf("Hello world from processor %s, rank %d out of %d processors\n",
processor_name, world_rank, world_size);
MPI_Finalize();
}
- 在 Login node 上編譯
user@login01:~$ mpic++ mpi.cpp
- 準備好 sbatch script,在 Login node 上發 job
user@login01:~$ sbatch test.sh
-
test.sh
#!/bin/sh
#SBATCH -A general # Account name (可透過 sshare 查看)
#SBATCH -p class_nodes # Partition name (可透過 sinfo 查看 partition)
#SBATCH -n 3 # Number of MPI tasks (i.e. processes)
#SBATCH -c 1 # Number of cores per MPI task
#SBATCH -N 3 # Maximum number of nodes to be allocated
#SBATCH -t 00:05:00 # (--time) Wall time limit (days-hrs:min:sec)
# 還有很多其他參數,可參考官方文件(https://slurm.schedmd.com/sbatch.html)
export PMIX_MCA_psec="^munge"
srun --mpi=pmix ./a.out
-
可以透過
squeue
查看 job 排隊/運行狀況,或是用sacct
查看以往的 job (包含剛剛發出的) -
完成後,可以在家目錄看到
slurm-<job id>.out
的文字檔,可以直接查看結果
user@login01:~$ cat slurm-74.out
Hello world from processor cmpt001.hpc.cc.cs.nctu.edu.tw, rank 0 out of 3 processors
Hello world from processor cmpt002.hpc.cc.cs.nctu.edu.tw, rank 1 out of 3 processors
Hello world from processor cmpt003.hpc.cc.cs.nctu.edu.tw, rank 2 out of 3 processors
Submit a job using GPU
Take cuda-samples for example.
-
Prepare your code
user@login01:~$ git clone https://github.com/NVIDIA/cuda-samples.git
-
Compile it
cd cuda-samples/Samples/1_Utilities/deviceQuery && make
-
Prepare sbatch script
test.sh
#!/bin/sh
#SBATCH -A general # Account name (可透過 sshare 查看)
#SBATCH -p class_nodes # Partition name (可透過 sinfo 查看 partition)
#SBATCH -N 1 # Maximum number of nodes to be allocated
#SBATCH --gres=gpu:1 # specify GPU number
# 還有很多其他參數,可參考官方文件(https://slurm.schedmd.com/sbatch.html)
export LD_LIBRARY_PATH=/gnu/driver${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
./deviceQuery
- 透過
sbatch
發送 job
user@login01:~/cuda-samples/Samples/1_Utilities/deviceQuery$ sbatch test.sh
之後一樣會在當前目錄看到 slurm-<job id>.out
的文字檔,可以直接查看結果
其他注意事項
請不要在要發的 sbatch script 中下需要 prompt 或是會一直 hang 在那直到退出的指令,像是 gdb
, top
等等,不但無法看到結果,也會無意義地佔據資源,若不小心下了,可以參考底下 Cancel job 進行處理。
Cancel job
為避免一個使用者發出大量 job 佔據大多資源,所以有限制一個使用者同時就只能發一個 job。若上個 job 發錯,想要發新的 job 就需要 cancel 上個 job
scancel -u <your username>