llamaIndex 基于GPU加载本地embedding模型
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core import Settings
import os
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:4000"
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
documents = SimpleDirectoryReader("./data/paul_graham").load_data()
Settings.embed_model = HuggingFaceEmbedding(
model_name="/home/leicq/Documents/LLM_models/bge-large-zh-v1.5"
)
index = VectorStoreIndex.from_documents(
documents,
)
print("hello")