Baichuan-13B icon indicating copy to clipboard operation
Baichuan-13B copied to clipboard

有mac部署方法吗,能用GPU么,需要多少内存

Open liaoweiguo opened this issue 1 year ago • 1 comments

liaoweiguo avatar Jul 12 '23 08:07 liaoweiguo

把模型下载到本地,

brew install git-lfs
git lfs install
git clone https://huggingface.co/baichuan-inc/Baichuan-13B-Chat

如果网络问题,可以收工下载模型文件

GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/baichuan-inc/Baichuan-13B-Chat

模型使用本地路径 使用mps加速model = model.to('mps') 量化不支持Mac,暂时无解 不管cl_demo.py 还是web_demo.py 都如下修改,

pretrained_model_name = "./model/Baichuan-13B-Chat/"

st.set_page_config(page_title="Baichuan-13B-Chat")
st.title("Baichuan-13B-Chat")


@st.cache_resource
def init_model():
    model = AutoModelForCausalLM.from_pretrained(
        pretrained_model_name,
        torch_dtype=torch.float16,
        # device_map="auto",
        trust_remote_code=True
    )
    model = model.to('mps')
    model.generation_config = GenerationConfig.from_pretrained(
        pretrained_model_name
    )
    tokenizer = AutoTokenizer.from_pretrained(
        pretrained_model_name,
        use_fast=False,
        trust_remote_code=True
    )
    return model, tokenizer

我的系统是: MacBook Pro M2 Max(12核CPU, 38核GPU, 32G内存) 使用情况,能跑起来,但没有啥意义,太慢。 内存使用最多超过32G,都使用虚拟内存了。 image

alitrack avatar Jul 13 '23 08:07 alitrack

感谢楼上兄弟, 我用了你的设置在Mac上成功跑起了,M1 Max + 64G内存速度可以接受。 不过今天看到有人搞了ggml的版本:

https://huggingface.co/xuqinyang/baichuan-13b-chat-ggml-int8

tankxiaodi avatar Aug 04 '23 10:08 tankxiaodi

感谢楼上兄弟, 我用了你的设置在Mac上成功跑起了,M1 Max + 64G内存速度可以接受。 不过今天看到有人搞了ggml的版本:

https://huggingface.co/xuqinyang/baichuan-13b-chat-ggml-int8

does it work well? My mac is mac book m1max 64G, could it work well?

tain198127 avatar Aug 21 '23 09:08 tain198127