赞
踩
经查阅,这个问题是因为conda默认安装的是CPU版本的torch,应该使用GPU版本的。
pip list
这种不带后缀的,就CPU版本的。
pip uninstall torch
注意:这个特别要注意版本兼容,需要兼顾:
1.cuda :12.0
2.python :3.11
命令:nvidia-smi
我的是12.0,算比较新的,就不更新了。
如果直接从资料库安装,很慢,建议下载后手工安装。
地址:https://mirror.sjtu.edu.cn/pytorch-wheels/cu121/?mirror_intel_list
需要3个文件:
pip install “d:\ai\torchaudio-2.1.0+cu121-cp311-cp311-win_amd64.whl”
之前的不报错了。
又报新的错误:
File "D:\ProgramData\anaconda3\envs\chatglm\Lib\site-packages\cpm_kernels\library\base.py", line 72, in wrapper
raise RuntimeError("Library %s is not initialized" % self.__name)
RuntimeError: Library cublasLt is not initialized
NVIDIA Corporation\PhysX\Common下,缺少cudart64_65.dll文件
想到cuda是12.0,与torch要求的12.1还是有些许差异。更新到12.1.
文件出现了
再次运行程序,终于成功了!
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("D:\AI\chatglm3-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("D:\AI\chatglm3-6b", trust_remote_code=True).quantize(4).half().cuda()
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
D:\ProgramData\anaconda3\envs\chatglm\python.exe C:\Users\frohman\PycharmProjects\pythonProject\main.py
Explicitly passing a `revision` is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.
Explicitly passing a `revision` is encouraged when loading a configuration with custom code to ensure no malicious code has been contributed in a newer revision.
Explicitly passing a `revision` is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.
Loading checkpoint shards: 100%|██████████| 7/7 [00:50<00:00, 7.27s/it]
你好声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/817535
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。