리눅스(Ubuntu)에서 스테이블 디퓨전(Stable Diffusion)을 설치하다 보면 환경 설정 문제로 여러 에러를 만나게 된다. 이 글에서는 스테이블 디퓨전 설치 시 흔하게 발생하는 에러 5가지를 원인별로 정리하고, 각 에러를 해결하는 방법을 명령어와 함께 단계별로 살펴본다.
1. GCC가 없어서 발생하는 에러
Git을 설치하거나 관련 패키지를 다룰 때, 아래와 같이 PPA 추가 단계에서 에러가 발생할 수 있다.
root@p-ai-img-svr:/product# apt-get install git
git is already the newest version (1:2.34.1-1ubuntu1.10).
...
root@p-ai-img-svr:/product# add-apt-repository ppa:git-core/ppa
PPA publishes dbgsym, you may need to include 'main/debug' component
이처럼 에러가 난다면 컴파일러인 GCC가 설치되어 있지 않은 경우다. 아래 명령어로 GCC를 설치하면 해결된다.
sudo apt-get install gcc
2. webui.sh 실행 시 발생하는 권한·실행 오류
설치 스크립트인 webui.sh를 내려받은 뒤 실행하면, 아래처럼 [[: not found, Bad substitution, Syntax error 같은 에러가 쏟아진다.
root@p-ai-img-svr:/product# sh ./webui.sh
./webui.sh: 9: [[: not found
./webui.sh: 13: Bad substitution
...
Running on root user
...
./webui.sh: 131: Syntax error: redirection unexpected
이 에러는 root 계정으로 설치하면서 동시에 실행 권한이 없는 상태에서 발생한 것이다. 원인을 세 가지로 나눠 정리하면 다음과 같다.
원인 ① 파일에 실행 권한이 없음
ls -al로 확인하면 webui.sh에 실행 권한(x)이 빠져 있다. 파일 자체에 실행 권한을 부여한다.
root@p-ai-img-svr:/product# ls -al
-rw-r--r-- 1 root root 8098 Sep 6 01:12 webui.sh
root@p-ai-img-svr:/product# chmod 777 webui.sh
원인 ② root 계정으로 실행하면 중단됨
실행 권한을 줘도 root로 실행하면 스크립트가 This script must not be launched as root 메시지를 내며 중단된다. 스테이블 디퓨전 설치 스크립트는 보안상 root 실행을 막아 두었기 때문이다. 따라서 개인 계정으로 실행해야 하며, 파일 소유자도 개인 계정으로 바꿔 준다.
root@p-ai-img-svr:/product# ./webui.sh
ERROR: This script must not be launched as root, aborting…
root@p-ai-img-svr:/product# chown gyeominater. webui.sh
원인 ③ 디렉토리에 쓰기 권한이 없음
개인 계정으로 실행하면 이번에는 작업 디렉토리를 만들지 못해 에러가 난다. webui.sh가 위치한 디렉토리(/product) 자체에 쓰기 권한이 없기 때문이다.
gyeominater@p-ai-img-svr:/product$ ./webui.sh
fatal: could not create work tree dir 'stable-diffusion-webui': Permission denied
ERROR: Can't cd to /product/stable-diffusion-webui/, aborting…
gyeominater@p-ai-img-svr:/product$ mkdir aa
mkdir: cannot create directory ‘aa’: Permission denied
root로 전환해 해당 디렉토리에 권한을 부여하면 해결된다.
root@p-ai-img-svr:/# chmod 777 product/
정리하면, webui.sh 실행 오류는 다음 세 가지를 처리하면 해결된다.
- webui.sh가 위치한 디렉토리에 777 권한을 준다.
- webui.sh 파일 자체에 777 권한을 준다.
- root가 아닌 개인 계정으로 webui.sh를 실행한다.
3. PIP가 설치되지 않아 발생하는 에러
권한 문제를 해결하고 다시 실행하면, 이번에는 torch를 설치하는 단계에서 No module named pip 에러로 멈춘다.
Installing torch and torchvision
/usr/bin/python3: No module named pip
...
RuntimeError: Couldn't install torch.
Command: "/usr/bin/python3" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 1
PIP가 설치되지 않아 발생한 에러다. 아래와 같이 apt로 PIP를 설치하면 된다.
sudo apt install python3-pip
4. packaging 모듈이 없어서 발생하는 에러
PIP를 설치한 뒤 다시 실행하면, 이번에는 packaging 모듈이 없다는 에러가 발생한다.
Installing requirements for CodeFormer
...
import packaging.version
ModuleNotFoundError: No module named 'packaging'
이 또한 PIP로 해당 모듈을 설치하면 해결된다.
gyeominater@p-sdsvr-01:/PRODUCT/sd-151$ sudo pip install packaging
Collecting packaging
...
Successfully installed packaging-23.1
위와 같이 정상적으로 설치가 완료되면 다시 webui.sh를 실행해 확인한다. 모든 의존성이 갖춰지면 아래처럼 Web UI가 정상적으로 구동된다.
gyeominater@p-sdsvr-01:/PRODUCT/sd-151$ ./webui.sh
...
Version: v1.6.0
Launching Web UI with arguments: --listen --enable-insecure-extension-access
...
Running on local URL: http://0.0.0.0:7860
...
Model loaded in 4.5s
5. 설치되는 버전이 의도와 다를 때
실행 로그를 보면 설치된 최신 버전이 v1.6.0으로 표시된다. 만약 특정 버전(예: 1.5.1)을 사용해야 한다면 기본으로 받아지는 최신 버전과 달라 문제가 될 수 있다. 이 경우 사용하려는 버전으로 별도로 변경해 주어야 한다.
정리
리눅스에서 스테이블 디퓨전 설치 시 흔한 에러는 대부분 권한과 의존성 문제에서 비롯된다. 핵심을 정리하면 다음과 같다.
- GCC 부재:
sudo apt-get install gcc로 설치. - webui.sh 권한 오류: 디렉토리·파일에 실행 권한을 주고, root가 아닌 개인 계정으로 실행.
- PIP 미설치:
sudo apt install python3-pip로 설치. - packaging 모듈 부재:
pip install packaging로 설치. - 버전 불일치: 필요한 버전으로 별도 변경.
위 다섯 가지 에러를 순서대로 해결하면 리눅스 환경에서 스테이블 디퓨전 Web UI를 무리 없이 구동할 수 있다.



💬 댓글 0