23.06.15
DEVOTEE를 활성화 시키면
지금 작성한 커뮤니티 글에 대해 1개의 댓글을 달아줍니다.
버튼을 누르면 글 수정 시 ChatGPT가 작성한 댓글이 수정됩니다.
| 컨텐츠 유형 | 제목 | 저장일 | 삭제 |
|---|
본인인증 로그인에 실패하였습니다.
회원이 아니시거나 본인인증 등록이
완료되지 않은 사용자입니다.
ChatGPT를 통해 손쉽게 이미지도 생성하는 시대가 되었다.
현재 맡고 있는 이프랜드스튜디오 서비스에 이미지 생성을 이용한 실험이 필요하였다. 생성 이미지 결과에 대한 프로젝트 참여자의 반응은 나쁘지 않았다.
ChatGPT 말고 Azure를 통한 이미지 생성에 대한 방안을 찾아 보았다. 다행히 Azure에서도 ready-made 또는 API 형태로 제공하는 서비스가 있기는 했다.
하지만, 독자적인 인프라로 구성하여 bulk로 구독료나 이용료를 내지 않는 방법에 대한 궁금증이 생겨 좀 더 찾아 보았다.
Azure VM에 설치할 수 있으면 사용 시간 관리를 통해 비용을 직접 통제하기가 편리하다.
Azure VM에 컨테이너 방식으로 Stable Diffusion을 구성할 수 있는 방법이 있어 소개하고자 한다.
Stable Diffusion: 독일 뮌헨 대학 CompVis 연구실의 “잠재 확산 모델을 이용한 고해상도 이미지 합성 연구”를 기반하여,
Stability AI와 Runway ML 등의 지원을 받아 개발된 딥러닝 인공지능 모델로 오픈소스로 공개되어 있다.
Stable Diffusion은 텍스트 설명을 바탕으로 사실적이고 다양한 이미지를 생성할 수 있는 강력한 AI 모델이다.
이 모델은 '확산(diffusion)' 기술을 사용하여 이미지에 점진적으로 노이즈를 추가한 뒤, 이 과정을 역으로 학습하여 새로운 이미지를 생성한다.
이런 과정을 통해 시각적으로 아름답고 의미있는 이미지를 만들어낼 수 있다.
Stable Diffusion은 방대한 이미지와 텍스트 데이터셋을 학습하여 다양한 시각적 개념을 이해하고 표현할 수 있다.
이 도구를 활용해서 예술가, 디자이너, 그리고 독특하고 매력적인 이미지를 만들고자 하는 모든 사람들에게 강력한 도구가 되고 있다.
VM Series: NC Series (e.g., NC6)
CPU: At least 6 vCPUs
GPU: 1 x NVIDIA Tesla K80 or better
RAM: 56 GB or more
Storage: 340 GB SSD or more
This specification is based on the general requirements for machine learning tasks and the specific needs of Stable Diffusion, which includes GPU acceleration for efficient processing.
The NC series in Azure is designed for compute-intensive and network-intensive applications, including deep learning and simulations. The NVIDIA Tesla K80 GPU provides good performance for such tasks.
aop@vm-stable-diffusion-gpu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 248G 2.2G 246G 1% /
tmpfs 55G 0 55G 0% /dev/shm
tmpfs 22G 1016K 22G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda15 105M 6.1M 99M 6% /boot/efi
/dev/sdb1 724G 32K 687G 1% /mnt
tmpfs 11G 4.0K 11G 1% /run/user/1000아래는 설치된 OS에 대한 설명이다.
Ubuntu 22.04 LTS:
이 Ubuntu 버전은 장기적인 지원, 안정성 및 광범위한 호환 소프트웨어 패키지를 제공합니다.
Linux를 처음 접하는 사용자에게는 사용자 친화적이고 고급 사용자에게는 충분히 강력합니다.
Ubuntu의 광범위한 커뮤니티와 문서를 통해 문제 해결이 더 쉬워집니다.
또한 많은 기계 학습 도구와 라이브러리가 Ubuntu에 대해 테스트 및 최적화되어 Stable Diffusion의 보다 원활한 설치 및 작동을 보장합니다.
비용을 생각하지 않을 수 없다. 구성할 때 한 번 정도를 체크를 해 본다.
프로젝트 수행할 때 소요되는 비용에 대한 감을 어느 정도 잡을 수 있다. 시간당 4천원이 조금 넘는 비용이 발생한다.
우분투에 도커 설치 부터 진행한다.
우분투 시스템 업데이트:
sudo apt update
sudo apt upgrade도커 패키지 설치를 위한 패키지 관리자 설치:
sudo apt install apt-transport-https ca-certificates curl software-properties-common도커 공식 GPG(GNU Privacy Guard) 키 추가:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg도커 저장소 추가:
echo "deb [arch=amd64 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도커 패키지 설치:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io# 수행 명령어 : 다운로드와 기동
sudo docker compose --profile download up --buildError response from daemon: could not select device driver "nvidia" with capabilities: [[compute utility]]
Install NVIDIA Container Toolkit and restart the docker service #81
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: initialization error: load library failed: libnvidia-ml.so.1: cannot open shared object file: no such file or directory: unknown
우분투 드라이버 설치
sudo apt install ubuntu-drivers-common
ubuntu-drivers devices 명령
ubuntu-drivers devices
ERROR:root:aplay command not found
== /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0004:00/VMBUS:00/47505500-0001-0000-3130-444531444234/pci0001:00/0001:00:00.0 ==
modalias : pci:v000010DEd00001DB4sv000010DEsd00001214bc03sc02i00
vendor : NVIDIA Corporation
model : GV100GL [Tesla V100 PCIe 16GB]
driver : nvidia-driver-535 - distro non-free recommended
driver : nvidia-driver-470-server - distro non-free
driver : nvidia-driver-525-server - distro non-free
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-525 - distro non-free
driver : nvidia-driver-535-server - distro non-free
driver : nvidia-driver-450-server - distro non-free
driver : nvidia-driver-470 - distro non-free
driver : nvidia-driver-390 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin현재 사용중인 그래픽카드 확인
lshw -numeric -C display
lspci | grep -i nvidia
lshw -numeric -C display
WARNING: you should run this program as super-user.
*-display UNCLAIMED
description: 3D controller
product: GV100GL [Tesla V100 PCIe 16GB] [10DE:1DB4]
vendor: NVIDIA Corporation [10DE]
physical id: 0
bus info: pci@0001:00:00.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: cap_list
configuration: latency=0
resources: iomemory:100-ff iomemory:140-13f memory:41000000-41ffffff memory:1000000000-13ffffffff memory:1400000000-1401ffffff
*-graphics
product: hyperv_drmdrmfb
physical id: 1
logical name: /dev/fb0
capabilities: fb
configuration: depth=32 resolution=1024,768
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.권장 드라이버 자동으로 설치
sudo ubuntu-drivers autoinstall
설치 후 재부팅 sudo reboot now
다시 기동
sudo docker compose --profile auto up --build
Azure VM에 어렵지 않은 방법으로 Stable Diffusion 환경을 구성할 수 있었다.
GPU가 있어 이미지 생성에는 빠른 속도로 결과를 제공해 준다.
비용이 걱정이라면 시간당 4천원 정도의 비용을 고려하여 VM을 일정시간만 Auto scheduling을 통해서 사용해 볼 수 있다.
DEVOTEE를 활성화 시키면
지금 작성한 댓글에 AI가 댓글을 달아줍니다.