얕고 넓게

[AI] text-generation-webui @Ubuntu 본문

IT/AI.ML

[AI] text-generation-webui @Ubuntu

블랙오닉스 2025. 4. 11. 19:13

2025.04.11

ChatGPT에서 학습된 모델을 사용할 수 있는 방법을 물어봤더니,

Docker로 하는 방법과 text-generation-webui를 이야기 한다.

Docker는 질려서 두번째 방법으로.

일단 llama 파인 튜닝을 위해서 만들어 논 가상환경으로 들어가서 진행

conda activate llama

git clone https://github.com/oobabooga/text-generation-webui.git
cd text-generation-webui
pip install -r requirements.txt

#text-generation-webui 안에 models, loras 에 모델 디렉토리를 넣는다
# 실행
python server.py --model llama3.1-8B --lora checkpoint-200

#VRAM 부족 에러
python3 server.py --model llama3.1-8B --lora checkpoint-200 --gpu-memory 16000 --load-in-8bit --trust-remote-code

...
22:52:46-254824 INFO     Loaded "llama3.1-8B" in 4.78 seconds.                                                                                                   
22:52:46-255565 INFO     LOADER: "Transformers"                                                                                                                  
22:52:46-255896 INFO     TRUNCATION LENGTH: 131072                                                                                                               
22:52:46-256212 INFO     INSTRUCTION TEMPLATE: "Alpaca"                                                                                                          
22:52:46-281180 INFO     Applying the following LoRAs to llama3.1-8B: checkpoint-200                                                                             
Running on local URL:  http://127.0.0.1:7860

 

웹에 접속하면 채팅할 수 있다.

웹 내부에서 LoRA 학습할 수 있는 것 같다.


https://yunwoong.tistory.com/239

 

text-generation-webui 설치 및 활용 가이드

text-generation-webui는 텍스트 생성을 위한 웹 기반 인터페이스입니다. 이 인터페이스를 사용하면 다양한 텍스트 생성 모델과 파라미터를 쉽게 선택하고, 키워드나 톤 등을 지정하여 원하는 텍스트

yunwoong.tistory.com

https://arca.live/b/alpaca/100152092

 

초보자를 위한 text-generation-webui 설치 및 간단 사용법 - Ai 언어모델 로컬 채널

여기는 수십 GB의 VRAM을 가진 그래픽카드들이 굴러다니고 괴수들이 돌아다니는 무시무시한 곳이지만 그래도 종종 초보적인 질문이 들어오는 것으로 보아 오늘은 초보자도 쉽게 따라할 수 있는 t

arca.live


2025.04.12

미리 모델과 옵션을 정하고 실행하는 것 보다 웹에서 설정해서 로딩하는 것이 편하다.

conda activate llama
cd text-generation-webui
python serve.py

Llama3.3을 8bit으로 로딩하면 메모리 부족이고 4bit으로 로딩하니 flash-attn이 인스톨 안되어 있다고 한다.

pip install flash-attn

load_in_8bit

Running on local URL:  http://127.0.0.1:7860

22:53:56-698368 INFO     Loading "Llama-3.3-70B-Instruct"                                                                               
22:53:56-852008 INFO     TRANSFORMERS_PARAMS=                                                                                           
{   'low_cpu_mem_usage': True,
    'torch_dtype': torch.bfloat16,
    'use_flash_attention_2': True,
    'device_map': 'auto',
    'quantization_config': BitsAndBytesConfig {
  "_load_in_4bit": false,
  "_load_in_8bit": true,
  "bnb_4bit_compute_dtype": "float32",
  "bnb_4bit_quant_storage": "uint8",
  "bnb_4bit_quant_type": "fp4",
  "bnb_4bit_use_double_quant": false,
  "llm_int8_enable_fp32_cpu_offload": false,
  "llm_int8_has_fp16_weight": false,
  "llm_int8_skip_modules": null,
  "llm_int8_threshold": 6.0,
  "load_in_4bit": false,
  "load_in_8bit": true,
  "quant_method": "bitsandbytes"
}
}

/home/cube/miniconda3/envs/llama/lib/python3.10/site-packages/transformers/generation/configuration_utils.py:638: UserWarning: `do_sample` is set to `False`. However, `min_p` is set to `0.0` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `min_p`.
  warnings.warn(
22:53:57-367405 ERROR    Failed to load the model.

 

load_in_4bit

3:10:36-809838 INFO     Loading "Llama-3.3-70B-Instruct"                                                                               
23:10:36-971378 INFO     TRANSFORMERS_PARAMS=                                                                                           
{   'low_cpu_mem_usage': True,
    'torch_dtype': torch.bfloat16,
    'use_flash_attention_2': True,
    'device_map': 'auto',
    'quantization_config': BitsAndBytesConfig {
  "_load_in_4bit": true,
  "_load_in_8bit": false,
  "bnb_4bit_compute_dtype": "float16",
  "bnb_4bit_quant_storage": "uint8",
  "bnb_4bit_quant_type": "nf4",
  "bnb_4bit_use_double_quant": false,
  "llm_int8_enable_fp32_cpu_offload": true,
  "llm_int8_has_fp16_weight": false,
  "llm_int8_skip_modules": null,
  "llm_int8_threshold": 6.0,
  "load_in_4bit": true,
  "load_in_8bit": false,
  "quant_method": "bitsandbytes"
}
}

Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████| 30/30 [00:17<00:00,  1.71it/s]
23:10:54-924947 INFO     Loaded "Llama-3.3-70B-Instruct" in 18.11 seconds.

질문하면 돌다가 메모리 부족 에러가 난다.

'IT > AI.ML' 카테고리의 다른 글

[AI] Ollama 모든 것  (0) 2025.04.15
[AI] Llama 파인튜닝 @Ubuntu  (0) 2025.04.10
[AI] 환경설정 @Ubuntu  (0) 2025.04.09
[AI] Llama 파인튜닝 with Copilot  (0) 2025.04.08
[AI] Open-WebUI: Docker 설치, 지우기, 다시... @Ubuntu  (0) 2025.04.03