当前位置: 首页> 教育> 幼教 > 深圳建企业网站公司_十大房产中介软件_合肥关键词优化平台_天津seo推广

深圳建企业网站公司_十大房产中介软件_合肥关键词优化平台_天津seo推广

时间:2025/7/12 5:53:28来源:https://blog.csdn.net/quickrubber/article/details/146467939 浏览次数:0次
深圳建企业网站公司_十大房产中介软件_合肥关键词优化平台_天津seo推广

前言 

       我在运行魔塔社区(modelscope)的ZhipuAI/chatglm3-6b模型(智谱)的实例程序的时候,碰到了一个奇怪的错误(torch.empty),我尝试解决了一下。

(当前采用的Python版本是3.11,程序在PyCharm中调试,torch采用的是cpu版本)

一、错误提示

  File "D:\PycharmProjects\ChatGLM3_py311_cpu_test\venv\Lib\site-packages\torch\nn\modules\sparse.py", line 167, in __init__

    torch.empty((num_embeddings, embedding_dim), **factory_kwargs),

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=str, device=str), but expected one of:

 * (tuple of ints size, *, tuple of names names, torch.memory_format memory_format = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)

二、初步判断

初步判断是torch的版本和transformers的版本没有对应上。

目前版本的对应关系如下:

直接运行

 pip install torch==2.0.0  transformers==4.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple   

出现了“can't find Rust compilier”的错误。

三、can't find Rust compiler

这个错误怎么如何解决?

参考这个链接:

pycharm安装其它库包,报错提示error:can‘t find Rust compiler,错误:找不到Rust编译器_error: can't find rust compiler-CSDN博客

但是似乎又有所不同,直接运行命令easy_install -U pip   似乎不行,如下图:

可能是pycharm的版本比较新,改为如下命令:

pip install --upgrade pip

得到提示后,重新运行了命令:

再安装cryptography

没有什么用,错误依旧

四、跳过问题3

将安装命令修改为:

pip install torch==2.3.0  transformers==4.40.0 -i https://pypi.tuna.tsinghua.edu.cn/simple  

想不到后续安装顺利,实例程序可以正常运行了,如下图:

以下是各个包的版本情况,如下2个图:


五、源程序的链接

https://download.csdn.net/download/quickrubber/90525630

关键字:深圳建企业网站公司_十大房产中介软件_合肥关键词优化平台_天津seo推广

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: