MLOps를 위해서는 위와 같은 세가지 작업을 자동화 하는 과정이 필요합니다.
위 작업을 위해서는 Containerization, Container Orchestration이 필요한데,
현재 가장 유명한 오픈 소스는 도커와 쿠버네티스 입니다.
컨테이너화(Containerization)는 특정 머신러닝 코드나 프로그램이 운영 체제(OS), Python 환경, 패키지 버전(pyp 패키지 등)과 같은 실행 환경에 영향을 받지 않고 독립적으로 동작할 수 있도록, 실행 환경 전체를 하나의 패키지로 묶는 기술을 말합니다. 이를 통해 해당 코드를 다른 컴퓨터나 서버에서도 동일한 환경에서 실행할 수 있게 보장합니다.
쿠버네티스는 컨테이너화된 애플리케이션을 여러 서버에 효율적으로 배치·확장·관리하며, 로드 밸런싱과 로그 분산, 장애 복구 등으로 시스템의 안정성과 확장성을 제공하는 오케스트레이션 도구입니다.
이를 통해 여러 사람이 서버를 공동으로 사용하면서 모델 스케줄 관리, GPU 자원 최적화, 서버 자원 정리 등을 수작업으로 하지 않고, 자동화된 시스템을 통해 효율적으로 처리합니다.
도커(Docker)는 애플리케이션과 그 실행 환경을 하나의 "도커 이미지"로 패키징하여, 어떤 운영체제(OS)나 환경에서도 동일한 결과를 보장하며 실행할 수 있게 해줍니다. 이를 통해 개발, 테스트, 배포 환경 간의 불일치 문제를 해결하고, 한 번 빌드한 이미지를 어디서나 재사용할 수 있어 효율성과 일관성을 제공합니다.
실습 환경을 구성해보도록 하겠습니다.
도커는 리눅스 컨테이너기반 기술이기 때문에 Windows나 Mac에 설치하려면 가상머신이라는 것 위에서 구동 되어야 합니다. 각 os별로 도커 데스크탑을 설치하는 방법은 이와 같습니다.
Window: https://docs.docker.com/desktop/setup/sign-in/
Sign in
Explore the Learning center and understand the benefits of signing in to Docker Desktop
docs.docker.com
Mac: https://docs.docker.com/desktop/setup/install/mac-install/
Mac
Install Docker for Mac to get started. This guide covers system requirements, where to download, and instructions on how to install and update.
docs.docker.com
두 os와 리눅스커널 기반의 os 모두에서 동일하게 진행할 수 있도록 virtualBox를 활용하여 os에 작은 컴퓨터VM을 띄어서 사용하겠습니다. VM은 ubuntu os로 띄운 후에 VM안에서 실습을 진행합니다.
연결해주면 됩니다.
Ctrl + Alt + T 를 눌러서 터미널을 실행시켜 줍니다.
Docker 설치
- 공식문서: https://docs.docker.com/engine/install/ubuntu/
Ubuntu
Jumpstart your client-side server applications with Docker Engine on Ubuntu. This guide details prerequisites and multiple methods to install Docker Engine on Ubuntu.
docs.docker.com
1) Set up the repository:
apt라는 패키지 매니저 업데이트
sudo apt-get update
그리고, docker의 prerequisite package들을 설치
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
Docker의 GPS key를 추가합니다.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o \
/usr/share/keyrings/docker-archive-keyring.gpg
그 다음 stable 버전의 repository를 바라보도록 설정.
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] http
s://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /de
v/null
혹시 arm 기반의 cpu라면 다음 코드 입력
echo \
"deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >
/dev/null
2) Install Docker Engine
Docker 엔진의 최신 버전 설치
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
3) 정상 설치 확인
docker container 를 실행시켜, 정상적으로 설치되었는지 확인합니다.
sudo docker run hello-world
다음과 같이 출력되다면, 정상 설치된 것 입니다.
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:0fe98d7debd9049c50b597ef1f85b7c1e8cc81f59c8d623fcb2250e8bec85b38
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
현재는 모든 docker 관련 작업이 root 유저에게만 권한이 있기 때문에, docker 관련 명령을 수행하려면 sudo 를 앞에 붙여주어야만 가능합니다.
예를 들면, docker ps를 수행하면 다음과 같이 Permission denied 라는 메시지가 출력됩니다.
따라서, root 유저가 아닌 host의 기본 유저에게도 권한을 주기 위해 다음과 같은 명령어를 "새로운 터미널"에 실행시켜야 합니다.
sudo usermod -a -G docker $USER
sudo service docker restart
그 다음, VM을 로그아웃 한 다음에 다시 로그인하면 다음과 같이 정상적으로 출력이 됩니다.
다음 코드를 입력하면 VM로그아웃이 됩니다.
sudo poweroff
다음에는 docker 실습을 진행해 보겠습니다!
다음 강의를 수강하고 있습니다.
https://fastcampus.co.kr/data_online_mlops
머신러닝 서비스 구축을 위한 실전 MLOps | 패스트캠퍼스
현직 MLOps 엔지니어에게 MLOps 서비스화 전과정을 배워보세요! 구축부터 배포, 운영 방법까지 모두 알려드립니다. 대표 클라우드 플랫폼별 실습까지 해보면 내 현업에 적용하는 것은 시간 문제!
fastcampus.co.kr
Docker 의 기본적인 명령어 (2) (0) | 2025.01.08 |
---|---|
Docker 의 기본적인 명령어 (1) (2) | 2025.01.08 |
한국 경제신문 with toss bank Final_Project 리뷰 (6) | 2024.12.24 |
[패스트캠퍼스] 완강 후기 테디노트의 RAG 비법노트 : 랭체인을 활용한 GPT부터 로컬 모델까지의 RAG 가이드 (2) | 2024.12.15 |
[ 논문 리뷰 ] Transformer - Attention Is All You Need(2017) [ 1 ] (21) | 2024.10.09 |