Code Monkey home page Code Monkey logo

Comments (3)

baibuxiha avatar baibuxiha commented on July 21, 2024 2

临时解决方案

修改chatglm.h文件 to_device方法

 void to_device() {

    	for(int i = 0;i < state_dict_.size();i++) {      
		    ggml_tensor *tensor = state_dict_[i].second;
			// should not place embedding onto device
			if (tensor != transformer.word_embeddings.weight) {
				    if(i <= 125) {// 此处i值为自己制定   需要根据自己的电脑多次修改
                        	                      tensor_to_device(tensor);//GPU加载部分
					}else {
                                                   tensor_to_cpu(tensor);//CPU加载部分
					}
			}
	}

    for (auto &layer : transformer.layers) {
        tensor_to_device(layer.attention.k_cache);
        tensor_to_device(layer.attention.v_cache);
    }
}

再次执行cmake 、make一系列操作

效果:解决只使用CPU版本时 速度慢需要大约1分多钟才有响应。使用原有GPU版本内存溢出 直接退出问题。
现在基本10s内就可以直接响应。充分利用CPU+GPU混合处理。

CPU: I5-6300HQ
GPU: GTX965M 4G版
系统:Win10

from chatglm.cpp.

dd123-a avatar dd123-a commented on July 21, 2024

大神,礼貌问一下现在还有更好的解决方案吗

from chatglm.cpp.

baibuxiha avatar baibuxiha commented on July 21, 2024

大神,礼貌问一下现在还有更好的解决方案吗

没有 本人也不是太懂C++

from chatglm.cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.