다중 대기열 모드 클러스터에서 작업 실행 - AWS ParallelCluster

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

다중 대기열 모드 클러스터에서 작업 실행

이 자습서에서는 다중 대기열 모드로 AWS ParallelCluster에서 첫 번째 "Hello World" 작업을 실행하는 방법을 다룹니다.

AWS ParallelCluster 명령줄 인터페이스(CLI) 또는 API를 사용하는 경우 AWS ParallelCluster 이미지 및 클러스터를 생성하거나 업데이트할 때 생성된 AWS 리소스에 대한 비용만 지불하면 됩니다. 자세한 내용은 AWS ParallelCluster가 사용하는 AWS 서비스 항목을 참조하세요.

AWS ParallelCluster UI는 서버리스 아키텍처를 기반으로 하며 대부분의 경우 AWS 프리 티어 범주 내에서 사용할 수 있습니다. 자세한 내용은 AWS ParallelCluster UI 비용 항목을 참조하세요.

사전 조건

클러스터 구성

AWS ParallelCluster가 제대로 설치되었는지 확인하려면 다음 명령을 실행합니다.

$ pcluster version

pcluster version에 대한 자세한 내용은 pcluster version 섹션을 참조하세요.

이 명령은 실행 중인 AWS ParallelCluster의 버전을 반환합니다.

다음으로 pcluster configure를 실행하여 기본 구성 파일을 생성합니다. 이 명령 다음에 나오는 모든 메시지를 따릅니다.

$ pcluster configure --config multi-queue-mode.yaml

pcluster configure 명령에 대한 자세한 내용은 pcluster configure 섹션을 참조하세요.

이 단계를 완료한 후에는 multi-queue-mode.yaml이라는 기본 구성 파일이 나타납니다. 이 파일에는 기본 클러스터 구성이 들어 있습니다.

다음 단계에서는 새 구성 파일을 수정하고 대기열이 여러 개 있는 클러스터를 시작합니다.

참고

이 자습서에서 사용된 일부 인스턴스는 프리 티어에 사용할 수 없습니다.

이 자습서에서는 다음 구성과 일치하도록 구성 파일을 수정하세요. 빨간색으로 강조 표시된 항목은 구성 파일 값을 나타냅니다. 자신의 고유한 값을 유지하세요.

Region: region-id Image: Os: alinux2 HeadNode: InstanceType: c5.xlarge Networking: SubnetId: subnet-abcdef01234567890 Ssh: KeyName: yourkeypair Scheduling: Scheduler: slurm SlurmQueues: - Name: spot ComputeResources: - Name: c5xlarge InstanceType: c5.xlarge MinCount: 1 MaxCount: 10 - Name: t2micro InstanceType: t2.micro MinCount: 1 MaxCount: 10 Networking: SubnetIds: - subnet-abcdef01234567890 - Name: ondemand ComputeResources: - Name: c52xlarge InstanceType: c5.2xlarge MinCount: 0 MaxCount: 10 Networking: SubnetIds: - subnet-021345abcdef6789

클러스터 생성

구성 파일을 기반으로 multi-queue-cluster라는 이름이 지정된 클러스터를 만드세요.

$ pcluster create-cluster --cluster-name multi-queue-cluster --cluster-configuration multi-queue-mode.yaml { "cluster": { "clusterName": "multi-queue-cluster", "cloudformationStackStatus": "CREATE_IN_PROGRESS", "cloudformationStackArn": "arn:aws:cloudformation:eu-west-1:123456789012:stack/multi-queue-cluster/1234567-abcd-0123-def0-abcdef0123456", "region": "eu-west-1", "version": "3.7.0", "clusterStatus": "CREATE_IN_PROGRESS" } }

pcluster create-cluster 명령에 대한 자세한 내용은 pcluster create-cluster 섹션을 참조하세요.

다음 명령을 실행하여 클러스터 상태를 확인합니다.

$ pcluster list-clusters { "cluster": { "clusterName": "multi-queue-cluster", "cloudformationStackStatus": "CREATE_IN_PROGRESS", "cloudformationStackArn": "arn:aws:cloudformation:eu-west-1:123456789012:stack/multi-queue-cluster/1234567-abcd-0123-def0-abcdef0123456", "region": "eu-west-1", "version": "3.7.0", "clusterStatus": "CREATE_IN_PROGRESS" } }

클러스터가 생성되면 clusterStatus 필드가 CREATE_COMPLETE를 표시합니다.

헤드 노드에 로그인

프라이빗 SSH 키 파일을 사용하여 헤드 노드에 로그인합니다.

$ pcluster ssh --cluster-name multi-queue-cluster -i ~/path/to/yourkeyfile.pem

pcluster ssh에 대한 자세한 정보는 pcluster ssh 섹션을 참조하세요.

로그인되면 sinfo 명령을 실행하여 스케줄러 대기열이 설정 및 구성되어 있는지 확인합니다.

sinfo에 대한 자세한 내용은 Slurm 설명서에서 sinfo 섹션을 참조하세요.

$ sinfo PARTITION AVAIL TIMELIMIT NODES STATE NODELIST spot* up infinite 18 idle~ spot-dy-c5xlarge-[1-9],spot-dy-t2micro-[1-9] spot* up infinite 2 idle spot-st-c5xlarge-1,spot-st-t2micro-1 ondemand up infinite 10 idle~ ondemand-dy-c52xlarge-[1-10]

출력에는 클러스터에서 사용할 수 있는 idle 상태에 t2.micro 하나 및 c5.xlarge 컴퓨팅 노드 하나가 있는 것으로 표시됩니다.

다른 노드는 모두 절전 상태이며, 노드 상태에서는 ~ 접미사로 표시되며, 이를 뒷받침하는 EC2 인스턴스가 없습니다. 기본 대기열은 대기열 이름 뒤에 * 접미사로 표시됩니다. spot은 기본 작업 대기열입니다.

다중 대기열 모드에서 작업 실행

그런 다음 작업을 실행하여 잠시 휴면 모드로 전환해 보세요. 작업은 나중에 자체 호스트 이름을 출력합니다. 현재 사용자가 이 스크립트를 실행할 수 있는지 확인하세요.

$ tee <<EOF hellojob.sh #!/bin/bash sleep 30 echo "Hello World from \$(hostname)" EOF $ chmod +x hellojob.sh $ ls -l hellojob.sh -rwxrwxr-x 1 ec2-user ec2-user 57 Sep 23 21:57 hellojob.sh

sbatch 명령을 사용하여 작업을 제출합니다. -N 2 옵션으로 이 작업의 노드 두 개를 요청하고 작업이 성공적으로 제출되는지 확인합니다. sbatch에 대한 자세한 내용은 Slurm 설명서에서 sbatch 섹션을 참조하세요.

$ sbatch -N 2 --wrap "srun hellojob.sh" Submitted batch job 1

squeue 명령으로 대기열을 보고 작업 상태를 확인할 수 있습니다. 단, 특정 대기열을 지정하지 않았으므로 기본 대기열(spot)이 사용됩니다. squeue에 대한 자세한 내용은 Slurm 설명서에서 squeue 섹션을 참조하세요.

$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 1 spot wrap ec2-user R 0:10 2 spot-st-c5xlarge-1,spot-st-t2micro-1

출력을 통해 작업이 현재 실행 중 상태인 것을 알 수 있습니다. 작업을 마칠 때까지 기다리세요. 이 작업에는 약 30초 정도 걸립니다. 그런 다음 squeue를 다시 실행하세요.

$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)

이제 대기열의 작업이 모두 완료되었으니 현재 디렉터리에서 slurm-1.out이라는 이름의 출력 파일을 찾아보세요.

$ cat slurm-1.out Hello World from spot-st-t2micro-1 Hello World from spot-st-c5xlarge-1

출력을 통해 spot-st-t2micro-1spot-st-c5xlarge-1 노드에서 작업이 성공적으로 실행되었음을 알 수 있습니다.

이제 다음 명령으로 특정 인스턴스에 대한 제약 조건을 지정하여 동일한 작업을 제출하세요.

$ sbatch -N 3 -p spot -C "[c5.xlarge*1&t2.micro*2]" --wrap "srun hellojob.sh" Submitted batch job 2

이 파라미터를 sbatch에 사용했습니다.

  • -N 3- 세 개의 노드를 요청합니다.

  • -p spot- 작업을 spot 대기열에 제출합니다. -p ondemand를 지정하여 작업을 ondemand 대기열에 제출할 수도 있습니다.

  • -C "[c5.xlarge*1&t2.micro*2]"– 이 작업에 대한 특정 노드 제약 조건을 지정합니다. 이것은 이 작업에 사용할 c5.xlarge 노드 1개와 t2.micro 노드 2개를 요청합니다.

sinfo 명령을 실행하여 노드와 대기열을 확인합니다. AWS ParallelCluster에 있는 대기열은 Slurm의 파티션이라고 합니다.

$ sinfo PARTITION AVAIL TIMELIMIT NODES STATE NODELIST spot* up infinite 1 alloc# spot-dy-t2micro-1 spot* up infinite 17 idle~ spot-dy-c5xlarge-[2-10],spot-dy-t2micro-[2-9] spot* up infinite 1 mix spot-st-c5xlarge-1 spot* up infinite 1 alloc spot-st-t2micro-1 ondemand up infinite 10 idle~ ondemand-dy-c52xlarge-[1-10]

노드에 전원이 공급되고 있습니다. 이는 노드 상태에 # 접미사가 붙는 것으로 표시됩니다. squeue 명령을 실행하여 클러스터에서 작업에 대한 정보를 봅니다.

$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 2 spot wrap ec2-user CF 0:04 3 spot-dy-c5xlarge-1,spot-dy-t2micro-1,spot-st-t2micro-1

작업은 CF(CONFIGURING) 상태이며, 인스턴스가 스케일 업되어 클러스터에 합류하기를 기다리고 있습니다.

약 3분 후에 노드를 사용할 수 있고 작업이 R(RUNNING) 상태로 전환됩니다.

$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 2 spot wrap ec2-user R 0:07 3 spot-dy-t2micro-1,spot-st-c5xlarge-1,spot-st-t2micro-1

작업이 완료되어 세 노드 모두 idle 상태입니다.

$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) $ sinfo PARTITION AVAIL TIMELIMIT NODES STATE NODELIST spot* up infinite 17 idle~ spot-dy-c5xlarge-[1-9],spot-dy-t2micro-[2-9] spot* up infinite 3 idle spot-dy-t2micro-1,spot-st-c5xlarge-1,spot-st-t2micro-1 ondemand up infinite 10 idle~ ondemand-dy-c52xlarge-[1-10]

그런 다음 대기열에 작업이 남아 있지 않으면 로컬 디렉토리에서 slurm-2.out을 확인하세요.

$ cat slurm-2.out Hello World from spot-st-t2micro-1 Hello World from spot-dy-t2micro-1 Hello World from spot-st-c5xlarge-1

클러스터의 최종 상태입니다.

$ sinfo PARTITION AVAIL TIMELIMIT NODES STATE NODELIST spot* up infinite 17 idle~ spot-dy-c5xlarge-[1-9],spot-dy-t2micro-[2-9] spot* up infinite 3 idle spot-dy-t2micro-1,spot-st-c5xlarge-1,spot-st-t2micro-1 ondemand up infinite 10 idle~ ondemand-dy-c52xlarge-[1-10]

클러스터를 로그오프한 후 pcluster delete-cluster를 실행하여 정리할 수 있습니다. 자세한 내용은 pcluster list-clusterspcluster delete-cluster를 참조하세요.

$ pcluster list-clusters { "clusters": [ { "clusterName": "multi-queue-cluster", "cloudformationStackStatus": "CREATE_COMPLETE", "cloudformationStackArn": "arn:aws:cloudformation:eu-west-1:123456789012:stack/multi-queue-cluster/1234567-abcd-0123-def0-abcdef0123456", "region": "eu-west-1", "version": "3.1.4", "clusterStatus": "CREATE_COMPLETE" } ] } $ pcluster delete-cluster -n multi-queue-cluster { "cluster": { "clusterName": "multi-queue-cluster", "cloudformationStackStatus": "DELETE_IN_PROGRESS", "cloudformationStackArn": "arn:aws:cloudformation:eu-west-1:123456789012:stack/multi-queue-cluster/1234567-abcd-0123-def0-abcdef0123456", "region": "eu-west-1", "version": "3.1.4", "clusterStatus": "DELETE_IN_PROGRESS" } }