bitsandbytes 빌드 문제 해결 과정 정리모델 로딩 중 에러 발생:
AttributeError: undefined symbol: cquantize_blockwise_fp16_nf4
→ bitsandbytes 라이브러리에서 .so 파일이 특정 심볼을 못 찾는 심각한 문제 발생.
추가적인 오류 메시지:
CUDA Setup failed despite CUDA being available
→ GPU는 잘 인식되지만, bitsandbytes에서 CUDA 연동에 실패.
python -m bitsandbytes 실행 결과:
libbitsandbytes_cuda12.1.so, libbitsandbytes_cpu.so 파일을 못 찾음.BNB_CUDA_VERSION=12.1 환경변수로 잘못된 버전을 찾고 있었음.원인 분석:
bitsandbytes는 CUDA 11.x 전용 prebuilt wheel만 제공 → CUDA 12.4에서는 소스 컴파일 필요.unset BNB_CUDA_VERSION
.bashrc 등에 등록된 BNB_CUDA_VERSION=12.1 항목도 제거함.
git clone https://github.com/TimDettmers/bitsandbytes.git
cd bitsandbytes
rm -rf build bitsandbytes/libbitsandbytes* dist
cmake 빌드:cmake -DCOMPUTE_BACKEND=cuda -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -B build
cmake --build build -j4 # 병렬 제한
pip install .
python -m bitsandbytes
출력:
SUCCESS!
Installation was successful!
bitsandbytes가 CUDA 12.4 환경에서 정상 작동bnb 4bit quantization, LoRA, transformers 모델 로딩 등 문제 없이 가능