THUDM / CodeGeeX2

CodeGeeX2: A More Powerful Multilingual Code Generation Model
https://codegeex.cn
Apache License 2.0
7.62k stars 532 forks source link

如何使用cpu运行 #13

Closed animalong closed 1 year ago

animalong commented 1 year ago

我像chatglm2-6b 那样使用 .float() 加载模型,但是失败了。请问 CodeGeeX2 是否可以 cpu 运行,如何操作?

11 12

RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

donjuanplatinum commented 1 year ago

你可以试试改这一条成这样

model = AutoModel.from_pretrained("./models/codegeex2-6b", trust_remote_code=True).to('cpu')
animalong commented 1 year ago

你可以试试改这一条成这样

model = AutoModel.from_pretrained("./models/codegeex2-6b", trust_remote_code=True).to('cpu')

不可以.. 它在 AutoModel.from_pretrained(model_path, trust_remote_code=True) 的时候就已经报错了。 我还试了下 AutoModel.from_pretrained(model_path, trust_remote_code=True, device='cpu') 这样,也不行,还是要找N卡

donjuanplatinum commented 1 year ago

我建议你还是试试在后面加上.to('cpu'),因为我用这个运行成功了. device='cpu是chatglm2-6b那个里面是这样改的

Stanislas0 commented 1 year ago

你可以试试改这一条成这样

model = AutoModel.from_pretrained("./models/codegeex2-6b", trust_remote_code=True).to('cpu')

不可以.. 它在 AutoModel.from_pretrained(model_path, trust_remote_code=True) 的时候就已经报错了。 我还试了下 AutoModel.from_pretrained(model_path, trust_remote_code=True, device='cpu') 这样,也不行,还是要找N卡

这样就可以用cpu运行了,另外最新的DEMO加了一个选项,可以通过以下命令运行在cpu上:

python demo/run_demo.py --cpu
animalong commented 1 year ago

你可以试试改这一条成这样

model = AutoModel.from_pretrained("./models/codegeex2-6b", trust_remote_code=True).to('cpu')

不可以.. 它在 AutoModel.from_pretrained(model_path, trust_remote_code=True) 的时候就已经报错了。 我还试了下 AutoModel.from_pretrained(model_path, trust_remote_code=True, device='cpu') 这样,也不行,还是要找N卡

这样就可以用cpu运行了,另外最新的DEMO加了一个选项,可以通过以下命令运行在cpu上:

python demo/run_demo.py --cpu

我看到说明更新里有了这样的demo指令,也做了尝试,但还是报了开始的错误,现在我怀疑是我的配置不够,但报找不到N卡还是让我挠头,难道是int4模型有问题了? python demo\run_demo.py --model-path=[目录]\THUDM\codegeex2-6b-int4 --cpu 33

Stanislas0 commented 1 year ago

你可以试试改这一条成这样

model = AutoModel.from_pretrained("./models/codegeex2-6b", trust_remote_code=True).to('cpu')

不可以.. 它在 AutoModel.from_pretrained(model_path, trust_remote_code=True) 的时候就已经报错了。 我还试了下 AutoModel.from_pretrained(model_path, trust_remote_code=True, device='cpu') 这样,也不行,还是要找N卡

这样就可以用cpu运行了,另外最新的DEMO加了一个选项,可以通过以下命令运行在cpu上:

python demo/run_demo.py --cpu

我看到说明更新里有了这样的demo指令,也做了尝试,但还是报了开始的错误,现在我怀疑是我的配置不够,但报找不到N卡还是让我挠头,难道是int4模型有问题了? python demo\run_demo.py --model-path=[目录]\THUDM\codegeex2-6b-int4 --cpu 33

int4模型依赖GPU支持,目前在cpu上只能运行FP16格式的模型。

animalong commented 1 year ago

原来 int4模型 还不支持cpu运行啊。。好吧,希望能出一个支持的

zhongfuxiao commented 1 year ago

大佬,你有试过fp16模型cpu上跑要多少内存不?