MNN icon indicating copy to clipboard operation
MNN copied to clipboard

运行DeepSeek 7b模型使用opencl报错

Open shalong07 opened this issue 9 months ago • 10 comments

高通8550上跑7B使用opencl报错: Can't open file:/sys/devices/system/cpu/cpufreq/boost/affected_cpus CPU Group: [ 0 1 2 ], 307200 - 2016000 CPU Group: [ 3 4 5 6 ], 499200 - 2803200 CPU Group: [ 7 ], 595200 - 3187200 The device supports: i8sdot:1, fp16:1, i8mm: 1, sve2: 0, sme2: 0 config path is ../MNN/model7b/config.json Can't open file:tmp/mnn_cachefile.bin Load Cache file error. load tokenizer tokenizer_type = 1 load tokenizer Done load ../MNN/model7b/llm.mnn ... Map error ptrCL == nullptr Segmentation fault (core dumped)

config: "llm_model": "llm.mnn", "llm_weight": "llm.mnn.weight", "backend_type": "opencl", "thread_num": 16, "precision": "normal", "memory": "normal"

DeepSeek1.5b 可以使用opencl正常推理。

shalong07 avatar Mar 10 '25 08:03 shalong07

thread_num 需要设成 68 (buffer 模式),用 image 模式有可能对于大尺寸情况下无法支持。

jxt1234 avatar Mar 11 '25 01:03 jxt1234

thread_num 需要设成 68 这个不会影响GPU处理吧?也就是opencl。 设置如下可以正常运行,但是GPU性能比CPU还要慢,GPU使用率不到40%多。 "thread_num": 4, "precision": "low", "memory": "low"

shalong07 avatar Mar 11 '25 02:03 shalong07

补充一下我用的模型是DeepSeek-R1:7B

shalong07 avatar Mar 11 '25 02:03 shalong07

不影响。68 表示 autotuning + buffer 模式,不是线程数的含义: https://mnn-docs.readthedocs.io/en/latest/inference/session.html

jxt1234 avatar Mar 11 '25 07:03 jxt1234

设成 4 的话,估计有较多算子回退到 CPU 了

jxt1234 avatar Mar 11 '25 07:03 jxt1234

"thread_num": 68,设置成68依然会报错load ../MNN/model7b/llm.mnn ... Map error ptrCL == nullptr 修改下面这两个属性组合也不行,最多报错不一样被kill掉。 "precision": "low", "memory": "low" 还请问下是不是转换或编译的时候有问题?亦或是opencl不匹配?

shalong07 avatar Mar 11 '25 07:03 shalong07

或者是8550本身GPU带不动7B模型?

shalong07 avatar Mar 11 '25 07:03 shalong07

mnn 是什么时候的代码?看着应该是内存不足了。模型是多大?int4 量化过的么?编译 mnn 时是否打开了 -DMNN_LOW_MEMORY=ON ?

jxt1234 avatar Mar 11 '25 11:03 jxt1234

cmake ..
-DCMAKE_SYSTEM_NAME=Linux
-DCMAKE_SYSTEM_VERSION=1
-DCMAKE_SYSTEM_PROCESSOR=aarch64
-DCMAKE_C_COMPILER=/dde/Code/AI/DeepSeek/Deekseek/MNN-master/gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
-DCMAKE_CXX_COMPILER=/dde/Code/AI/DeepSeek/Deekseek/MNN-master/gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
-DMNN_LOW_MEMORY=true
-DMNN_CPU_WEIGHT_DEQUANT_GEMM=true
-DMNN_BUILD_LLM=true
-DMNN_SUPPORT_TRANSFORMER_FUSE=true
-DMNN_OPENCL=true
-DMNN_VULKAN=true 这个是我编译的命令,代码是最近下载的。

模型转换就用的网上的命令: python llmexport.py --path download_path/models--deepseek-ai--DeepSeek-R1-7B --export mnn

shalong07 avatar Mar 11 '25 11:03 shalong07

python llmexport.py --path download_path/models--deepseek-ai--DeepSeek-R1-7B --export mnn --quant_bit 4 量化模型后依然会提示内存问题

shalong07 avatar Mar 13 '25 09:03 shalong07

Marking as stale. No activity in 60 days.

github-actions[bot] avatar May 13 '25 09:05 github-actions[bot]