[AWS] Amazon Kinesis 알아보기

운영중인 서비스가 점차 커진다면 대용량의 실시간 데이터를 수집, 처리 및 분석할 수 있도록 구성해야됩니다. 별도의 데이터 처리 서버를 구성할 수 있겠지만 확장성 및 실시간 모니터링 등 데이터 처리에 필요한 기능을 구현해야 하므로 어려움이 많습니다. AWS에서는 클라우드 기반 데이터 스트리밍 플랫폼인 Amazon Kinesis를 사용하여 대용량의 실시간 데이터를 수집, 처리 및 분석할 수 있습니다.

 

 


주요 기능

Amazon Kinesis의 주요 기능은 크게 4가지로 구성되어 있습니다.

  • Kinesis Video Streams
    • 비디오 스트림 캡처, 처리 및 저장
  • Kinesis Data Streams
    • 데이터 스트림 캡처, 처리 및 저장
  • Kinesis Data Firehose
    • 데이터 스트림 AWS 데이터 스토어로 로드
  • Kinesis Data Analytics
    • SQL 또는 Apache Flink로 데이터 스트림 분석

 

Kinesis Video Streams

Kinesis Video Streams는 동영상 스트림을 쉽게 처리하고 저장하기 위한 기능입니다.
IoT 디바이스나 카메라에서 생성되는 동영상 스트림을 실시간으로 수집하고 처리할 수 있습니다. 또한 동영상 데이터를 압축하고 인코딩하며, 실시간으로 스트리밍하거나 저장할 수 있는 인프라를 제공합니다.

 

 

Kinesis Data Streams

Kinesis Data Streams은 대량의 실시간 데이터 스트림을 처리하고 분석하기 위한 기능입니다.
데이터 스트림은 하나 이상의 샤드로 구성되며, 각 샤드는 데이터의 순서를 보장하고 병렬 처리가 가능합니다. 데이터를 수집한 후 필요한 처리를 수행하거나 다른 AWS 서비스와 연동하여 사용할 수 있습니다.

 

 

Kinesis Data Firehose

Kinesis Data Firehose는 스트림 데이터를 처리하여 다양한 대상으로 전달하는 역할을 합니다.
데이터를 Amazon S3, Amazon Redshift, Amazon Elasticsearch 등과 같은 저장소나 분석 도구로 전달할 수 있습니다. 또한 데이터 전달 과정을 자동으로 관리하므로 개발자는 데이터 전달 파이프라인을 구축하고 관리하는데 시간을 절약할 수 있습니다.

 

 

Kinesis Data Analytics

Kinesis Data Analytics는 SQL 쿼리를 사용하여 스트림 데이터를 실시간으로 분석하는 데 사용됩니다.
데이터 스트림에서 생성된 실시간 데이터를 실시간으로 데이터를 가공하고, 패턴을 발견하며, 실시간 대시보드를 생성할 수 있습니다. 또한 SQL 쿼리를 통해 분석하면서 시각화 및 모니터링에 활용할 수 있습니다.

 

 


장단점

Amazon Kinesis는 강력한 실시간 데이터 스트리밍 및 처리 플랫폼이지만, 사용 시 고려해야 할 장점과 단점이 있습니다.

 

장점

  1. 실시간 데이터 처리: 대량의 실시간 데이터를 처리하고 분석하는데 탁월한 성능을 제공합니다.
  2. 확장성: 데이터 스트림을 여러 샤드로 나누어 처리할 수 있으며, 필요에 따라 확장하여 데이터 처리의 확장성을 보장하면서도 성능을 유지할 수 있습니다.
  3. 다양한 데이터 유형 처리: 웹사이트 로그, 센서 데이터, 애플리케이션 로그 등 다양한 소스의 데이터 유형을 처리할 수 있습니다.
  4. 간편한 데이터 파이프라인 구축: 간편하게 데이터 파이프라인을 쉽게 구축하고, 데이터 변환과 전달을 자동으로 관리하므로 개발자는 데이터 이동에만 집중하면 됩니다.
  5. 실시간 분석 및 모니터링: 실시간으로 데이터를 분석하고 모니터링할 수 있습니다.
  6. 다양한 대상으로의 전달: 데이터를 다양한 AWS 서비스 및 저장소로 전달할 수 있습니다.

 

단점

  1. 복잡성: 대규모 애플리케이션에서는 설정 및 구성 과정이 다소 복잡해질 수 있습니다.
  2. 비용: 데이터 처리량 및 스트림의 크기에 따라 과금되므로, 대규모 데이터 처리 시 비용이 증가할 수 있습니다.
  3. 모니터링 및 디버깅: 대용량 데이터 처리 시 모니터링 및 디버깅이 복잡해질 수 있습니다.
  4. 서비스 의존성: AWS 서비스에 의존성이 높아지므로, AWS 서비스가 불안정한 경우 영향을 받을 수 있습니다.

 

 


비용

Amazon Kinesis의 비용은 사용되는 리소스와 데이터 처리량에 따라 다를 수 있습니다

 

Kinesis Data Streams

데이터 샤드 수: 가장 큰 비용 요소는 데이터 샤드 수입니다. 데이터 샤드 수가 많을수록 비용이 증가합니다.
데이터 샤드 시간당 비용: 각 데이터 샤드당 시간당 비용이 부과됩니다.

 

Kinesis Data Firehose

전송량: 전송된 데이터 양에 따라 비용이 부과됩니다. 데이터 전송량이 많을수록 비용이 증가합니다.
전송 시간당 비용: 데이터 전송 시간당 비용이 부과됩니다.

 

Kinesis Data Analytics

처리량: 처리되는 데이터 양에 따라 비용이 부과됩니다. 처리량이 많을수록 비용이 증가합니다.
처리 시간당 비용: 처리된 시간당 비용이 부과됩니다.

 

 


활용

 

웹 사이트 모니터링 및 분석

모바일 서비스 발전에 따라 모바일에서 어플이나 웹 사이트를 통해 다양한 서비스를 이용하고 있습니다.
어플이나 웹 사이트에서 생성되는 로그 데이터를 수집하고 분석하여 성능, 사용자 동작, 에러 등을 실시간으로 모니터링 및 분석할 수 있습니다. 실시간 대시보드 및 경고 시스템을 구축하여 웹사이트의 상태를 실시간으로 파악하고 개선할 수 있습니다.

 

금융 거래 감지 및 분석

결제, 입출금, 주식 거래 등 실시간으로 많은 수의 금융 거래가 실시간으로 계속 발생되고 있습니다.
금융 거래 데이터를 실시간으로 처리하여 부정 거래나 신용카드 사기 등을 감지할 수 있습니다.
또한 금융 거래의 이상 패턴을 실시간으로 분석하여 신속하게 대응할 수 있습니다.

 

게임 분석

온라인 게임에서는 실시간으로 다른 플레이어들과 상호작용을 하면서 다양한 게임 플레이를 진행합니다.
온라인 게임에서 생성되는 사용자 데이터를 실시간으로 분석하여 게임 플레이, 플레이어 상호작용, 성과 등을 추적하고 게임 개선에 활용할 수 있습니다.

 

 

 

Amazon Kinesis를 통해 대용량의 실시간 데이터를 유연하게 처리해보시기 바랍니다.
지금까지 Amazon Kinesis를 알아보는 시간이었습니다....! 끝...!

 

 

 

[Reference]

 

 

 

[AWS] EC2 Placement 알아보기

EC2(온디맨드, 스팟, 예약) 인스턴스를 실행할 때, 인스턴스들은 물리적으로 AWS의 데이터 센터에 배치(Placement)되어 실행됩니다.


이렇게 AWS의 데이터 센터에 배치되는 위치를 EC2 Placement라고 하며, EC2 Placement에는 가용 영역 (Availability Zone)과 배치 그룹 (Placement Group), 두 가지 주요 요소가 있습니다

 

 


가용 영역 (Availability Zone)

가용 영역(Availability Zone)은 AWS의 데이터 센터가 물리적으로 분리된 지리적 위치입니다.


각 가용 영역은 고유한 전력, 네트워킹 및 연결성을 갖고 있으며, 장애가 발생할 경우 다른 가용 영역은 독립적으로 작동할 수 있습니다. 따라서 가용 영역을 사용하여 고가용성 및 내구성을 보장할 수 있습니다.

 

 


배치 그룹 (Placement Group)

배치 그룹은 동일한 물리적 하드웨어에서 여러 EC2 인스턴스를 실행할 수 있도록 지원하는 것입니다.


배치 그룹을 사용하면 인스턴스 간의 네트워크 지연 시간을 최소화하고 클러스터 컴퓨팅 또는 데이터 간의 고성능 통신을 제공할 수 있습니다. 배치 그룹은 크게 세 가지의 유형을 선택하여 생성할 수 잇습니다.

 

클러스터 배치 그룹(Cluster Placement Group)

클러스터 배치 그룹은 하나의 물리적 호스트에 인스턴스를 모아서 실행되어, 가장 높은 네트워크 성능을 제공합니다.
짧은 네트워크 지연 시간, 높은 네트워크 처리량 또는 둘 다의 이점을 활용할 수 있는 애플리케이션에 권장됩니다.
하지만 특정 가용 영역에 제한되어 물리적 호스트에 장애 발생 시 모든 EC2에 장애가 발생할 수 있어 고가용성은 떨어집니다.

 

 

파티션 배치 그룹(Partition Placement Group)

파티션 배치 그룹은 EC2를 파티션으로 분리하여 여러 물리적 호스트에 분산하여 실행합니다.
배치 그룹 내 파티션이 동일한 랙을 공유해지 않으므로 하드웨어 장애 가능성을 줄이는데 도움이 됩니다.
여러 가용 영역에 걸쳐 고가용성을 제공할 수 있지만 파티션 장애 발생 시 같은 파티션의 EC2에 모두 장애가 발생할 수 있습니다.

 

 

스프레드 배치 그룹(Spread Placement Group)

스프레드 배치 그룹은 인스턴스를 가능한 한 물리적으로 분리된 호스트에 실행하여 가용 영역 및 물리적 하드웨어에서 실패가 발생해도 안정성을 보장합니다.
서로 떨어져 있어야 하는 중요 인스턴스의 수가 적은 애플리케이션에서는 분산형 배치 그룹이 권장됩니다.

 

 


비용

EC2 Placement를 사용하여 EC2 인스턴스를 구성할 때, 추가 비용 없이 인스턴스의 배치를 최적화하여 성능과 가용성을 개선할 수 있습니다.


EC2 Placement는 인스턴스를 배치하는 방법에 대한 설정이며, 이는 인스턴스의 가격이나 인스턴스 자체에 영향을 미치지 않습니다. 비용은 EC2 인스턴스의 유형, 크기, 운영 체제 등과 같은 인스턴스 자체의 속성에 따라 결정됩니다.

 

 


EC2 Placement는 성능, 내구성 및 확장성을 위해 중요한 요소이며, 올바르게 구성하고 관리함으로써 안정적인 인스턴스 운영과 서비스 제공에 도움을 줍니다. 따라서 인스턴스를 실행하기 전에 가용 영역 및 플레이스먼트 그룹을 신중하게 선택하고 구성해보시기 바랍니다.

 

 

 

지금까지 EC2 Placement를 알아보는 시간이었습니다....! 끝...!

 

 

 

[Reference]

 

 

 

'AWS' 카테고리의 다른 글

[AWS] Route 53 도메인 신규 등록하기  (0) 2023.09.19
[AWS] Amazon Kinesis 알아보기  (0) 2023.08.17
[AWS] Amazon Route 53 알아보기  (0) 2023.07.19
[AWS] AWS Direct Connect 알아보기  (0) 2023.07.12
[AWS] Amazon SNS 알아보기  (0) 2023.07.11

[AWS] Amazon Route 53 알아보기


도메인은 인터넷에서 웹사이트나 이메일 등을 식별하는 주소로, 사용자가 웹사이트를 방문하거나 이메일을 보낼 때 사용됩니다.

 

도메인을 사용하기 위해서는 도메인 서버를 직접 구성하거나 가비아, 후이즈 등 도메인 리셀러를 통해서 공인 도메인을 구매하여 사용이 가능한데요.


Amazon에서는 가용성과 확장성이 뛰어난 클라우드 기반 DNS 웹 서비스를 Route 53을 통해 제공합니다.
Route 53을 통해 EC2, ELB, S3 버킷 등 다양한 AWS 서비스와 연동하여 사용할 수도 있습니다.

 

 


주요 기능

 

Amazon Route 53은 확장 가능하고 안정적인 DNS 서비스로서, 도메인 이름 관리와 DNS 라우팅을 효과적으로 수행하는 데 필요한 주요 기능을 제공합니다.

 

  1. 도메인 등록 및 관리
    • Route 53을 사용하여 도메인을 등록하고, 도메인 이름의 소유권을 관리할 수 있습니다.
    • 도메인은 amazon.com을 사용할 수 있지만 Route 53에서 바로 리셀러를 선택하여 공인 도메인을 구매하여 사용할 수 있습니다.
    • 관리 콘솔을 통해 도메인 이름 등록, 갱신, 이전, 삭제 등의 작업을 손쉽게 수행할 수 있습니다.
  2. DNS 라우팅
    • Route 53은 DNS 라우팅을 제공하여 도메인 이름을 해당하는 웹 서버 또는 AWS 리소스와 연결할 수 있습니다.
    • 라우팅 정책을 사용하여 트래픽을 여러 리소스 간에 분산하거나, 특정 리전 또는 지연 시간이 가장 낮은 리소스로 트래픽을 전달할 수 있습니다.
  3. 고가용성 및 신뢰성
    • Route 53은 글로벌로 분산된 네트워크를 통해 DNS 서비스를 제공하므로 고가용성과 신뢰성이 높습니다.
    • 전 세계의 DNS 서버로 트래픽을 분산하여 서비스 지연 시간을 최소화하고, 장애 발생 시 자동으로 트래픽을 다른 서버로 전환하여 연결성을 유지합니다.
  4. 상태 확인과 모니터링
    • Route 53은 지정된 도메인 또는 리소스에 대한 상태 확인 및 모니터링 기능을 제공합니다.
    • 도메인 또는 엔드포인트의 가용성, 지연 시간, 성능 등을 모니터링하고, 상태가 변경되면 경고 및 알림을 제공합니다.

 

 


작동 방식

Amazon Route 53은 사용자(End User)의 요청을 AWS 또는 온프레미스에서 실행되는 인터넷 애플리케이션에 연결합니다.

리소스의 상태를 확인하기 위해서 Health Check를 통해 정상 작동 중인지 확인하고, AWS CloudWatch를 통해 모니터링 매트릭 및 알람을 관리합니다.

 

 


다이어그램

Amazon Route 53을 사용하는 웹 애플리케이션의 아키텍처입니다.


Amazon Route 53의 기능을 통해 DNS 서비스를 제공하고, 전체 웹 트래픽을 클라우드 프런트를 통해 전달됩니다.
또한 서비스 요청에 따라 특정 리전의 EIP 또는 ELB로 라우팅하거나, AWS에서 사용 중인 다른 리소스로 전달할 수도 있습니다.

 

 


각 요소들

 

DNS (Domain Name System)

  • 인터넷에서 도메인 이름과 해당 도메인에 대한 IP 주소를 매핑하는 시스템입니다.
  • 사용자가 사람이 이해하기 쉬운 도메인 이름을 입력하여 웹사이트나 이메일 서버 등의 리소스에 접근할 수 있게 합니다.

 

DNS 레코드 (DNS Record)

  • 도메인 이름과 해당 도메인과 연결된 IP 주소 또는 서비스의 정보를 매핑하는 기록으로, 인터넷에서 도메인을 식별하고 해당 도메인으로의 트래픽을 올바르게 전송하는 역할을 합니다.
  • 각각의 DNS 레코드 유형(A, CNAME, MX, TXT 등)은 특정 도메인 이름과 IP 주소, 서브도메인 등의 매핑 정보를 정의하여 웹사이트 호스팅, 이메일 전송, 서비스 지정 등을 가능하게 합니다.

 

호스팅 영역(Hosted Zone)

  • Amazon Route 53에서 도메인 이름의 DNS 정보를 저장하고 관리하는 영역입니다.
  • Route 53의 Hosted Zone을 사용하여 DNS 레코드를 추가, 수정, 삭제하여 도메인 이름과 관련된 리소스를 관리할 수 있습니다.

 

DNS 쿼리 (DNS Query)

  • 사용자 또는 클라이언트(예: 웹 브라우저)가 도메인 이름을 IP 주소로 변환하기 위해 DNS 서버에 보내는 요청으로, 도메인 이름에 대한 정확한 IP 주소나 다른 DNS 레코드 정보를 받아오는 프로세스를 말합니다.

 

 


요금

 

Amazon Route 53은 사용한 내역에 대해서만 요금을 지불합니다.
큰 항목으로는 호스팅 영역 관리, DNS 쿼리 제공, 도메인 이름 관리 항목에서 요금이 지불됩니다.

 

 

호스팅 영역 및 레코드

  • 처음 25개 호스팅 영역의 경우 월별 호스팅 영역당 0.50 USD
  • 추가 호스팅 영역의 경우 월별 호스팅 영역당 0.10 USD
    호스팅 영역 하나에는 10,000개의 레코드가 포함되며, 영역당 10,000개를 초과하는 각 레코드에는 월 0.0015 USD의 요금이 부과됩니다.

 

 

쿼리

표준 쿼리

  • 월별 첫 10억 개 쿼리의 경우 1백만 쿼리당 0.40 USD
  • 월별 10억 개를 초과하는 쿼리의 경우 1백만 쿼리당 0.20 USD

지연 시간 기반 라우팅 쿼리

  • 월별 첫 10억 개 쿼리의 경우 1백만 쿼리당 0.60 USD
  • 월별 10억 개를 초과하는 쿼리의 경우 1백만 쿼리당 0.30 USD

지역 DNS 및 지역 근접성 쿼리

  • 월별 첫 10억 개 쿼리의 경우 1백만 쿼리당 0.70 USD
  • 월별 10억 개를 초과하는 쿼리의 경우 1백만 쿼리당 0.35 USD

IP 기반 라우팅 쿼리*

  • 월별 첫 10억 개 쿼리의 경우 1백만 쿼리당 0.80 USD
  • 월별 10억 개를 초과하는 쿼리의 경우 1백만 쿼리당 0.40 USD

 

 

도메인 이름

도메인 이름에 대한 요금은 최상위 도메인(Top-level domain, TLD)별로 다릅니다.
< TLD별 현재 요금에 대한 전체 목록 >
도메인 이름은 1년 단위로 등록되며, 계정당 최대 20개까지 도메인 이름을 등록할 수 있습니다

그외에는 DNS 방화벽, DNSSEC, 쿼리 로깅등을 구성한 경우 요금이 부과될 수 있습니다.

 

 


활용

 

  • DNS 라우팅 및 로드 밸런싱
    Cloud 환경에서 서비스 운영 시 확장성과 가용성을 고려하여 서비스를 설계하고 운영해야합니다.
    서비스는 DNS를 기반으로 운영되기 때문에 Amazon Route 53을 통해 DNS 라우팅을 구성하여 도메인 이름과 해당하는 리소스(예: 웹 서버, 로드 밸런서)를 연결할 수 있습니다.
    라우팅 정책을 설정하여 트래픽을 분산하거나 지연 시간에 따라 트래픽을 가장 빠른 리소스로 전달하여 확장성과 가용성을 향상시킬 수 있습니다.

 

  • 지리적 라우팅
    SaaS 서비스를 국내 뿐만 아니라 해외 고객에 제공할 경우 각 서비스 사용자들은 해외 네트워크를 통해 서비스를 사용하게 됩니다.
    해외에서 접속하는 서비스 사용자들은 지역에 따라 네트워크 지연에 따른 서비스 이용에 지연이 발생할 수 잇습니다.
    Amazon Route 53을 활용하여 지리적 라우팅을 구성하여, 사용자들의 지역에 따라 트래픽을 다른 리소스로 라우팅하여 지역별로 최적화된 서비스를 제공할 수 있습니다.

 

  • SSL/TLS 인증서 관리
    HTTPS로 웹 서비스를 운영하기 위해서는 공인 도메인 발급 후 SSL/TLS 인증서 발급 및 적용이 필요합니다.
    Amazon Route 53을 사용하여 SSL/TLS 인증서를 발급하고 관리할 수 있습니다.
    또한 SSL/TLS 인증서를 추가로 구매하여 사용할 필요 없이 Amazon Certificate Manager(ACM)과 통합하여 무료로 SSL/TLS 인증서를 쉽게 구성할 수 있습니다.

 

 

 

지금까지 Amazon에서 제공하는 클라우드 기반 DNS 웹 서비스를 Route 53을 알아보는 시간이었습니다....! 끝...!

 

 

 

[Reference]

 

 

 

'AWS' 카테고리의 다른 글

[AWS] Amazon Kinesis 알아보기  (0) 2023.08.17
[AWS] EC2 Placement 알아보기  (0) 2023.07.26
[AWS] AWS Direct Connect 알아보기  (0) 2023.07.12
[AWS] Amazon SNS 알아보기  (0) 2023.07.11
[AWS] Amazon Elastic Container Registry 알아보기  (0) 2023.06.14

[AWS] AWS Direct Connect 알아보기

AWS의 네트워크 서비스로는 대표적으로 Amazon VPC(Virtual Private Cloud)가 있습니다.
VPC의 기능을 통해서 내부 네트워크를 할당하거나 외부 네트워크를 사용할 수 있도록 설정할 수 있는데요.

 

AWS Direct Connect은 AWS의 클라우드 서비스에 직접적으로 연결할 수 있는 네트워킹 서비스로,
공용 인터넷을 우회하고 전용 연결을 통해 더 안정적이고 안전한 네트워크 연결을 구성할 수 있습니다.

 

 


주요 기능

AWS Direct Connect를 사용하면 전용 케이블을 통해 내부 네트워크를 AWS Direct Connect와 연결 할 수 있습니다.

주요 기능은 아래와 같습니다.

 

  1. 전용 연결
    • 내부 네트워크 망이나 AWS 리전 간의 전용 연결읕 설정할 수 있습니다.
    • 전용 연결을 통해 안정적이고 저지연의 연결을 제공하며, 데이터 속도와 신뢰성을 향상시킵니다
  2. 가상 인터페이스
    • 가상 인터페이스를 통해 AWS 내의 VPC 또는 기타 AWS 서비스와 연결할 수 있습니다.
  3. 보안
    • 공용 인터넷 대역폭을 우회하여 데이터 전송을 보안하며 전용 연결을 통해 고객의 데이터는 인터넷을 거치지 않고 직접 AWS에 도달하므로 더 높은 보안 수준을 제공합니다.
  4. 대역폭 제어
    • 1Gbps, 10Gbps, 100Gbps 등 다양한 속도의 연결을 선택하여 필요한 만큼의 대역폭을 확장하거나 축소하여 비용을 효율적으로 관리할 수 있습니다.

 

 


다이어그램

AWS Direct Connect를 사용하여 네트워크에 대한 종합적인 개요를 보여주는 다이어그램입니다.


온프레미스의 고객 네트워크와 AWS Cloud와의 네트워크 통신을 AWS Direct Connect의 전용 연결을 통해 네트워크 통신을 할 수 있습니다. AWS Direct Connect의 라우터와 고객 라우터는 BGP 라우팅을 통해서 설정을 관리하고 라우팅 정보를 교환합니다.


Private Subnet과의 연결을 위해 Virtual Private Gateway를 설정하고 가상 인터페이스를 통해 Direct Connect와 연결합니다. 이제 보안 그룹 및 네트워크 ACL 규칙 등을 설정하면 온프레미스의 고객 네트워크와 AWS Cloud와의 네트워크 통신을 할 수 있습니다.

 

 


각 요소들

가상 인터페이스(Virtual Interface, VIF)

  • 가상 인터페이스는 AWS Direct Connect 연결을 통해 생성되는 논리적인 연결로 VPC 및 기타 AWS 서비스와 연결할 수 있는 방법을 제공합니다.
  • VLAN(Virtual LAN)을 사용하여 네트워크 트래픽을 분리하고, BGP를 사용하여 라우팅을 구성합니다.

 

전용 연결(dedicated connections)

  • AWS Direct Connect의 연결 유형 중 하나로, 고객이 AWS Direct Connect 위치에 직접 연결하여 대량의 트래픽을 처리하는 데 사용되는 유형입니다
  • 전용 연결을 설정하기 위해 고객은 AWS Direct Connect 위치에서 고객 장비를 설치하거나, AWS Direct Connect 서비스 파트너를 통해 연결을 요청해야 합니다.
  • 대량의 트래픽을 처리하거나 고객의 네트워크에 안정적이고 고성능의 연결을 제공하는데 적합한 방법입니다.

 

호스팅 연결(hosted connections)

  • AWS Direct Connect의 연결 유형 중 하나로, AWS Direct Connect 위치와 인터넷 서비스 공급자(ISP)의 피어링 지점에 연결하여 작은 양의 트래픽이나 테스트 및 개발 용도로 사용되는 유형입니다.
  • 호스팅 연결을 설정하기 위해 고객은 AWS Direct Connect 위치와 ISP 피어링 지점에 대한 연결 요청을 수행해야 합니다.
  • 작은 규모의 트래픽이나 테스트, 개발 용도에 적합한 방법입니다.

 

SiteLink

  • AWS Direct Connect의 연결 유형 중 하나로, 동일한 AWS Direct Connect 위치의 여러 장치나 데이터 센터 간에 전용 연결을 설정하는 기능을 제공합니다.
  • 여러 지역 또는 데이터 센터 간에 AWS Direct Connect 연결을 구성하여 AWS의 다중 지역 아키텍처를 구축하거나, 여러 데이터 센터에서 AWS 리소스에 안전하고 고성능의 연결을 확보할 수 있습니다.

 

Virtual Private Gateway

  • Virtual Private Gateway는 AWS 클라우드 내에서 VPC와 인터넷 간의 연결을 제공하는 가상 장치입니다.
  • AWS Direct Connect와 함께 사용하여 VPC를 온프레미스 환경 또는 다른 외부 네트워크와 연결할 수 있습니다.
  • Site-to-Site VPN 연결과 BGP 라우팅을 통해 네트워크 연결을 구성하고 제어할 수 있습니다.

 

 


요금

AWS Direct Connect의 요금은 포트 연결 시간 및 송수신 데이터에 따라 결정됩니다.

 

포트 시간: 전용 연결

전용 연결은 AWS Direct Connect 위치 내 AWS 네트워크 포트 및 사용자의 네트워크 포트 간 물리적 연결입니다.
전용 포트 시간은 사용하기 위해 포트를 프로비저닝한 만큼 요금이 청구됩니다.

 

트 시간 : 호스팅 연결

호스팅 연결은 AWS Direct Connect 제공 파트너가 사용자를 대신하여 프로비저닝하는 논리적 연결입니다.
호스팅 연결을 사용하는 경우 파트너 포트 중 하나를 사용하여 AWS 네트워크에 연결합니다.

 

데이터 송신(DTO)

DTO 요금은 소스 AWS 리전 또는 로컬 영역 및 AWS Direct Connect 위치에 따라 다르며, GB당 USD 요금이 부과됩니다.

 

SiteLink 데이터 전송

SiteLink는 AWS Direct Connect 서비스에서 제공되는 네트워크 연결 유형 중 하나로,
여러 지리적 위치나 데이터 센터 간에 안전하고 신뢰성 있는 전용 연결을 설정하는 기능을 제공합니다

 

 


활용

  1. Hybrid Cloud 구축
    온프레미스에서 운영중인 시스템을 한번에 모두 AWS Cloud로 Migration 하기는 어렵습니다.
    또한 내부에 구축한 환경을 동일하게 AWS Cloud로 구현할 수 없다면 온프레미스에서 운영중인 시스템을 같이 사용해야 되는데요.
    AWS Direct Connect을 사용하여 온프레미스와 AWS 클라우드 간의 안전하고 고성능의 연결을 설정할 수 있습니다.
    이를 통해 하이브리드 클라우드 아키텍처를 구축하고 온프레미스 리소스를 사용 가능하게 합니다.

 

  1. 보안 네트워크 구축
    별도의 방화벽과 보안 장치가 없이 인터넷 망을 통해서 AWS Cloud와 온프레미스 서로간의 네트워크 접근과 데이터를 전송한다면 보안에 취약합니다.
    AWS Direct Connect은 전용 연결을 통해 인터넷을 거치지 않고 공용 인터넷 대역폭을 우회하여 데이터 전송을 보안함으로써 더 높은 보안 수준을 제공합니다.
    또한 VPC 내의 프라이빗 서브넷과 온프레미스 리소스 간에 안전하고 효율적인 통신을 가능하게 합니다.

 

  1. 대용량 데이터 전송 및 고품질 네트워크 구축
    인터넷 망을 통해서 AWS Cloud와 온프레미스 서로간의 대용량의 데이터를 전송한다면 네트워크 지연 발생으로 안정적으로 데이터를 전송할 수 없습니다.
    AWS Direct Connect을 사용하여 대용량의 데이터를 안정적으로 업로드하거나 다운로드 할 수 있으며,
    실시간 비디오 스트리밍, 온라인 게임, 음성 통화 등의 애플리케이션에서는 네트워크 지연을 최소화하고 품질을 향상시킬 수 있습니다.

 

 

AWS Direct Connect에 대한 주요 기능, 요금, 활용 등 다양한 부분을 확인해봤는데요. 내부 네트워크 연결을 위해 AWS Direct Connect의 다양한 기능을 사용해보시기 바랍니다.

 

 

 

지금까지 AWS의 클라우드 서비스에 직접적으로 연결할 수 있는 네트워킹 서비스인 AWS Direct Connect를 알아보는 시간이었습니다....! 끝...!

 

 

 

[Reference]

 

 

 

[AWS] Amazon SNS 알아보기

서비스 장애 메시지를 실시간으로 확인하거나 서비스 업데이트 알림 등을 보내기 위해서는 이메일, 모바일 푸시 알림 및 모바일 문자 메시지(SMS) 등을 사용하고 있는데요. AWS 에서는 메시지 전송 관리형 서비스인 Amazon Simple Notification Service(Amazon SNS)를 통해 서비스를 지원하고 있습니다.

 

Amazon SNS는 다양한 클라이언트들에게 실시간으로 메시지를 보내고 수신할 수 있으며는 주제, 구독자, 발행자의 개념을 기반으로 관리되고 있습니다. 다양한 프로토콜을 지원하여 이메일, SMS, HTTP/HTTPS 모바일 푸시 알림 등을 통해 메시지를 전송할 수 있으며 Amazon Kinesis Data Firehose, Amazon SQS, AWS Lambda 등의 AWS 서비스에도 연동하여 사용할 수 있습니다.

 

 


주요 기능

Amazon SNS는 애플리케이션, 시스템, 서비스 간에 신속하고 안정적인 메시지 전송을 제공하며

아래와 같은 주요 기능을 제공합니다.

 

  1. 메시지 푸시
    • Amazon SNS를 사용하여 다양한 클라이언트에게 메시지를 푸시할 수 있습니다.
    • 이메일, SMS, HTTP/HTTPS, 모바일 푸시 알림 등 다양한 프로토콜을 통해 메시지를 전송할 수 있습니다.
  2. 주제 기반 구독
    • Amazon SNS는 주제(Topic)를 생성하여 관련 구독자를 그룹화할 수 있습니다.
    • 구독자는 특정 주제에 대한 알림을 받기 위해 해당 주제에 가입하고, 이를 통해 세밀한 구독 관리와 대상 그룹의 동적 구성이 가능합니다.
  3. 다양한 엔드포인트 지원
    • Amazon SNS는 이메일 주소, SMS 번호, AWS Lambda 함수, Amazon Simple Queue Service (SQS) 대기열 등 다양한 대상에게 메시지를 전달하고 연동할 수 있습니다.
  4. 확장성과 안정성
    • Amazon SNS는 확장 가능한 서비스로, 메시지 처리량이 매우 높은 환경에서도 안정적으로 동작합니다.
    • 수신 확인 및 재시도 기능을 제공하여 메시지 전송의 신뢰성을 보장합니다.
  5. 필터링 및 메시지 페이로드
    • Amazon SNS는 메시지 필터링을 통해 특정 조건에 따라 메시지를 선택적으로 전송할 수 있습니다.
    • 메시지 페이로드를 통해 추가 데이터를 전송하고 수신측에서 이를 활용할 수 있습니다.
  6. AWS 서비스와의 통합
    • Amazon SNS는 다른 AWS 서비스와의 강력한 통합을 제공합니다.
    • Amazon Kinesis Data Firehose, Amazon SQS, AWS Lambda와의 연동을 통해 실시간 데이터 스트리밍, 큐잉 및 서버리스 아키텍처 시나리오에서 유연하게 메시지를 전송하고 처리할 수 있습니다.

 

 


작동 방식

Amazon SNS는 A2A와 A2P의 두 가지 방식으로 알림을 전송합니다.

 

A2A는 분산된 시스템, 마이크로서비스 및 이벤트 중심의 서버리스 애플리케이션 간에 처리량이 많은 푸시 기반의 다대다 메시징을 제공합니다. 이러한 애플리케이션에는 Amazon Simple Queue Service(SQS), Amazon Kinesis Data Firehose, AWS Lambda, 기타 HTTPS 엔드포인트가 포함됩니다.


A2P 기능을 사용하면 SMS 텍스트, 푸시 알림, 이메일을 통해 고객에게 메시지를 전송할 수 있습니다.

 

게시/구독

 

SMS

 

모바일 푸시

 


요금

Amazon SNS의 요금은 표준 주제 API 요청, FIFO 주제 API 요청, 페이로드 크기, Amazon S3에서 페이로드 크기 확장, AWS KMS와 상호 작용으로 측정됩니다.


간단히 요약한다면 API 요청과 데이터 전송으로 나눠져 있다고 생각하면 좋을 것 같습니다.

 

알림 전달

 

데이터 전송

 

상세한 내용은 아래 링크를 통해 확인하시기 바랍니다.
https://aws.amazon.com/ko/sns/pricing/

 

 

추가적으로 모바일 문자 메시지(SMS) 및 모바일 푸시 알림 등은 지원되는 리전이 정해져있으니 참고하시기 바랍니다.

 

 


화면

Amazon SNS은 주제(Topic)을 기준으로 서비스를 관리할 수 있습니다.

 

 

Topics 메뉴에서 Topic을 생성하거나 기존에 생성된 Topic을 관리할 수 있습니다.
Subscriptions 메뉴에서는 각 Topic에 대한 구독자를 관리할 수 있습니다.

 

 


활용

서비스에서 발생하는 이벤트에 대한 알림을 실시간으로 Email 및 SMS 등을 전송할 수 있습니다.
예를 들어 주문 상태 변경, 결제 완료 등의 이벤트가 있습니다.

 

 

서비스에 중요한 이벤트나 장애가 발생하면 실시간으로 이벤트를 Email 및 SMS 등을 통해 경고 알림을 전송할 수 있습니다.

예를 들어, 시스템 다운, CPU or Memory 부하 발생, 서비스 이용자 급증 등의 이벤트가 있습니다.

 

 

AWS에서 제공하는 암호화 서비스(KMS) 등과의 연동을 통해 암호화된 메시지를 전송할 수 있습니다.

SageMaker에서 S3 버킷에 저장된 기계 학습 데이터를 사용하는 작업을 완료하였습니다.

 

 

Amazon SNS에 대한 기존적인 정보들을 알아보았으니 실제 서비스에 적용하여 활용해보시기 바랍니다.

지금까지 Amazon에서 제공하는 메시지 전송 관리형 서비스인 Amazon Simple Notification Service(Amazon SNS)을 알아보는 시간이었습니다....! 끝...!

 

 

 

 

[Reference]

 

 

 

 

[AWS] SageMaker에서 S3 버킷에 저장된 학습 데이터 사용하기

이전 포스트에서는 AWS에서 자체 제공하는 기계 학습 플랫폼인 SageMaker를 사용하여 기계 학습 환경을 구축해봤는데요.


SageMaker에서 기계 학습 시 로컬 디렉토리나 다운로드 받은 기계 학습 데이터를 사용하는 것이 아닌 S3 버킷에 저장된 기계 학습 데이터를 사용하여 기계 학습을 실행할 수 있도록 해보겠습니다.

 

이전이 작성한 포스트인 Amazon SageMaker를 사용하여 기계 학습 환경을 구축하는 방법을 기준으로 진행하는 작업이므로 이전 포스트를 사전에 확인 후 작업하시면 더 도움이 될 것 같습니다.

 

 


SageMaker S3 버킷 확인

SageMaker Studio에서 Jupyter Notebook을 통해 Session 생성 시 Default S3 버킷이 생성됩니다.


아래 명령어를 통해 Default S3 버킷 이름을 확인하실 수 있습니다.

import sagemaker

#========== 기본설정 ==========
# Session 생성
sagemaker_session = sagemaker.Session()

# Amazon S3 bucket 이름
s3_bucket_name = sagemaker_session.default_bucket()

# Amazon S3 bucket 출력
print (s3_bucket_name)

 

 


기계 학습 데이터 S3 버킷 업로드

기계 학습 데이터는 COCO 데이터 셋을 사용하도록 하겠습니다.


SageMaker Default S3 버킷에 폴더를 생성 후 COCO 데이터 셋을 업로드 합니다.


업로드 작업은 AWS Console에서 작업하거나 AWS CLI를 통해 S3 버킷에 기계 학습 데이터를 업로드 할 수 있습니다.

 

AWS CLI 예시

# aws s3 cp {{기계 학습 데이터}}  s3://{{S3 버킷 URL}}/coco128/images/.

 

 


기계 학습 코드

 

기계 학습 코드 - 기본 설정

SageMaker Default S3 버킷을 확인하고 COCO 데이터 셋 경로와 모델 저장 경로를 설정합니다.

import sagemaker

#========== 기본설정 ==========
# Session 생성
sagemaker_session = sagemaker.Session()

# Amazon S3 bucket 이름
s3_bucket_name = sagemaker_session.default_bucket()

# IAM role
role = sagemaker.get_execution_role()


#========== 학습 설정 ==========
# 데이터셋 경로
dataset_path = 'coco128'

# 모델 저장 경로
output_path = 'coco128/train'

# S3 bucket 데이터셋 경로
s3_dataset_path = f's3://{s3_bucket_name}/{dataset_path}'

# S3 bucket 모델 저장 경로
s3_output_path = f's3://{s3_bucket_name}/{output_path}'


# Estimator 설정
est_pytorch_entry_point= 'train.py'
est_pytorch_image_uri = '{ECR_URL}/sagemaker:pytorch-training-2.0.0-gpu-py310-cu118-ubuntu20.04-sagemaker'
est_pytorch_framework_version = '2.0.0'
est_pytorch_py_version = 'py310'
est_pytorch_instance_type = 'ml.g4dn.xlarge'
est_pytorch_instance_count = 1
est_pytorch_source_dir = './'

# Hyperparameters 설정
est_pytorch_hyperparameters={
    'data': 'coco128.yaml',
    'cfg': 'yolov5s.yaml',
    'epochs': 3,
    'project' : '/opt/ml/model',
    'batch-size': 8
}

 

  1. SageMaker Default S3 버킷 이름을 설정합니다.
    • s3_bucket_name = sagemaker_session.default_bucket()
  2. S3 버킷관련 경로 설정을 추가합니다.
    • 데이터셋 경로 : dataset_path = 'coco128'
    • 모델 저장 경로 : output_path = 'coco128/train'
    • S3 bucket 데이터셋 경로 : s3_dataset_path = f's3://{s3_bucket_name}/{dataset_path}'
    • S3 bucket 모델 저장 경로 : s3_output_path = f's3://{s3_bucket_name}/{output_path}'

 

 

기계 학습 코드 - 입력 데이터 채널 및 Estimator 생성

기계 학습 입력 데이터 채널을 생성하고, 모델 저장 경로를 Estimator 생성 시 설정합니다.

from sagemaker.pytorch import PyTorch
from sagemaker.inputs import TrainingInput

# 입력 데이터 채널 (기계 학습 데이터)
data_inputs = TrainingInput(s3_data=s3_dataset_path, content_type='application/x-image')

# Estimator 생성
pytorch_estimator = PyTorch(
    entry_point=est_pytorch_entry_point,
    image_uri=est_pytorch_image_uri,
    framework_version=est_pytorch_framework_version,
    py_version=est_pytorch_py_version,
    instance_type=est_pytorch_instance_type,
    instance_count=est_pytorch_instance_count,
    source_dir=est_pytorch_source_dir,
    output_path=s3_output_path,
    train_output=s3_output_path,
    sagemaker_session=sagemaker_session,
    role=role,
    hyperparameters=est_pytorch_hyperparameters
)

 

  1. 사전에 S3 버킷에 업로드한 기계 학습 데이터를 사용할 수 있도록 기계 학습 입력 데이터 채널을 생성합니다.
  2. Estimator 생성 시 output_path, train_output 옵션을 추가하여 모델 저장 경로를 설정합니다.

 

 

기계 학습 코드 - 학습 시작

사전에 생성한 기계 학습 입력 데이터 채널을 기계 학습 시작 시 사용하는 .fit() 함수에 추가합니다.

# 학습 시작
pytorch_estimator.fit(inputs=data_inputs)

 

 

 

기계 학습 코드 - 데이터 셋 경로 설정 변경

S3 버킷을 통해 기계 학습 데이터 다운로드 시 기본 경로인 /opt/ml/input/data 경로에 데이터가 다운로드 됩니다.


coco128.yaml 파일을 사용하여 데이터 셋을 정의하고 있으며 해당 파일의 경로 설정을 변경하여 S3 버킷을 통해 다운로드 받은 기계 학습 데이터를 사용할 수 있도록 수정합니다.

# 기존
path: ../datasets/coco128  # dataset root dir
# 수정
path: /opt/ml/input/data/training

 

 


기계 학습 코드 실행

작성한 기계 학습 코드를 실행해보도록 하겠습니다.

 

Estimator의 fit 함수를 실행합니다.

 

 

 

기존에는 학습 데이터를 저장하고 있지 않았기 때문에 기계 학습 데이터를 다운로드 받으며,

S3 버킷의 기계 학습 데이터를 사용할 경우 데이터 셋을 확인하여 이후 작업을 진행합니다.

  • 기존

 

  • S3 버킷 기계 학습 데이터 사용

 

 

 

S3 버킷의 기계 학습 데이터를 사용하기 때문에 기계 학습 시간도 단축됩니다.

  • 기존 (427)

 

  • S3 버킷 기계 학습 데이터 사용 (363초)

 

 

  • 기계 학습 완료 시 사전에 설정한 모델 저장 경로에 모델 파일이 저장되어 있는지 저장 경로를 확인할 수 있습니다.

 

  • S3 버킷에 직접 접속 후 기계 학습이 완료된 모델 파일을 확인하시기 바랍니다.

 

 

전체 학습 상세 로그는 아래 버튼을 클릭하여 확인하시기 바랍니다.

학습 상세 로그
Using provided s3_resource
INFO:sagemaker:Creating training-job with name: sagemaker-2023-07-04-07-46-10-310
2023-07-04 07:46:13 Starting - Starting the training job...
2023-07-04 07:46:28 Starting - Preparing the instances for training......
2023-07-04 07:47:31 Downloading - Downloading input data...
2023-07-04 07:48:01 Training - Downloading the training image...........................
2023-07-04 07:52:27 Training - Training image download completed. Training in progress.bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
2023-07-04 07:52:37,314 sagemaker-training-toolkit INFO     Imported framework sagemaker_pytorch_container.training
2023-07-04 07:52:37,331 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-07-04 07:52:37,340 sagemaker_pytorch_container.training INFO     Block until all host DNS lookups succeed.
2023-07-04 07:52:37,345 sagemaker_pytorch_container.training INFO     Invoking user training script.
2023-07-04 07:52:39,710 sagemaker-training-toolkit INFO     Installing dependencies from requirements.txt:
/opt/conda/bin/python3.10 -m pip install -r requirements.txt
Collecting gitpython>=3.1.30 (from -r requirements.txt (line 5))
Downloading GitPython-3.1.31-py3-none-any.whl (184 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 184.3/184.3 kB 12.4 MB/s eta 0:00:00
Requirement already satisfied: matplotlib>=3.3 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 6)) (3.7.1)
Requirement already satisfied: numpy>=1.18.5 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 7)) (1.23.5)
Requirement already satisfied: opencv-python>=4.1.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 8)) (4.7.0)
Requirement already satisfied: Pillow>=7.1.2 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 9)) (9.4.0)
Requirement already satisfied: psutil in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 10)) (5.9.5)
Requirement already satisfied: PyYAML>=5.3.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 11)) (5.4.1)
Requirement already satisfied: requests>=2.23.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 12)) (2.28.2)
Requirement already satisfied: scipy>=1.4.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 13)) (1.10.1)
Collecting thop>=0.1.1 (from -r requirements.txt (line 14))
Downloading thop-0.1.1.post2209072238-py3-none-any.whl (15 kB)
Requirement already satisfied: torch>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 15)) (2.0.0)
Requirement already satisfied: torchvision>=0.8.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 16)) (0.15.1)
Requirement already satisfied: tqdm>=4.64.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 17)) (4.65.0)
Collecting ultralytics>=8.0.111 (from -r requirements.txt (line 18))
Downloading ultralytics-8.0.125-py3-none-any.whl (612 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 612.5/612.5 kB 80.2 MB/s eta 0:00:00
Requirement already satisfied: pandas>=1.1.4 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 27)) (2.0.1)
Requirement already satisfied: seaborn>=0.11.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 28)) (0.12.2)
Requirement already satisfied: setuptools>=65.5.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 42)) (65.6.3)
Collecting gitdb<5,>=4.0.1 (from gitpython>=3.1.30->-r requirements.txt (line 5))
Downloading gitdb-4.0.10-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.7/62.7 kB 21.5 MB/s eta 0:00:00
Requirement already satisfied: contourpy>=1.0.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (1.0.7)
Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (4.39.4)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (1.4.4)
Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (23.1)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (2.8.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (2023.5.7)
Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (3.12.0)
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (4.5.0)
Requirement already satisfied: sympy in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (1.11.1)
Requirement already satisfied: networkx in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (3.1)
Requirement already satisfied: jinja2 in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (3.1.2)
Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.10/site-packages (from pandas>=1.1.4->-r requirements.txt (line 27)) (2023.3)
Requirement already satisfied: tzdata>=2022.1 in /opt/conda/lib/python3.10/site-packages (from pandas>=1.1.4->-r requirements.txt (line 27)) (2023.3)
Collecting smmap<6,>=3.0.1 (from gitdb<5,>=4.0.1->gitpython>=3.1.30->-r requirements.txt (line 5))
Downloading smmap-5.0.0-py3-none-any.whl (24 kB)
Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib>=3.3->-r requirements.txt (line 6)) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from jinja2->torch>=1.7.0->-r requirements.txt (line 15)) (2.1.2)
Requirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.10/site-packages (from sympy->torch>=1.7.0->-r requirements.txt (line 15)) (1.3.0)
Installing collected packages: smmap, gitdb, thop, gitpython, ultralytics
Successfully installed gitdb-4.0.10 gitpython-3.1.31 smmap-5.0.0 thop-0.1.1.post2209072238 ultralytics-8.0.125
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
2023-07-04 07:52:42,410 sagemaker-training-toolkit INFO     Waiting for the process to finish and give a return code.
2023-07-04 07:52:42,411 sagemaker-training-toolkit INFO     Done waiting for a return code. Received 0 from exiting process.
2023-07-04 07:52:42,428 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-07-04 07:52:42,453 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-07-04 07:52:42,477 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-07-04 07:52:42,485 sagemaker-training-toolkit INFO     Invoking user script
Training Env:
{
    "additional_framework_parameters": {},
    "channel_input_dirs": {
        "training": "/opt/ml/input/data/training"
    },
    "current_host": "algo-1",
    "current_instance_group": "homogeneousCluster",
    "current_instance_group_hosts": [
        "algo-1"
    ],
    "current_instance_type": "ml.g4dn.xlarge",
    "distribution_hosts": [],
    "distribution_instance_groups": [],
    "framework_module": "sagemaker_pytorch_container.training:main",
    "hosts": [
        "algo-1"
    ],
    "hyperparameters": {
        "batch-size": 8,
        "cfg": "yolov5s.yaml",
        "data": "coco128.yaml",
        "epochs": 3,
        "project": "/opt/ml/model/"
    },
    "input_config_dir": "/opt/ml/input/config",
    "input_data_config": {
        "training": {
            "ContentType": "application/x-image",
            "TrainingInputMode": "File",
            "S3DistributionType": "FullyReplicated",
            "RecordWrapperType": "None"
        }
    },
    "input_dir": "/opt/ml/input",
    "instance_groups": [
        "homogeneousCluster"
    ],
    "instance_groups_dict": {
        "homogeneousCluster": {
            "instance_group_name": "homogeneousCluster",
            "instance_type": "ml.g4dn.xlarge",
            "hosts": [
                "algo-1"
            ]
        }
    },
    "is_hetero": false,
    "is_master": true,
    "is_modelparallel_enabled": null,
    "is_smddpmprun_installed": true,
    "job_name": "sagemaker-2023-07-04-07-46-10-310",
    "log_level": 20,
    "master_hostname": "algo-1",
    "model_dir": "/opt/ml/model",
    "module_dir": "s3://####################/sagemaker-2023-07-04-07-46-10-310/source/sourcedir.tar.gz",
    "module_name": "train",
    "network_interface_name": "eth0",
    "num_cpus": 4,
    "num_gpus": 1,
    "num_neurons": 0,
    "output_data_dir": "/opt/ml/output/data",
    "output_dir": "/opt/ml/output",
    "output_intermediate_dir": "/opt/ml/output/intermediate",
    "resource_config": {
        "current_host": "algo-1",
        "current_instance_type": "ml.g4dn.xlarge",
        "current_group_name": "homogeneousCluster",
        "hosts": [
            "algo-1"
        ],
        "instance_groups": [
            {
                "instance_group_name": "homogeneousCluster",
                "instance_type": "ml.g4dn.xlarge",
                "hosts": [
                    "algo-1"
                ]
            }
        ],
        "network_interface_name": "eth0"
    },
    "user_entry_point": "train.py"
}
Environment variables:
SM_HOSTS=["algo-1"]
SM_NETWORK_INTERFACE_NAME=eth0
SM_HPS={"batch-size":8,"cfg":"yolov5s.yaml","data":"coco128.yaml","epochs":3,"project":"/opt/ml/model/"}
SM_USER_ENTRY_POINT=train.py
SM_FRAMEWORK_PARAMS={}
SM_RESOURCE_CONFIG={"current_group_name":"homogeneousCluster","current_host":"algo-1","current_instance_type":"ml.g4dn.xlarge","hosts":["algo-1"],"instance_groups":[{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}],"network_interface_name":"eth0"}
SM_INPUT_DATA_CONFIG={"training":{"ContentType":"application/x-image","RecordWrapperType":"None","S3DistributionType":"FullyReplicated","TrainingInputMode":"File"}}
SM_OUTPUT_DATA_DIR=/opt/ml/output/data
SM_CHANNELS=["training"]
SM_CURRENT_HOST=algo-1
SM_CURRENT_INSTANCE_TYPE=ml.g4dn.xlarge
SM_CURRENT_INSTANCE_GROUP=homogeneousCluster
SM_CURRENT_INSTANCE_GROUP_HOSTS=["algo-1"]
SM_INSTANCE_GROUPS=["homogeneousCluster"]
SM_INSTANCE_GROUPS_DICT={"homogeneousCluster":{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}}
SM_DISTRIBUTION_INSTANCE_GROUPS=[]
SM_IS_HETERO=false
SM_MODULE_NAME=train
SM_LOG_LEVEL=20
SM_FRAMEWORK_MODULE=sagemaker_pytorch_container.training:main
SM_INPUT_DIR=/opt/ml/input
SM_INPUT_CONFIG_DIR=/opt/ml/input/config
SM_OUTPUT_DIR=/opt/ml/output
SM_NUM_CPUS=4
SM_NUM_GPUS=1
SM_NUM_NEURONS=0
SM_MODEL_DIR=/opt/ml/model
SM_MODULE_DIR=s3://####################/sagemaker-2023-07-04-07-46-10-310/source/sourcedir.tar.gz
SM_TRAINING_ENV={"additional_framework_parameters":{},"channel_input_dirs":{"training":"/opt/ml/input/data/training"},"current_host":"algo-1","current_instance_group":"homogeneousCluster","current_instance_group_hosts":["algo-1"],"current_instance_type":"ml.g4dn.xlarge","distribution_hosts":[],"distribution_instance_groups":[],"framework_module":"sagemaker_pytorch_container.training:main","hosts":["algo-1"],"hyperparameters":{"batch-size":8,"cfg":"yolov5s.yaml","data":"coco128.yaml","epochs":3,"project":"/opt/ml/model/"},"input_config_dir":"/opt/ml/input/config","input_data_config":{"training":{"ContentType":"application/x-image","RecordWrapperType":"None","S3DistributionType":"FullyReplicated","TrainingInputMode":"File"}},"input_dir":"/opt/ml/input","instance_groups":["homogeneousCluster"],"instance_groups_dict":{"homogeneousCluster":{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}},"is_hetero":false,"is_master":true,"is_modelparallel_enabled":null,"is_smddpmprun_installed":true,"job_name":"sagemaker-2023-07-04-07-46-10-310","log_level":20,"master_hostname":"algo-1","model_dir":"/opt/ml/model","module_dir":"s3://####################/sagemaker-2023-07-04-07-46-10-310/source/sourcedir.tar.gz","module_name":"train","network_interface_name":"eth0","num_cpus":4,"num_gpus":1,"num_neurons":0,"output_data_dir":"/opt/ml/output/data","output_dir":"/opt/ml/output","output_intermediate_dir":"/opt/ml/output/intermediate","resource_config":{"current_group_name":"homogeneousCluster","current_host":"algo-1","current_instance_type":"ml.g4dn.xlarge","hosts":["algo-1"],"instance_groups":[{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}],"network_interface_name":"eth0"},"user_entry_point":"train.py"}
SM_USER_ARGS=["--batch-size","8","--cfg","yolov5s.yaml","--data","coco128.yaml","--epochs","3","--project","/opt/ml/model/"]
SM_OUTPUT_INTERMEDIATE_DIR=/opt/ml/output/intermediate
SM_CHANNEL_TRAINING=/opt/ml/input/data/training
SM_HP_BATCH-SIZE=8
SM_HP_CFG=yolov5s.yaml
SM_HP_DATA=coco128.yaml
SM_HP_EPOCHS=3
SM_HP_PROJECT=/opt/ml/model/
PYTHONPATH=/opt/ml/code:/opt/conda/bin:/opt/conda/lib/python310.zip:/opt/conda/lib/python3.10:/opt/conda/lib/python3.10/lib-dynload:/opt/conda/lib/python3.10/site-packages
Invoking script with the following command:
/opt/conda/bin/python3.10 train.py --batch-size 8 --cfg yolov5s.yaml --data coco128.yaml --epochs 3 --project /opt/ml/model/
2023-07-04 07:52:42,517 sagemaker-training-toolkit INFO     Exceptions not imported for SageMaker TF as Tensorflow is not installed.
#033[34m#033[1mtrain: #033[0mweights=yolov5s.pt, cfg=yolov5s.yaml, data=coco128.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=3, batch_size=8, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=/opt/ml/model/, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest
From https://github.com/ultralytics/yolov5
   0004c74..a453a45  master       -> origin/master
* [new branch]      discord-link -> origin/discord-link
* [new branch]      pre-commit-ci-update-config -> origin/pre-commit-ci-update-config
#033[34m#033[1mgithub: #033[0m⚠️ YOLOv5 is out of date by 2 commits. Use 'git pull' or 'git clone https://github.com/ultralytics/yolov5' to update.
YOLOv5 🚀 v7.0-187-g0004c74 Python-3.10.8 torch-2.0.0 CUDA:0 (Tesla T4, 15102MiB)
#033[34m#033[1mhyperparameters: #033[0mlr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
#033[34m#033[1mComet: #033[0mrun 'pip install comet_ml' to automatically track and visualize YOLOv5 🚀 runs in Comet
#033[34m#033[1mTensorBoard: #033[0mStart with 'tensorboard --logdir /opt/ml/model', view at http://localhost:6006/
Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...
0%|          | 0.00/755k [00:00<?, ?B/s]
100%|██████████| 755k/755k [00:00<00:00, 42.6MB/s]
Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s.pt to yolov5s.pt...
0%|          | 0.00/14.1M [00:00<?, ?B/s]
100%|██████████| 14.1M/14.1M [00:00<00:00, 411MB/s]
from  n    params  module                                  arguments
0                -1  1      3520  models.common.Conv                      [3, 32, 6, 2, 2]
1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]
2                -1  1     18816  models.common.C3                        [64, 64, 1]
3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]
4                -1  2    115712  models.common.C3                        [128, 128, 2]
5                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]
6                -1  3    625152  models.common.C3                        [256, 256, 3]
7                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]
8                -1  1   1182720  models.common.C3                        [512, 512, 1]
9                -1  1    656896  models.common.SPPF                      [512, 512, 5]
10                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]
11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']
12           [-1, 6]  1         0  models.common.Concat                    [1]
13                -1  1    361984  models.common.C3                        [512, 256, 1, False]
14                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]
15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']
16           [-1, 4]  1         0  models.common.Concat                    [1]
17                -1  1     90880  models.common.C3                        [256, 128, 1, False]
18                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]
19          [-1, 14]  1         0  models.common.Concat                    [1]
20                -1  1    296448  models.common.C3                        [256, 256, 1, False]
21                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]
22          [-1, 10]  1         0  models.common.Concat                    [1]
23                -1  1   1182720  models.common.C3                        [512, 512, 1, False]
24      [17, 20, 23]  1    229245  models.yolo.Detect                      [80, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
YOLOv5s summary: 214 layers, 7235389 parameters, 7235389 gradients, 16.6 GFLOPs
Transferred 348/349 items from yolov5s.pt
#033[34m#033[1mAMP: #033[0mchecks passed ✅
#033[34m#033[1moptimizer:#033[0m SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 60 weight(decay=0.0005), 60 bias
#033[34m#033[1mtrain: #033[0mScanning /opt/ml/input/data/training/labels/train2017...:   0%|          | 0/128 [00:00<?, ?it/s]
#033[34m#033[1mtrain: #033[0mScanning /opt/ml/input/data/training/labels/train2017... 126 images, 2 backgrounds, 0 corrupt: 100%|██████████| 128/128 [00:00<00:00, 2417.66it/s]
#033[34m#033[1mtrain: #033[0mNew cache created: /opt/ml/input/data/training/labels/train2017.cache
#033[34m#033[1mval: #033[0mScanning /opt/ml/input/data/training/labels/train2017.cache... 126 images, 2 backgrounds, 0 corrupt: 100%|██████████| 128/128 [00:00<?, ?it/s]
#033[34m#033[1mval: #033[0mScanning /opt/ml/input/data/training/labels/train2017.cache... 126 images, 2 backgrounds, 0 corrupt: 100%|██████████| 128/128 [00:00<?, ?it/s]
#033[34m#033[1mAutoAnchor: #033[0m4.27 anchors/target, 0.994 Best Possible Recall (BPR). Current anchors are a good fit to dataset ✅
Plotting labels to /opt/ml/model/exp/labels.jpg...
Image sizes 640 train, 640 val
Using 4 dataloader workers
Logging results to #033[1m/opt/ml/model/exp#033[0m
Starting training for 3 epochs...
Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
0%|          | 0/16 [00:00<?, ?it/s]
0/2      1.72G    0.04263    0.04785    0.02002         84        640:   0%|          | 0/16 [00:00<?, ?it/s]
0/2      1.72G    0.04263    0.04785    0.02002         84        640:   6%|▋         | 1/16 [00:00<00:07,  2.00it/s]
0/2      1.86G    0.04137     0.0532    0.01919         77        640:   6%|▋         | 1/16 [00:00<00:07,  2.00it/s]
0/2      1.86G    0.04137     0.0532    0.01919         77        640:  12%|█▎        | 2/16 [00:00<00:04,  3.39it/s]
0/2      1.86G    0.04399    0.05919    0.01962         86        640:  12%|█▎        | 2/16 [00:00<00:04,  3.39it/s]
0/2      1.86G    0.04399    0.05919    0.01962         86        640:  19%|█▉        | 3/16 [00:00<00:03,  3.98it/s]
0/2      1.86G     0.0457    0.06293    0.01933        123        640:  19%|█▉        | 3/16 [00:01<00:03,  3.98it/s]#015        0/2      1.86G     0.0457    0.06293    0.01933        123        640:  25%|██▌       | 4/16 [00:01<00:03,  3.71it/s]
0/2      1.86G    0.04631    0.06611    0.01771        115        640:  25%|██▌       | 4/16 [00:01<00:03,  3.71it/s]
0/2      1.86G    0.04631    0.06611    0.01771        115        640:  31%|███▏      | 5/16 [00:01<00:02,  4.62it/s]
0/2      1.86G    0.04695    0.06591    0.01847        114        640:  31%|███▏      | 5/16 [00:01<00:02,  4.62it/s]#015        0/2      1.86G    0.04695    0.06591    0.01847        114        640:  38%|███▊      | 6/16 [00:01<00:01,  5.28it/s]
0/2      1.86G    0.04622    0.06352    0.01832         78        640:  38%|███▊      | 6/16 [00:01<00:01,  5.28it/s]#015        0/2      1.86G    0.04622    0.06352    0.01832         78        640:  44%|████▍     | 7/16 [00:01<00:01,  5.99it/s]
0/2      1.86G    0.04573    0.06442      0.018        118        640:  44%|████▍     | 7/16 [00:01<00:01,  5.99it/s]
0/2      1.86G    0.04573    0.06442      0.018        118        640:  50%|█████     | 8/16 [00:01<00:01,  6.63it/s]
0/2      1.86G    0.04537    0.06323    0.01781         76        640:  50%|█████     | 8/16 [00:01<00:01,  6.63it/s]
0/2      1.86G    0.04574    0.06244    0.01824         91        640:  50%|█████     | 8/16 [00:01<00:01,  6.63it/s]
0/2      1.86G    0.04574    0.06244    0.01824         91        640:  62%|██████▎   | 10/16 [00:01<00:00,  7.67it/s]
0/2      1.86G    0.04525    0.06201    0.01792         96        640:  62%|██████▎   | 10/16 [00:01<00:00,  7.67it/s]
0/2      1.86G    0.04525    0.06201    0.01792         96        640:  69%|██████▉   | 11/16 [00:01<00:00,  8.13it/s]
0/2      1.86G    0.04521     0.0621    0.01862        103        640:  69%|██████▉   | 11/16 [00:02<00:00,  8.13it/s]#015        0/2      1.86G    0.04521     0.0621    0.01862        103        640:  75%|███████▌  | 12/16 [00:02<00:00,  7.87it/s]
0/2      1.86G    0.04485    0.06149     0.0183         91        640:  75%|███████▌  | 12/16 [00:02<00:00,  7.87it/s]
0/2      1.86G    0.04485    0.06149     0.0183         91        640:  81%|████████▏ | 13/16 [00:02<00:00,  8.36it/s]
0/2      1.86G    0.04482    0.06218    0.01863        116        640:  81%|████████▏ | 13/16 [00:02<00:00,  8.36it/s]
0/2      1.86G    0.04482    0.06218    0.01863        116        640:  88%|████████▊ | 14/16 [00:02<00:00,  8.19it/s]
0/2      1.86G    0.04545    0.06109    0.01889         63        640:  88%|████████▊ | 14/16 [00:02<00:00,  8.19it/s]#015        0/2      1.86G    0.04545    0.06109    0.01889         63        640:  94%|█████████▍| 15/16 [00:02<00:00,  8.26it/s]
0/2      1.86G    0.04523    0.06067    0.01926         82        640:  94%|█████████▍| 15/16 [00:02<00:00,  8.26it/s]#015        0/2      1.86G    0.04523    0.06067    0.01926         82        640: 100%|██████████| 16/16 [00:02<00:00,  8.03it/s]#015        0/2      1.86G    0.04523    0.06067    0.01926         82        640: 100%|██████████| 16/16 [00:02<00:00,  6.20it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:01<00:10,  1.44s/it]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:01<00:04,  1.48it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:01<00:02,  2.10it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:01<00:01,  2.94it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:02<00:00,  3.70it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:02<00:00,  3.92it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:02<00:00,  4.14it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  4.35it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  2.92it/s]
all        128        929      0.732      0.631      0.718      0.477
Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
0%|          | 0/16 [00:00<?, ?it/s]
1/2      2.03G    0.05467    0.06597    0.02623        109        640:   0%|          | 0/16 [00:00<?, ?it/s]
1/2      2.03G    0.04909     0.0572     0.0236         60        640:   0%|          | 0/16 [00:00<?, ?it/s]
1/2      2.03G    0.04909     0.0572     0.0236         60        640:  12%|█▎        | 2/16 [00:00<00:01, 10.01it/s]
1/2      2.03G    0.04965    0.06586    0.02222        137        640:  12%|█▎        | 2/16 [00:00<00:01, 10.01it/s]
1/2      2.04G    0.04856    0.07264    0.02058        143        640:  12%|█▎        | 2/16 [00:00<00:01, 10.01it/s]
1/2      2.04G    0.04856    0.07264    0.02058        143        640:  25%|██▌       | 4/16 [00:00<00:01, 10.01it/s]
1/2      2.04G    0.04746    0.07102    0.01933         91        640:  25%|██▌       | 4/16 [00:00<00:01, 10.01it/s]
1/2      2.04G    0.04695     0.0708    0.01908         94        640:  25%|██▌       | 4/16 [00:00<00:01, 10.01it/s]
1/2      2.04G    0.04695     0.0708    0.01908         94        640:  38%|███▊      | 6/16 [00:00<00:01,  9.95it/s]
1/2      2.04G    0.04689     0.0724    0.01959        135        640:  38%|███▊      | 6/16 [00:00<00:01,  9.95it/s]
1/2      2.04G    0.04749    0.07476    0.01983        159        640:  38%|███▊      | 6/16 [00:00<00:01,  9.95it/s]
1/2      2.04G    0.04749    0.07476    0.01983        159        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
1/2      2.04G    0.04698    0.07365    0.01919         97        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
1/2      2.04G     0.0468    0.07334    0.01888        109        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
1/2      2.04G     0.0468    0.07334    0.01888        109        640:  62%|██████▎   | 10/16 [00:00<00:00,  9.99it/s]
1/2      2.04G    0.04633    0.07145      0.019         88        640:  62%|██████▎   | 10/16 [00:01<00:00,  9.99it/s]
1/2      2.04G    0.04585       0.07      0.019         79        640:  62%|██████▎   | 10/16 [00:01<00:00,  9.99it/s]
1/2      2.04G    0.04585       0.07      0.019         79        640:  75%|███████▌  | 12/16 [00:01<00:00,  9.89it/s]
1/2      2.04G    0.04636    0.06949    0.01866        104        640:  75%|███████▌  | 12/16 [00:01<00:00,  9.89it/s]
1/2      2.04G    0.04635    0.06968    0.01835        120        640:  75%|███████▌  | 12/16 [00:01<00:00,  9.89it/s]
1/2      2.04G    0.04635    0.06968    0.01835        120        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.15it/s]
1/2      2.04G    0.04637    0.06777    0.01839         76        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.15it/s]
1/2      2.04G    0.04622    0.06747    0.01825        116        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.15it/s]
1/2      2.04G    0.04622    0.06747    0.01825        116        640: 100%|██████████| 16/16 [00:01<00:00,  8.42it/s]#015        1/2      2.04G    0.04622    0.06747    0.01825        116        640: 100%|██████████| 16/16 [00:01<00:00,  9.33it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:00<00:00,  7.77it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:00<00:00,  7.41it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:00<00:00,  7.31it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:00<00:00,  7.30it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:00<00:00,  7.08it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:00<00:00,  6.67it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:01<00:00,  6.77it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  6.87it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  6.99it/s]
all        128        929      0.785      0.629      0.738      0.498
Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
0%|          | 0/16 [00:00<?, ?it/s]
2/2      2.04G    0.04802     0.1227    0.01417        195        640:   0%|          | 0/16 [00:00<?, ?it/s]
2/2      2.04G    0.04561    0.08766    0.01594        101        640:   0%|          | 0/16 [00:00<?, ?it/s]
2/2      2.04G    0.04561    0.08766    0.01594        101        640:  12%|█▎        | 2/16 [00:00<00:01,  9.64it/s]
2/2      2.04G    0.04542    0.07617    0.01757         86        640:  12%|█▎        | 2/16 [00:00<00:01,  9.64it/s]
2/2      2.04G    0.04423    0.07265    0.01708         98        640:  12%|█▎        | 2/16 [00:00<00:01,  9.64it/s]
2/2      2.04G    0.04423    0.07265    0.01708         98        640:  25%|██▌       | 4/16 [00:00<00:01, 10.27it/s]
2/2      2.04G    0.04398    0.07078    0.01723        111        640:  25%|██▌       | 4/16 [00:00<00:01, 10.27it/s]
2/2      2.04G    0.04369    0.07246    0.01751        113        640:  25%|██▌       | 4/16 [00:00<00:01, 10.27it/s]
2/2      2.04G    0.04369    0.07246    0.01751        113        640:  38%|███▊      | 6/16 [00:00<00:01, 10.00it/s]
2/2      2.04G    0.04346    0.06956      0.018        102        640:  38%|███▊      | 6/16 [00:00<00:01, 10.00it/s]
2/2      2.04G    0.04342    0.06977    0.01773        118        640:  38%|███▊      | 6/16 [00:00<00:01, 10.00it/s]
2/2      2.04G    0.04342    0.06977    0.01773        118        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
2/2      2.04G    0.04328    0.06999    0.01823        102        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
2/2      2.04G    0.04326    0.06942    0.01802        113        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
2/2      2.04G    0.04326    0.06942    0.01802        113        640:  62%|██████▎   | 10/16 [00:00<00:00, 10.05it/s]
2/2      2.04G    0.04364    0.06832    0.01798        118        640:  62%|██████▎   | 10/16 [00:01<00:00, 10.05it/s]
2/2      2.04G    0.04363    0.06963    0.01759        140        640:  62%|██████▎   | 10/16 [00:01<00:00, 10.05it/s]
2/2      2.04G    0.04363    0.06963    0.01759        140        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.25it/s]
2/2      2.04G    0.04389    0.06915     0.0175        107        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.25it/s]
2/2      2.04G    0.04385     0.0688    0.01785         98        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.25it/s]
2/2      2.04G    0.04385     0.0688    0.01785         98        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.07it/s]
2/2      2.04G    0.04383    0.06737    0.01852         62        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.07it/s]
2/2      2.04G    0.04365    0.06745    0.01911         96        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.07it/s]
2/2      2.04G    0.04365    0.06745    0.01911         96        640: 100%|██████████| 16/16 [00:01<00:00,  8.03it/s]#015        2/2      2.04G    0.04365    0.06745    0.01911         96        640: 100%|██████████| 16/16 [00:01<00:00,  9.17it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:00<00:00,  7.89it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:00<00:00,  7.56it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:00<00:00,  7.36it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:00<00:00,  7.44it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:00<00:00,  6.98it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:00<00:00,  6.80it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:01<00:00,  6.67it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  6.90it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  7.03it/s]
all        128        929      0.819      0.627      0.747      0.504
3 epochs completed in 0.004 hours.
Optimizer stripped from /opt/ml/model/exp/weights/last.pt, 14.8MB
Optimizer stripped from /opt/ml/model/exp/weights/best.pt, 14.8MB
Validating /opt/ml/model/exp/weights/best.pt...
Fusing layers...
YOLOv5s summary: 157 layers, 7225885 parameters, 0 gradients, 16.4 GFLOPs
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:00<00:01,  5.84it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:00<00:01,  3.41it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:00<00:01,  2.83it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:01<00:01,  2.61it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:01<00:00,  3.20it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:01<00:00,  3.68it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:01<00:00,  4.16it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  4.61it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  3.76it/s]
all        128        929      0.819      0.627      0.746      0.503
person        128        254        0.9      0.669      0.807      0.523
bicycle        128          6          1      0.331      0.711      0.427
car        128         46      0.859      0.413      0.579      0.243
motorcycle        128          5      0.682        0.8      0.798      0.663
airplane        128          6      0.979          1      0.995      0.755
bus        128          7      0.748      0.714      0.779      0.659
train        128          3          1      0.659      0.863      0.532
truck        128         12      0.664      0.333      0.501      0.242
boat        128          6          1      0.301      0.519      0.252
traffic light        128         14      0.607      0.214      0.377      0.222
stop sign        128          2      0.792          1      0.995      0.772
bench        128          9      0.823       0.52      0.717      0.311
bird        128         16      0.885          1      0.991      0.651
cat        128          4      0.918          1      0.995       0.77
dog        128          9          1      0.653      0.901      0.693
horse        128          2       0.89          1      0.995      0.622
              elephant        128         17      0.972      0.882      0.939      0.651
                  bear        128          1       0.71          1      0.995      0.995
zebra        128          4      0.885          1      0.995       0.93
giraffe        128          9      0.877      0.791      0.962      0.756
backpack        128          6          1      0.562      0.836      0.428
umbrella        128         18       0.79      0.629      0.877      0.529
handbag        128         19      0.959      0.158      0.337      0.188
tie        128          7      0.817      0.645      0.777      0.486
              suitcase        128          4      0.866          1      0.995      0.601
               frisbee        128          5      0.735        0.8        0.8      0.627
skis        128          1      0.827          1      0.995      0.497
             snowboard        128          7       0.85      0.714      0.867      0.544
sports ball        128          6      0.685      0.667      0.668      0.346
kite        128         10      0.835      0.508      0.628       0.22
baseball bat        128          4      0.521       0.25      0.388      0.171
baseball glove        128          7      0.763      0.429       0.47      0.276
skateboard        128          5      0.725       0.54      0.648      0.479
tennis racket        128          7      0.801      0.429      0.559      0.344
bottle        128         18      0.588      0.333      0.601       0.31
wine glass        128         16      0.735      0.875       0.89      0.448
cup        128         36      0.902      0.667      0.839       0.52
                  fork        128          6          1      0.311      0.439      0.302
knife        128         16      0.829      0.625      0.704      0.393
spoon        128         22      0.828      0.439      0.637      0.363
bowl        128         28          1       0.63      0.763      0.573
banana        128          1      0.809          1      0.995      0.302
sandwich        128          2          1          0      0.448      0.383
orange        128          4      0.829          1      0.995      0.738
broccoli        128         11      0.824      0.364      0.491      0.356
carrot        128         24      0.685      0.625      0.713      0.487
hot dog        128          2      0.547          1      0.663      0.614
pizza        128          5          1      0.792      0.962       0.77
donut        128         14      0.674          1      0.946      0.799
cake        128          4      0.774          1      0.995      0.846
chair        128         35      0.612      0.632      0.619      0.319
couch        128          6          1      0.646      0.826      0.527
          potted plant        128         14      0.903      0.786      0.875      0.508
bed        128          3          1          0      0.863      0.532
          dining table        128         13      0.804      0.317      0.621      0.407
toilet        128          2      0.857          1      0.995      0.796
                    tv        128          2      0.751          1      0.995      0.796
                laptop        128          3          1          0      0.913      0.548
                 mouse        128          2          1          0     0.0907     0.0454
                remote        128          8          1      0.617      0.629      0.513
cell phone        128          8      0.722      0.332      0.453      0.262
             microwave        128          3      0.848          1      0.995      0.843
oven        128          5      0.667        0.4       0.43      0.298
sink        128          6      0.272      0.167      0.338      0.252
refrigerator        128          5      0.672        0.8       0.81      0.558
book        128         29      0.749      0.206      0.367      0.168
clock        128          9      0.762      0.778      0.879      0.689
vase        128          2      0.439          1      0.995      0.895
scissors        128          1          1          0      0.166     0.0332
            teddy bear        128         21       0.85      0.571      0.788      0.506
            toothbrush        128          5      0.826          1      0.995      0.618
Results saved to #033[1m/opt/ml/model/exp#033[0m
2023-07-04 07:53:23,480 sagemaker-training-toolkit INFO     Waiting for the process to finish and give a return code.
2023-07-04 07:53:23,480 sagemaker-training-toolkit INFO     Done waiting for a return code. Received 0 from exiting process.
2023-07-04 07:53:23,480 sagemaker-training-toolkit INFO     Reporting training SUCCESS

2023-07-04 07:53:38 Uploading - Uploading generated training model
2023-07-04 07:53:38 Completed - Training job completed
Training seconds: 368
Billable seconds: 368

 

SageMaker에서 S3 버킷에 저장된 기계 학습 데이터를 사용하는 작업을 완료하였습니다.
이제 기계 학습 시 사용하는 기계 학습 데이터를 S3 버킷에 저장 및 관리하면서 기계 학습을 사용해보시기 바랍니다.

 

 

 

지금까지 SageMaker에서 S3 버킷에 저장된 기계 학습 데이터를 사용해보는 작업을 알아보는 시간이었습니다....! 끝...!

 

 

 

[AWS] SageMaker에서 PyTorch를 활용한 기계 학습 환경 구축하기

AI(인공 지능)의 발전과 적용 분야의 다양화로 인해 기계 학습에 대한 수요가 높아지고 있는데요. 기계 학습 환경을 구축하기 위해서는 여러가지 요소들이 필요합니다.


AWS에서 자체 제공하는 기계 학습 플랫폼인 SageMaker를 사용하여 기계 학습 환경을 구현해보도록 하겠습니다.

 

Amazon SageMaker에 대한 기본적인 정보는 이전 포스트를 참고하시기 바랍니다.

 

 


기계 학습 환경

구현해보고자하는 기계 학습 환경 정보입니다. 

다양한 기계 학습 라이브러리, 학습 모델, 데이터셋 등을 사용하실 수 있습니다.

 

기계 학습 라이브러리

  • 기계 학습 라이브러리는 오픈소스 머신 러닝 라이브러리인 PyTorch를 사용하여 기계 학습 환경을 구현해보도록 하겠습니다.

기계 학습 모델

  • 기계 학습 모델은 Object Detection 분야에서 많이 알려진 YOLOv5모델을 사용하도록 하겠습니다.

기계 학습 데이터

  • 기계 학습 데이터는 COCO dataset을 사용하도록 하겠습니다.

개발 환경

  • 개발 환경은 기계 학습을 위한 완전한 IDE(통합 개발 환경)을 제공하는 Amazon SageMaker Studio를 사용하도록 하겠습니다.
  • Studio에서 학습 코드와 학습 데이터를 구성하고 바로 기계 학습을 할 수 있도록 구성해보겠습니다.

 

 


개발 환경 설정

개발 환경 설정을 위해 Amazon SageMaker Studio를 사용합니다.


Studio에서는 Jupyter Notebook 파일(ipynb)로 기계 학습 코드를 실행하거나 Terminal을 통해 개발 환경을 구성할 수 있습니다. 각각의 요소들을 하나씩 구현해보도록 하겠습니다.

 

 

기계 학습 모델 다운로드

Terminal을 실행하여 기계 학습 모델은 YOLOv5를 다운로드 받습니다.

 

git clone 명령어를 통해 github 프로젝트를 다운로드 받습니다.

git clone https://github.com/ultralytics/yolov5.git

 

 

다운로드 완료 시 기계 학습 모델 코드가 정상적으로 다운로드 되었는지 확인하실 수 있습니다.

 

 

Jupyter Notebook 실행

Studio에서 Jupyter Notebook을 실행하기 위해 Notebook을 추가합니다.

 

 

Image는 PyTorch 라이브러리를 사용하며 기계 학습을 실행할 수 있도록 PyTorch 2.0.0 Python 3.10 CPU Optimized를 선택하였습니다.


Instance type을 GPU Instance를 사용 시 GPU Optimized를 선택해주시면 되고, 그렇지 않다면 원하는 타입을 선택 후 진행해주시면 됩니다.

 

 

생성된 Notebook은 오른쪽 클릭 후 이름을 변경하였습니다.

 

 

왼쪽 메뉴에 있는 Running Terminals and Kernels 버튼을 클릭하여 현재 Studio에서 실행되고 있는 리소스들을 확인하실 수 있습니다.

 

 


기계 학습 코드 작성

다운로드 받은 기계 학습 모델을 통해 Notebook에서 python 코드를 바로 실행하면 기계 학습을 실행할 수 있습니다.

!python train.py --data coco128.yaml --cfg yolov5s.yaml  --epochs 3 --batch-size 8 --weights ''

하지만 SageMaker에서 제공하는 SDK를 통해 기계 학습 환경을 구성할 것이므로, SageMaker의 SDK를 사용해보도록 합시다.

 

 

기계 학습 코드 - 기본 설정

기계 학습을 위해 기본 SageMaker 관련 설정과 Estimator를 설정해야됩니다.


Amazon SageMaker의 Estimator는 기계 학습 모델을 학습 및 배포하기 위한 고수준 추상화 인터페이스입니다.
Estimator를 사용하면 다양한 기계 학습 작업을 쉽게 관리하고 실행할 수 있습니다.

import sagemaker

#========== 기본설정 ==========
# Session 생성
sagemaker_session = sagemaker.Session()

# IAM role
role = sagemaker.get_execution_role()

#========== 학습 설정 ==========
# Estimator 설정
est_pytorch_entry_point= 'train.py'
est_pytorch_image_uri = '{ECR_URL}/sagemaker:pytorch-training-2.0.0-gpu-py310-cu118-ubuntu20.04-sagemaker'
est_pytorch_framework_version = '2.0.0'
est_pytorch_py_version = 'py310'
est_pytorch_instance_type = 'ml.g4dn.xlarge'
est_pytorch_instance_count = 1
est_pytorch_source_dir = './'

# Hyperparameters 설정
est_pytorch_hyperparameters={
    'data': 'coco128.yaml',
    'cfg': 'yolov5s.yaml',
    'epochs': 3,
    'project' : '/opt/ml/model',
    'batch-size': 8
}
  1. YOLOv5 모델 프로젝트의 기본 학습 코드 인 train.py 파일을 사용합니다.
  2. 기계 학습 시 사용할 PyTorch, Python 버전과 컨테이너 이미지를 지정합니다.
    • 별도의 컨테이너 이미지를 지정하지 않아도 SageMaker에서 자체 제공하는 이미지를 통해 기계 학습이 실행됩니다.
  3. 기계 학습 시 사용할 데이터 셋 및 옵션을 선택합니다.
    • coco128.yml 데이터셋을 지정하고, 모델은 YOLOv5s를 선택하였습니다.
    • epochs 값은 3, batch-size는 8로 설정하였으며 SageMaker 기본 모델 저장 경로를 지정하기 위해 project 값은 /opt/ml/model로 설정하였습니다.

 

 

기계 학습 코드 - Estimator 생성

기계 학습을 실행하기 위한 Estimator를 생성 작업을 진행합니다.


사전에 설정한 정보를 통해 Estimator를 생성합니다.

from sagemaker.pytorch import PyTorch
from sagemaker.inputs import TrainingInput

# Estimator 생성
pytorch_estimator = PyTorch(
    entry_point=est_pytorch_entry_point,
    image_uri=est_pytorch_image_uri,
    framework_version=est_pytorch_framework_version,
    py_version=est_pytorch_py_version,
    instance_type=est_pytorch_instance_type,
    instance_count=est_pytorch_instance_count,
    source_dir=est_pytorch_source_dir,
    sagemaker_session=sagemaker_session,
    role=role,
    hyperparameters=est_pytorch_hyperparameters
)

 

 

기계 학습 코드 - 학습 시작

 pytorch_estimator 이름으로 생성한 Estimator를 실행합니다.


 .fit() 함수를 통해 학습을 시작합니다.

# 학습 시작
pytorch_estimator.fit()

 

 

 

기계 학습 코드 - 모델 저장 경로 확인

기계 학습 완료 후 아래 명령어를 통해 저장된 모델 파일 및 경로를 확인할 수 있습니다.

# 학습된 모델 아티팩트의 S3 경로
model_data = pytorch_estimator.model_data

# S3에 저장된 weights 파일 확인
print("Model artifacts saved at:", model_data)

 

 


기계 학습 코드 실행

작성한 기계 학습 코드를 실행해보도록 하겠습니다.

 

Estimator의 fit 함수를 실행합니다.

 

 

기계 학습 완료 시 생성된 모델 경로와 성공 여부, 학습 시간 등을 확인하실 수 있습니다.

 

 

전체 학습 상세 로그는 아래 버튼을 클릭하여 확인하시기 바랍니다.

학습 상세 로그
Using provided s3_resource
INFO:sagemaker:Creating training-job with name: sagemaker-2023-06-30-08-49-38-688
2023-06-30 08:49:43 Starting - Starting the training job...
2023-06-30 08:50:00 Starting - Preparing the instances for training......
2023-06-30 08:51:00 Downloading - Downloading input data...
2023-06-30 08:51:20 Training - Downloading the training image.................................
2023-06-30 08:56:55 Training - Training image download completed. Training in progress.bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
2023-06-30 08:57:05,915 sagemaker-training-toolkit INFO     Imported framework sagemaker_pytorch_container.training
2023-06-30 08:57:05,930 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-06-30 08:57:05,939 sagemaker_pytorch_container.training INFO     Block until all host DNS lookups succeed.
2023-06-30 08:57:05,944 sagemaker_pytorch_container.training INFO     Invoking user training script.
2023-06-30 08:57:08,222 sagemaker-training-toolkit INFO     Installing dependencies from requirements.txt:
/opt/conda/bin/python3.10 -m pip install -r requirements.txt
Collecting gitpython>=3.1.30 (from -r requirements.txt (line 5))
Downloading GitPython-3.1.31-py3-none-any.whl (184 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 184.3/184.3 kB 13.1 MB/s eta 0:00:00
Requirement already satisfied: matplotlib>=3.3 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 6)) (3.7.1)
Requirement already satisfied: numpy>=1.18.5 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 7)) (1.23.5)
Requirement already satisfied: opencv-python>=4.1.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 8)) (4.7.0)
Requirement already satisfied: Pillow>=7.1.2 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 9)) (9.4.0)
Requirement already satisfied: psutil in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 10)) (5.9.5)
Requirement already satisfied: PyYAML>=5.3.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 11)) (5.4.1)
Requirement already satisfied: requests>=2.23.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 12)) (2.28.2)
Requirement already satisfied: scipy>=1.4.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 13)) (1.10.1)
Collecting thop>=0.1.1 (from -r requirements.txt (line 14))
Downloading thop-0.1.1.post2209072238-py3-none-any.whl (15 kB)
Requirement already satisfied: torch>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 15)) (2.0.0)
Requirement already satisfied: torchvision>=0.8.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 16)) (0.15.1)
Requirement already satisfied: tqdm>=4.64.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 17)) (4.65.0)
Collecting ultralytics>=8.0.111 (from -r requirements.txt (line 18))
Downloading ultralytics-8.0.124-py3-none-any.whl (612 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 612.6/612.6 kB 35.5 MB/s eta 0:00:00
Requirement already satisfied: pandas>=1.1.4 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 27)) (2.0.1)
Requirement already satisfied: seaborn>=0.11.0 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 28)) (0.12.2)
Requirement already satisfied: setuptools>=65.5.1 in /opt/conda/lib/python3.10/site-packages (from -r requirements.txt (line 42)) (65.6.3)
Collecting gitdb<5,>=4.0.1 (from gitpython>=3.1.30->-r requirements.txt (line 5))
Downloading gitdb-4.0.10-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.7/62.7 kB 17.3 MB/s eta 0:00:00
Requirement already satisfied: contourpy>=1.0.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (1.0.7)
Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (4.39.4)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (1.4.4)
Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (23.1)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/lib/python3.10/site-packages (from matplotlib>=3.3->-r requirements.txt (line 6)) (2.8.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests>=2.23.0->-r requirements.txt (line 12)) (2023.5.7)
Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (3.12.0)
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (4.5.0)
Requirement already satisfied: sympy in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (1.11.1)
Requirement already satisfied: networkx in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (3.1)
Requirement already satisfied: jinja2 in /opt/conda/lib/python3.10/site-packages (from torch>=1.7.0->-r requirements.txt (line 15)) (3.1.2)
Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.10/site-packages (from pandas>=1.1.4->-r requirements.txt (line 27)) (2023.3)
Requirement already satisfied: tzdata>=2022.1 in /opt/conda/lib/python3.10/site-packages (from pandas>=1.1.4->-r requirements.txt (line 27)) (2023.3)
Collecting smmap<6,>=3.0.1 (from gitdb<5,>=4.0.1->gitpython>=3.1.30->-r requirements.txt (line 5))
Downloading smmap-5.0.0-py3-none-any.whl (24 kB)
Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib>=3.3->-r requirements.txt (line 6)) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from jinja2->torch>=1.7.0->-r requirements.txt (line 15)) (2.1.2)
Requirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.10/site-packages (from sympy->torch>=1.7.0->-r requirements.txt (line 15)) (1.3.0)
Installing collected packages: smmap, gitdb, thop, gitpython, ultralytics
Successfully installed gitdb-4.0.10 gitpython-3.1.31 smmap-5.0.0 thop-0.1.1.post2209072238 ultralytics-8.0.124
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
2023-06-30 08:57:10,933 sagemaker-training-toolkit INFO     Waiting for the process to finish and give a return code.
2023-06-30 08:57:10,933 sagemaker-training-toolkit INFO     Done waiting for a return code. Received 0 from exiting process.
2023-06-30 08:57:10,950 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-06-30 08:57:10,975 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-06-30 08:57:10,999 sagemaker-training-toolkit INFO     No Neurons detected (normal if no neurons installed)
2023-06-30 08:57:11,008 sagemaker-training-toolkit INFO     Invoking user script
Training Env:
{
    "additional_framework_parameters": {},
    "channel_input_dirs": {},
    "current_host": "algo-1",
    "current_instance_group": "homogeneousCluster",
    "current_instance_group_hosts": [
        "algo-1"
    ],
    "current_instance_type": "ml.g4dn.xlarge",
    "distribution_hosts": [],
    "distribution_instance_groups": [],
    "framework_module": "sagemaker_pytorch_container.training:main",
    "hosts": [
        "algo-1"
    ],
    "hyperparameters": {
        "batch-size": 8,
        "cfg": "yolov5s.yaml",
        "data": "coco128.yaml",
        "epochs": 3,
        "project": "/opt/ml/model"
    },
    "input_config_dir": "/opt/ml/input/config",
    "input_data_config": {},
    "input_dir": "/opt/ml/input",
    "instance_groups": [
        "homogeneousCluster"
    ],
    "instance_groups_dict": {
        "homogeneousCluster": {
            "instance_group_name": "homogeneousCluster",
            "instance_type": "ml.g4dn.xlarge",
            "hosts": [
                "algo-1"
            ]
        }
    },
    "is_hetero": false,
    "is_master": true,
    "is_modelparallel_enabled": null,
    "is_smddpmprun_installed": true,
    "job_name": "sagemaker-2023-06-30-08-49-38-688",
    "log_level": 20,
    "master_hostname": "algo-1",
    "model_dir": "/opt/ml/model",
    "module_dir": "s3://####################/sagemaker-2023-06-30-08-49-38-688/source/sourcedir.tar.gz",
    "module_name": "train",
    "network_interface_name": "eth0",
    "num_cpus": 4,
    "num_gpus": 1,
    "num_neurons": 0,
    "output_data_dir": "/opt/ml/output/data",
    "output_dir": "/opt/ml/output",
    "output_intermediate_dir": "/opt/ml/output/intermediate",
    "resource_config": {
        "current_host": "algo-1",
        "current_instance_type": "ml.g4dn.xlarge",
        "current_group_name": "homogeneousCluster",
        "hosts": [
            "algo-1"
        ],
        "instance_groups": [
            {
                "instance_group_name": "homogeneousCluster",
                "instance_type": "ml.g4dn.xlarge",
                "hosts": [
                    "algo-1"
                ]
            }
        ],
        "network_interface_name": "eth0"
    },
    "user_entry_point": "train.py"
}
Environment variables:
SM_HOSTS=["algo-1"]
SM_NETWORK_INTERFACE_NAME=eth0
SM_HPS={"batch-size":8,"cfg":"yolov5s.yaml","data":"coco128.yaml","epochs":3,"project":"/opt/ml/model"}
SM_USER_ENTRY_POINT=train.py
SM_FRAMEWORK_PARAMS={}
SM_RESOURCE_CONFIG={"current_group_name":"homogeneousCluster","current_host":"algo-1","current_instance_type":"ml.g4dn.xlarge","hosts":["algo-1"],"instance_groups":[{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}],"network_interface_name":"eth0"}
SM_INPUT_DATA_CONFIG={}
SM_OUTPUT_DATA_DIR=/opt/ml/output/data
SM_CHANNELS=[]
SM_CURRENT_HOST=algo-1
SM_CURRENT_INSTANCE_TYPE=ml.g4dn.xlarge
SM_CURRENT_INSTANCE_GROUP=homogeneousCluster
SM_CURRENT_INSTANCE_GROUP_HOSTS=["algo-1"]
SM_INSTANCE_GROUPS=["homogeneousCluster"]
SM_INSTANCE_GROUPS_DICT={"homogeneousCluster":{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}}
SM_DISTRIBUTION_INSTANCE_GROUPS=[]
SM_IS_HETERO=false
SM_MODULE_NAME=train
SM_LOG_LEVEL=20
SM_FRAMEWORK_MODULE=sagemaker_pytorch_container.training:main
SM_INPUT_DIR=/opt/ml/input
SM_INPUT_CONFIG_DIR=/opt/ml/input/config
SM_OUTPUT_DIR=/opt/ml/output
SM_NUM_CPUS=4
SM_NUM_GPUS=1
SM_NUM_NEURONS=0
SM_MODEL_DIR=/opt/ml/model
SM_MODULE_DIR=s3://####################/sagemaker-2023-06-30-08-49-38-688/source/sourcedir.tar.gz
SM_TRAINING_ENV={"additional_framework_parameters":{},"channel_input_dirs":{},"current_host":"algo-1","current_instance_group":"homogeneousCluster","current_instance_group_hosts":["algo-1"],"current_instance_type":"ml.g4dn.xlarge","distribution_hosts":[],"distribution_instance_groups":[],"framework_module":"sagemaker_pytorch_container.training:main","hosts":["algo-1"],"hyperparameters":{"batch-size":8,"cfg":"yolov5s.yaml","data":"coco128.yaml","epochs":3,"project":"/opt/ml/model"},"input_config_dir":"/opt/ml/input/config","input_data_config":{},"input_dir":"/opt/ml/input","instance_groups":["homogeneousCluster"],"instance_groups_dict":{"homogeneousCluster":{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}},"is_hetero":false,"is_master":true,"is_modelparallel_enabled":null,"is_smddpmprun_installed":true,"job_name":"sagemaker-2023-06-30-08-49-38-688","log_level":20,"master_hostname":"algo-1","model_dir":"/opt/ml/model","module_dir":"s3://####################/sagemaker-2023-06-30-08-49-38-688/source/sourcedir.tar.gz","module_name":"train","network_interface_name":"eth0","num_cpus":4,"num_gpus":1,"num_neurons":0,"output_data_dir":"/opt/ml/output/data","output_dir":"/opt/ml/output","output_intermediate_dir":"/opt/ml/output/intermediate","resource_config":{"current_group_name":"homogeneousCluster","current_host":"algo-1","current_instance_type":"ml.g4dn.xlarge","hosts":["algo-1"],"instance_groups":[{"hosts":["algo-1"],"instance_group_name":"homogeneousCluster","instance_type":"ml.g4dn.xlarge"}],"network_interface_name":"eth0"},"user_entry_point":"train.py"}
SM_USER_ARGS=["--batch-size","8","--cfg","yolov5s.yaml","--data","coco128.yaml","--epochs","3","--project","/opt/ml/model"]
SM_OUTPUT_INTERMEDIATE_DIR=/opt/ml/output/intermediate
SM_HP_BATCH-SIZE=8
SM_HP_CFG=yolov5s.yaml
SM_HP_DATA=coco128.yaml
SM_HP_EPOCHS=3
SM_HP_PROJECT=/opt/ml/model
PYTHONPATH=/opt/ml/code:/opt/conda/bin:/opt/conda/lib/python310.zip:/opt/conda/lib/python3.10:/opt/conda/lib/python3.10/lib-dynload:/opt/conda/lib/python3.10/site-packages
Invoking script with the following command:
/opt/conda/bin/python3.10 train.py --batch-size 8 --cfg yolov5s.yaml --data coco128.yaml --epochs 3 --project /opt/ml/model
2023-06-30 08:57:11,040 sagemaker-training-toolkit INFO     Exceptions not imported for SageMaker TF as Tensorflow is not installed.
#033[34m#033[1mtrain: #033[0mweights=yolov5s.pt, cfg=yolov5s.yaml, data=coco128.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=3, batch_size=8, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=/opt/ml/model, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest
#033[34m#033[1mgithub: #033[0mup to date with https://github.com/ultralytics/yolov5 ✅
YOLOv5 🚀 v7.0-187-g0004c74 Python-3.10.8 torch-2.0.0 CUDA:0 (Tesla T4, 15102MiB)
#033[34m#033[1mhyperparameters: #033[0mlr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
#033[34m#033[1mComet: #033[0mrun 'pip install comet_ml' to automatically track and visualize YOLOv5 🚀 runs in Comet
#033[34m#033[1mTensorBoard: #033[0mStart with 'tensorboard --logdir /opt/ml/model', view at http://localhost:6006/
Dataset not found ⚠️, missing paths ['/opt/ml/datasets/coco128/images/train2017']
Downloading https://ultralytics.com/assets/coco128.zip to coco128.zip...
0%|          | 0.00/6.66M [00:00<?, ?B/s]
100%|██████████| 6.66M/6.66M [00:00<00:00, 258MB/s]
Dataset download success ✅ (0.8s), saved to #033[1m/opt/ml/datasets#033[0m
Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...
0%|          | 0.00/755k [00:00<?, ?B/s]
100%|██████████| 755k/755k [00:00<00:00, 43.8MB/s]
Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s.pt to yolov5s.pt...
0%|          | 0.00/14.1M [00:00<?, ?B/s]
4%|▍         | 560k/14.1M [00:00<00:02, 5.63MB/s]
8%|▊         | 1.09M/14.1M [00:00<00:02, 5.60MB/s]
12%|█▏        | 1.62M/14.1M [00:00<00:02, 5.61MB/s]
17%|█▋        | 2.38M/14.1M [00:00<00:01, 6.49MB/s]
27%|██▋       | 3.80M/14.1M [00:00<00:01, 9.51MB/s]
37%|███▋      | 5.18M/14.1M [00:00<00:00, 10.8MB/s]
54%|█████▍    | 7.69M/14.1M [00:00<00:00, 15.7MB/s]
67%|██████▋   | 9.48M/14.1M [00:00<00:00, 16.6MB/s]
84%|████████▍ | 11.8M/14.1M [00:00<00:00, 19.1MB/s]
97%|█████████▋| 13.7M/14.1M [00:01<00:00, 18.8MB/s]
100%|██████████| 14.1M/14.1M [00:01<00:00, 14.1MB/s]
from  n    params  module                                  arguments
0                -1  1      3520  models.common.Conv                      [3, 32, 6, 2, 2]
1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]
2                -1  1     18816  models.common.C3                        [64, 64, 1]
3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]
4                -1  2    115712  models.common.C3                        [128, 128, 2]
5                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]
6                -1  3    625152  models.common.C3                        [256, 256, 3]
7                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]
8                -1  1   1182720  models.common.C3                        [512, 512, 1]
9                -1  1    656896  models.common.SPPF                      [512, 512, 5]
10                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]
11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']
12           [-1, 6]  1         0  models.common.Concat                    [1]
13                -1  1    361984  models.common.C3                        [512, 256, 1, False]
14                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]
15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']
16           [-1, 4]  1         0  models.common.Concat                    [1]
17                -1  1     90880  models.common.C3                        [256, 128, 1, False]
18                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]
19          [-1, 14]  1         0  models.common.Concat                    [1]
20                -1  1    296448  models.common.C3                        [256, 256, 1, False]
21                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]
22          [-1, 10]  1         0  models.common.Concat                    [1]
23                -1  1   1182720  models.common.C3                        [512, 512, 1, False]
24      [17, 20, 23]  1    229245  models.yolo.Detect                      [80, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
YOLOv5s summary: 214 layers, 7235389 parameters, 7235389 gradients, 16.6 GFLOPs
Transferred 348/349 items from yolov5s.pt
#033[34m#033[1mAMP: #033[0mchecks passed ✅
#033[34m#033[1moptimizer:#033[0m SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 60 weight(decay=0.0005), 60 bias
#033[34m#033[1mtrain: #033[0mScanning /opt/ml/datasets/coco128/labels/train2017...:   0%|          | 0/128 [00:00<?, ?it/s]
#033[34m#033[1mtrain: #033[0mScanning /opt/ml/datasets/coco128/labels/train2017... 126 images, 2 backgrounds, 0 corrupt: 100%|██████████| 128/128 [00:00<00:00, 3075.76it/s]
#033[34m#033[1mtrain: #033[0mNew cache created: /opt/ml/datasets/coco128/labels/train2017.cache
#033[34m#033[1mval: #033[0mScanning /opt/ml/datasets/coco128/labels/train2017.cache... 126 images, 2 backgrounds, 0 corrupt: 100%|██████████| 128/128 [00:00<?, ?it/s]
#033[34m#033[1mval: #033[0mScanning /opt/ml/datasets/coco128/labels/train2017.cache... 126 images, 2 backgrounds, 0 corrupt: 100%|██████████| 128/128 [00:00<?, ?it/s]
#033[34m#033[1mAutoAnchor: #033[0m4.27 anchors/target, 0.994 Best Possible Recall (BPR). Current anchors are a good fit to dataset ✅
Plotting labels to /opt/ml/model/exp/labels.jpg...
Image sizes 640 train, 640 val
Using 4 dataloader workers
Logging results to #033[1m/opt/ml/model/exp#033[0m
Starting training for 3 epochs...
Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
0%|          | 0/16 [00:00<?, ?it/s]
0/2      1.72G    0.04263    0.04785    0.02002         84        640:   0%|          | 0/16 [00:00<?, ?it/s]
0/2      1.72G    0.04263    0.04785    0.02002         84        640:   6%|▋         | 1/16 [00:00<00:09,  1.65it/s]
0/2      1.86G    0.04137     0.0532    0.01919         77        640:   6%|▋         | 1/16 [00:00<00:09,  1.65it/s]
0/2      1.86G    0.04137     0.0532    0.01919         77        640:  12%|█▎        | 2/16 [00:00<00:04,  2.91it/s]
0/2      1.86G    0.04399    0.05919    0.01962         86        640:  12%|█▎        | 2/16 [00:00<00:04,  2.91it/s]
0/2      1.86G    0.04399    0.05919    0.01962         86        640:  19%|█▉        | 3/16 [00:00<00:03,  3.75it/s]
0/2      1.86G     0.0457    0.06293    0.01933        123        640:  19%|█▉        | 3/16 [00:01<00:03,  3.75it/s]
0/2      1.86G     0.0457    0.06293    0.01933        123        640:  25%|██▌       | 4/16 [00:01<00:02,  4.25it/s]
0/2      1.86G    0.04631    0.06611    0.01771        115        640:  25%|██▌       | 4/16 [00:01<00:02,  4.25it/s]
0/2      1.86G    0.04631    0.06611    0.01771        115        640:  31%|███▏      | 5/16 [00:01<00:02,  5.16it/s]
0/2      1.86G    0.04695    0.06591    0.01847        114        640:  31%|███▏      | 5/16 [00:01<00:02,  5.16it/s]
0/2      1.86G    0.04695    0.06591    0.01847        114        640:  38%|███▊      | 6/16 [00:01<00:01,  6.04it/s]
0/2      1.86G    0.04622    0.06352    0.01832         78        640:  38%|███▊      | 6/16 [00:01<00:01,  6.04it/s]
0/2      1.86G    0.04622    0.06352    0.01832         78        640:  44%|████▍     | 7/16 [00:01<00:01,  6.84it/s]
0/2      1.86G    0.04573    0.06442      0.018        118        640:  44%|████▍     | 7/16 [00:01<00:01,  6.84it/s]
0/2      1.86G    0.04573    0.06442      0.018        118        640:  50%|█████     | 8/16 [00:01<00:01,  7.43it/s]
0/2      1.86G    0.04537    0.06323    0.01781         76        640:  50%|█████     | 8/16 [00:01<00:01,  7.43it/s]
0/2      1.86G    0.04574    0.06244    0.01824         91        640:  50%|█████     | 8/16 [00:01<00:01,  7.43it/s]
0/2      1.86G    0.04574    0.06244    0.01824         91        640:  62%|██████▎   | 10/16 [00:01<00:00,  8.43it/s]
0/2      1.86G    0.04525    0.06201    0.01792         96        640:  62%|██████▎   | 10/16 [00:01<00:00,  8.43it/s]
0/2      1.86G    0.04521     0.0621    0.01862        103        640:  62%|██████▎   | 10/16 [00:01<00:00,  8.43it/s]
0/2      1.86G    0.04521     0.0621    0.01862        103        640:  75%|███████▌  | 12/16 [00:01<00:00,  8.92it/s]
0/2      1.86G    0.04485    0.06149     0.0183         91        640:  75%|███████▌  | 12/16 [00:02<00:00,  8.92it/s]
0/2      1.86G    0.04482    0.06218    0.01863        116        640:  75%|███████▌  | 12/16 [00:02<00:00,  8.92it/s]
0/2      1.86G    0.04482    0.06218    0.01863        116        640:  88%|████████▊ | 14/16 [00:02<00:00,  9.25it/s]
0/2      1.86G    0.04545    0.06109    0.01889         63        640:  88%|████████▊ | 14/16 [00:02<00:00,  9.25it/s]
0/2      1.86G    0.04523    0.06067    0.01926         82        640:  88%|████████▊ | 14/16 [00:02<00:00,  9.25it/s]
0/2      1.86G    0.04523    0.06067    0.01926         82        640: 100%|██████████| 16/16 [00:02<00:00,  9.50it/s]#015        0/2      1.86G    0.04523    0.06067    0.01926         82        640: 100%|██████████| 16/16 [00:02<00:00,  6.71it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:01<00:08,  1.26s/it]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:01<00:03,  1.67it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:01<00:02,  2.34it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:01<00:01,  3.15it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:01<00:00,  3.84it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:02<00:00,  3.89it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:02<00:00,  4.17it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  4.39it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  3.10it/s]
all        128        929      0.732      0.631      0.718      0.477
Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
0%|          | 0/16 [00:00<?, ?it/s]
1/2      2.19G    0.05467    0.06597    0.02623        109        640:   0%|          | 0/16 [00:00<?, ?it/s]
1/2      2.19G    0.04909     0.0572     0.0236         60        640:   0%|          | 0/16 [00:00<?, ?it/s]
1/2      2.19G    0.04909     0.0572     0.0236         60        640:  12%|█▎        | 2/16 [00:00<00:01, 10.13it/s]
1/2      2.19G    0.04965    0.06586    0.02222        137        640:  12%|█▎        | 2/16 [00:00<00:01, 10.13it/s]
1/2      2.19G    0.04856    0.07264    0.02058        143        640:  12%|█▎        | 2/16 [00:00<00:01, 10.13it/s]
1/2      2.19G    0.04856    0.07264    0.02058        143        640:  25%|██▌       | 4/16 [00:00<00:01, 10.04it/s]
1/2      2.19G    0.04746    0.07102    0.01933         91        640:  25%|██▌       | 4/16 [00:00<00:01, 10.04it/s]
1/2      2.19G    0.04695     0.0708    0.01908         94        640:  25%|██▌       | 4/16 [00:00<00:01, 10.04it/s]
1/2      2.19G    0.04695     0.0708    0.01908         94        640:  38%|███▊      | 6/16 [00:00<00:01,  9.85it/s]
1/2      2.19G    0.04689     0.0724    0.01959        135        640:  38%|███▊      | 6/16 [00:00<00:01,  9.85it/s]
1/2      2.19G    0.04749    0.07476    0.01983        159        640:  38%|███▊      | 6/16 [00:00<00:01,  9.85it/s]
1/2      2.19G    0.04749    0.07476    0.01983        159        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
1/2      2.19G    0.04698    0.07365    0.01919         97        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
1/2      2.19G     0.0468    0.07334    0.01888        109        640:  50%|█████     | 8/16 [00:00<00:00, 10.21it/s]
1/2      2.19G     0.0468    0.07334    0.01888        109        640:  62%|██████▎   | 10/16 [00:00<00:00, 10.03it/s]
1/2      2.19G    0.04633    0.07145      0.019         88        640:  62%|██████▎   | 10/16 [00:01<00:00, 10.03it/s]
1/2      2.19G    0.04585       0.07      0.019         79        640:  62%|██████▎   | 10/16 [00:01<00:00, 10.03it/s]
1/2      2.19G    0.04585       0.07      0.019         79        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.01it/s]
1/2      2.19G    0.04636    0.06949    0.01866        104        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.01it/s]
1/2      2.19G    0.04635    0.06968    0.01835        120        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.01it/s]
1/2      2.19G    0.04635    0.06968    0.01835        120        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.25it/s]
1/2      2.19G    0.04637    0.06777    0.01839         76        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.25it/s]
1/2      2.19G    0.04622    0.06747    0.01825        116        640:  88%|████████▊ | 14/16 [00:01<00:00, 10.25it/s]
1/2      2.19G    0.04622    0.06747    0.01825        116        640: 100%|██████████| 16/16 [00:01<00:00,  8.37it/s]#015        1/2      2.19G    0.04622    0.06747    0.01825        116        640: 100%|██████████| 16/16 [00:01<00:00,  9.33it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:00<00:00,  7.10it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:00<00:00,  7.13it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:00<00:00,  6.68it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:00<00:00,  6.66it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:00<00:00,  6.84it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:00<00:00,  6.74it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:01<00:00,  6.84it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  6.61it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  6.73it/s]
all        128        929      0.785      0.629      0.738      0.498
Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
0%|          | 0/16 [00:00<?, ?it/s]
2/2       2.2G    0.04802     0.1227    0.01417        195        640:   0%|          | 0/16 [00:00<?, ?it/s]
2/2       2.2G    0.04561    0.08766    0.01594        101        640:   0%|          | 0/16 [00:00<?, ?it/s]
2/2       2.2G    0.04561    0.08766    0.01594        101        640:  12%|█▎        | 2/16 [00:00<00:01,  9.72it/s]
2/2       2.2G    0.04542    0.07617    0.01757         86        640:  12%|█▎        | 2/16 [00:00<00:01,  9.72it/s]
2/2       2.2G    0.04423    0.07265    0.01708         98        640:  12%|█▎        | 2/16 [00:00<00:01,  9.72it/s]
2/2       2.2G    0.04423    0.07265    0.01708         98        640:  25%|██▌       | 4/16 [00:00<00:01, 10.23it/s]
2/2       2.2G    0.04398    0.07078    0.01723        111        640:  25%|██▌       | 4/16 [00:00<00:01, 10.23it/s]
2/2       2.2G    0.04369    0.07246    0.01751        113        640:  25%|██▌       | 4/16 [00:00<00:01, 10.23it/s]
2/2       2.2G    0.04369    0.07246    0.01751        113        640:  38%|███▊      | 6/16 [00:00<00:00, 10.09it/s]
2/2       2.2G    0.04346    0.06956      0.018        102        640:  38%|███▊      | 6/16 [00:00<00:00, 10.09it/s]
2/2       2.2G    0.04342    0.06977    0.01773        118        640:  38%|███▊      | 6/16 [00:00<00:00, 10.09it/s]
2/2       2.2G    0.04342    0.06977    0.01773        118        640:  50%|█████     | 8/16 [00:00<00:00, 10.27it/s]
2/2       2.2G    0.04328    0.06999    0.01823        102        640:  50%|█████     | 8/16 [00:00<00:00, 10.27it/s]
2/2       2.2G    0.04326    0.06942    0.01802        113        640:  50%|█████     | 8/16 [00:00<00:00, 10.27it/s]
2/2       2.2G    0.04326    0.06942    0.01802        113        640:  62%|██████▎   | 10/16 [00:00<00:00, 10.14it/s]
2/2       2.2G    0.04364    0.06832    0.01798        118        640:  62%|██████▎   | 10/16 [00:01<00:00, 10.14it/s]
2/2       2.2G    0.04363    0.06963    0.01759        140        640:  62%|██████▎   | 10/16 [00:01<00:00, 10.14it/s]
2/2       2.2G    0.04363    0.06963    0.01759        140        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.36it/s]
2/2       2.2G    0.04389    0.06915     0.0175        107        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.36it/s]
2/2       2.2G    0.04385     0.0688    0.01785         98        640:  75%|███████▌  | 12/16 [00:01<00:00, 10.36it/s]
2/2       2.2G    0.04385     0.0688    0.01785         98        640:  88%|████████▊ | 14/16 [00:01<00:00,  9.54it/s]
2/2       2.2G    0.04383    0.06737    0.01852         62        640:  88%|████████▊ | 14/16 [00:01<00:00,  9.54it/s]
2/2       2.2G    0.04365    0.06745    0.01911         96        640:  88%|████████▊ | 14/16 [00:01<00:00,  9.54it/s]
2/2       2.2G    0.04365    0.06745    0.01911         96        640: 100%|██████████| 16/16 [00:01<00:00,  8.02it/s]#015        2/2       2.2G    0.04365    0.06745    0.01911         96        640: 100%|██████████| 16/16 [00:01<00:00,  9.14it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:00<00:00,  7.91it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:00<00:00,  7.70it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:00<00:00,  7.29it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:00<00:00,  7.22it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:00<00:00,  7.08it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:00<00:00,  6.85it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:01<00:00,  6.53it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  6.88it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:01<00:00,  7.00it/s]
all        128        929      0.819      0.627      0.747      0.504
3 epochs completed in 0.004 hours.
Optimizer stripped from /opt/ml/model/exp/weights/last.pt, 14.8MB
Optimizer stripped from /opt/ml/model/exp/weights/best.pt, 14.8MB
Validating /opt/ml/model/exp/weights/best.pt...
Fusing layers...
YOLOv5s summary: 157 layers, 7225885 parameters, 0 gradients, 16.4 GFLOPs
Class     Images  Instances          P          R      mAP50   mAP50-95:   0%|          | 0/8 [00:00<?, ?it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  12%|█▎        | 1/8 [00:00<00:01,  5.90it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  25%|██▌       | 2/8 [00:00<00:01,  3.32it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  38%|███▊      | 3/8 [00:01<00:01,  2.74it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  50%|█████     | 4/8 [00:01<00:01,  2.66it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  62%|██████▎   | 5/8 [00:01<00:00,  3.31it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  75%|███████▌  | 6/8 [00:01<00:00,  3.88it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95:  88%|████████▊ | 7/8 [00:01<00:00,  4.44it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  4.97it/s]
Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:02<00:00,  3.91it/s]
all        128        929      0.819      0.627      0.746      0.503
person        128        254        0.9      0.669      0.807      0.523
bicycle        128          6          1      0.331      0.711      0.427
                   car        128         46      0.859      0.413      0.579      0.243
motorcycle        128          5      0.682        0.8      0.798      0.663
              airplane        128          6      0.979          1      0.995      0.755
                   bus        128          7      0.748      0.714      0.779      0.659
train        128          3          1      0.659      0.863      0.532
truck        128         12      0.664      0.333      0.501      0.242
boat        128          6          1      0.301      0.519      0.252
traffic light        128         14      0.607      0.214      0.377      0.222
stop sign        128          2      0.792          1      0.995      0.772
bench        128          9      0.823       0.52      0.717      0.311
bird        128         16      0.885          1      0.991      0.651
cat        128          4      0.918          1      0.995       0.77
dog        128          9          1      0.653      0.901      0.693
horse        128          2       0.89          1      0.995      0.622
elephant        128         17      0.972      0.882      0.939      0.651
bear        128          1       0.71          1      0.995      0.995
zebra        128          4      0.885          1      0.995       0.93
giraffe        128          9      0.877      0.791      0.962      0.756
backpack        128          6          1      0.562      0.836      0.428
umbrella        128         18       0.79      0.629      0.877      0.529
handbag        128         19      0.959      0.158      0.337      0.188
tie        128          7      0.817      0.645      0.777      0.486
suitcase        128          4      0.866          1      0.995      0.601
frisbee        128          5      0.735        0.8        0.8      0.627
skis        128          1      0.827          1      0.995      0.497
snowboard        128          7       0.85      0.714      0.867      0.544
sports ball        128          6      0.685      0.667      0.668      0.346
kite        128         10      0.835      0.508      0.628       0.22
          baseball bat        128          4      0.521       0.25      0.388      0.171
        baseball glove        128          7      0.763      0.429       0.47      0.276
            skateboard        128          5      0.725       0.54      0.648      0.479
tennis racket        128          7      0.801      0.429      0.559      0.344
                bottle        128         18      0.588      0.333      0.601       0.31
            wine glass        128         16      0.735      0.875       0.89      0.448
                   cup        128         36      0.902      0.667      0.839       0.52
                  fork        128          6          1      0.311      0.439      0.302
                 knife        128         16      0.829      0.625      0.704      0.393
                 spoon        128         22      0.828      0.439      0.637      0.363
                  bowl        128         28          1       0.63      0.763      0.573
                banana        128          1      0.809          1      0.995      0.302
sandwich        128          2          1          0      0.448      0.383
orange        128          4      0.829          1      0.995      0.738
broccoli        128         11      0.824      0.364      0.491      0.356
carrot        128         24      0.685      0.625      0.713      0.487
hot dog        128          2      0.547          1      0.663      0.614
pizza        128          5          1      0.792      0.962       0.77
donut        128         14      0.674          1      0.946      0.799
cake        128          4      0.774          1      0.995      0.846
chair        128         35      0.612      0.632      0.619      0.319
couch        128          6          1      0.646      0.826      0.527
potted plant        128         14      0.903      0.786      0.875      0.508
bed        128          3          1          0      0.863      0.532
          dining table        128         13      0.804      0.317      0.621      0.407
                toilet        128          2      0.857          1      0.995      0.796
                    tv        128          2      0.751          1      0.995      0.796
laptop        128          3          1          0      0.913      0.548
mouse        128          2          1          0     0.0907     0.0454
remote        128          8          1      0.617      0.629      0.513
cell phone        128          8      0.722      0.332      0.453      0.262
microwave        128          3      0.848          1      0.995      0.843
oven        128          5      0.667        0.4       0.43      0.298
sink        128          6      0.272      0.167      0.338      0.252
refrigerator        128          5      0.672        0.8       0.81      0.558
book        128         29      0.749      0.206      0.367      0.168
clock        128          9      0.762      0.778      0.879      0.689
vase        128          2      0.439          1      0.995      0.895
scissors        128          1          1          0      0.166     0.0332
teddy bear        128         21       0.85      0.571      0.788      0.506
toothbrush        128          5      0.826          1      0.995      0.618
Results saved to #033[1m/opt/ml/model/exp#033[0m
2023-06-30 08:57:53,434 sagemaker-training-toolkit INFO     Waiting for the process to finish and give a return code.
2023-06-30 08:57:53,434 sagemaker-training-toolkit INFO     Done waiting for a return code. Received 0 from exiting process.
2023-06-30 08:57:53,435 sagemaker-training-toolkit INFO     Reporting training SUCCESS

2023-06-30 08:58:07 Uploading - Uploading generated training model
2023-06-30 08:58:07 Completed - Training job completed
Training seconds: 427
Billable seconds: 427

 

 

기계 학습 완료 후 저장된 모델 파일 및 경로를 확인합니다.

 

 

기계 학습이 완료되어 저장된 모델 파일은 SageMaker의 기본 S3 버킷 경로에 생성되며 output 디렉토리의 model.tar.gz 이름으로 생성됩니다. 이제 생성된 모델을 통해 AI(인공지능) 분야에서 사용하기길 바랍니다!

 

 

SageMaker에서 Studio의 Jupyter Notebook 파일(ipynb)을 통해 간단히 기계 학습을 완료하였습니다.
이제 기계 학습 시 사용할 라이브러리, 모델, 학습 데이터 등을 설정 후 원하는 기계 학습 환경을 구성해보시기 바랍니다.

 

 

 

지금까지 SageMaker에서 PyTorch를 활용한 기계 학습 환경을 구축하는 작업을 알아보는 시간이었습니다....! 끝...!

 

 

 

[Reference]

 

 

 

[Jenkins] Window Nodes 추가 및 연동하기

Jenkins에서는 도커 컨테이너를 통해 다양한 환경에서의 빌드 및 배포 작업을 진핼할 수 있습니다.
하지만 Host OS가 Linux인 Jenkins 서버에서는 Window OS에서만 할 수 있는 작업에는 제한이 있는데요.
Host OS가 Linux인 Jenkins 서버에서 Window 관련 작업을 진행하기 위한 Window Nodes 추가 및 연동하는 작업을 진행해 보겠습니다.

 

 


Nodes 설정 추가

Dashboard -> Jenkins 관리 -> Nodes 메뉴에서 Nodes 관련 설정을 관리할 수 있습니다.

 

기본적으로 Jenkins 서버를 설치하면 Host OS에 맞는 기본 Nodes가 Built-In Node 이름으로 생성되어 있습니다.
Window Nodes를 신규 추가할 것이므로 New Node를 클릭하여 Nodes 설정을 추가합니다.

 

 

Nodes Name을 입력 후 Type은 Permanent Agent를 선택합니다.


Permanent Agent는 Jenkins 마스터 서버와 연결되어 지속적으로 사용 가능한 에이전트(또는 슬레이브)를 할당하는 것을 의미합니다.

 

 

Number of executors 값은 Nodes에서 수행할 수 있는 동시 빌드 작업 수를 정의합니다.


Remote root directory 값은 Nodes에서 사용할 작업 디렉토리를 지정하며, 작업 디렉토리는 설정한 값과 동일하게 Window Nodes에 추가해야됩니다.

 

 

Labels 값은 여러 에이전트를 그룹화하고 Pipeline에서 에이전트를 선택 시 사용하는 값입니다.


Usage 값은 빌드 작업에 대한 방법을 제어하며 Only build jobs with label expressions matching this node 값을 선택합니다. 레이블 표현식이 있는 작업만 빌드 시 사용하겠다는 것을 의미합니다.

 

 

Nodes 설정 추가 작업을 완료하면 아래와 같이 추가된 Nodes 정보를 확인하실 수 있습니다.

 

 


Nodes 연결

Nodes 설정을 추가하였으니 이제 Window에서 Nodes를 연결하도록 설정해보겠습니다.
Nodes 이름을 클릭하면 아래와 같이 Nodes 연결을 위한 agent.jar 파일 다운로드와 연결 명령어가 정리되어 있습니다.

 

 

이제 Window OS에 접속하여 해당 명령어를 입력하여 agent.jar 파일 다운로드 후 jenkins의 Nodes로 연결합니다.

 

 

연결이 완료되면 Nodes 관리 페이지에서도 해당 Nodes의 상태에 X 표시가 사라지고 정상적으로 연결됨을 확인하실 수 있습니다.

 

 


Nodes 사용

이제 Jenkins Pipeline에서 설정한 Nodes를 사용하도록 설정해보겠습니다.


Pipeline에서는 Nodes 생성 시 설정한 Labels 값을 통해 Nodes를 지정하고 빌드 시 사용할 수 있습니다.

stage('window-agent-stage') {
  agent {
    // Nodes 생성 시 설정한 label 값
    label 'windows'
  }
  steps {
    // 명령어 입력
    bat '''
      bat 'dir /b
    '''
  }
}

 

 

agent { label 'windows' } agent 옵션을 사용하여 Nodes 생성 시 설정한 Labels 값을 지정하였습니다.
이제 Jenkins의 Pipeline이 동작할 경우 해당 Stage에서는 Nodes를 통해 연결된 Window OS 환경에서 명령어를 실행하여 빌드 시 사용할 수 있게 되었습니다.

 

 

Jenkins를 Window OS 환경에서 설치하여 사용할 경우 위와 같은 작업은 필요 없지만,

Linux OS 환경에 설치된 Jenkins에서 Window OS 환경 작업이 필요한 경우,

Window OS 환경에 설치된 Jenkins에서 Linux OS 환경 작업이 필요한 경우,

Nodes 추가 작업으로 작업을 구분하여 빌드 및 배포 작업을 구현할 수 있습니다.

 

 

 

지금까지 Jenkins에서 Window Nodes 추가 및 연동하는 작업을 알아보는 시간이었습니다....! 끝...!

 

 

 

+ Recent posts