chatglm.cpp icon indicating copy to clipboard operation
chatglm.cpp copied to clipboard

使用python接口运行不能调用gpu

Open Vincent131499 opened this issue 1 year ago • 1 comments

你好,运行如下命令: python cli_chat.py -m ../../pretrained-models/chatglm2-6b-ggml-q8_0.bin -i 发现并没有调用gpu。 之前编译使用: cmake -B build -DGGML_CUBLAS=ON cmake --build build -j 如果使用下面命令是可以正常调用gpu: ./build/bin/main -m ../pretrained-models/chatglm2-6b-ggml-q8_0.bin -i

想问下:是这个python接口还需要适配gpu吗?若有,需要改动什么呢

Vincent131499 avatar Jul 11 '23 09:07 Vincent131499

可以试试在安装时加个环境变量:

CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v

我稍后更新到文档里。目前CUDA性能还比较差,正在优化中。

li-plus avatar Jul 13 '23 13:07 li-plus

3q. 这种方式安装后,python接口可以正常调用gpu

Vincent131499 avatar Jul 14 '23 06:07 Vincent131499

@Vincent131499 怎么看出来调用了GPU呢

>>> import chatglm_cpp
>>> model_path="/users_3/chatglm.cpp/chatglm2-ggml.bin"
>>> pipeline = chatglm_cpp.Pipeline(model_path)
>>> pipeline.chat(["你叫小明","好的我叫小明","你是谁"])
'我是一个人工智能助手,不能像真正的人一样感知世界,我只能通过算法和语言模型来回答问题。'

@li-plus 怎么看出来调用了GPU呢

wqh17101 avatar Jul 15 '23 08:07 wqh17101

@wqh17101 可以nvidia-smi看下显存占用和GPU利用率

li-plus avatar Jul 22 '23 10:07 li-plus

优化了一版 GPU 推理性能,可以装最新的 chatglm-cpp 测试下。

li-plus avatar Jul 22 '23 10:07 li-plus

@li-plus CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v 这样安装么 模型转换的时候要加什么参数么

wqh17101 avatar Jul 22 '23 10:07 wqh17101

优化了一版 GPU 推理性能,可以装最新的 chatglm-cpp 测试下。

你好,请问我下了最新的chatglm-cpp 0.2.1版本,发现还是没有调用gpu,这个是需要加什么参数进去或者指定某个gpu吗?

Kevinddddddd avatar Jul 25 '23 07:07 Kevinddddddd

@Kevinddddddd 要 CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v 这样安装。我用起来了

wqh17101 avatar Jul 27 '23 03:07 wqh17101

@Kevinddddddd 要 CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v 这样安装。我用起来了

好的感谢,我去试一下

Kevinddddddd avatar Jul 28 '23 05:07 Kevinddddddd

@Kevinddddddd 要 CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v 这样安装。我用起来了

最好改成:

CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v --no-cache 或者在本地重新编译

homjay avatar Aug 18 '23 03:08 homjay

CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v 'CMAKE_ARGS' 不是內部或外部命令、可執行的程式或批次檔。 在WIN11上的錯誤

henrywang0314 avatar Dec 07 '23 02:12 henrywang0314

我通过CMAKE_ARGS="-DGGML_CUBLAS=ON" pip install chatglm-cpp --force-reinstall -v 安装成功了,但是还是依然不能使用gpu进行推理, docker启动命令加了gpus=all, 加了-e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all 还是不行。请问下是怎么回事呢?@li-plus

Mewral avatar Mar 23 '24 12:03 Mewral