Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你们确定提供的代码真的能通过运行成功吗? #145

Open
pio57019 opened this issue Nov 18, 2024 · 2 comments
Open

你们确定提供的代码真的能通过运行成功吗? #145

pio57019 opened this issue Nov 18, 2024 · 2 comments

Comments

@pio57019
Copy link

pio57019 commented Nov 18, 2024

我挨个尝试了你们提供的代码,全部都不是这错就是那错,不是这缺失就是那缺失,我严重怀疑你们的东西真的有没有人用得了的,哪怕 1 个人.

最后我尝试只有这个代码能跑,于是并改写了它,结果最后还是掉链子,连问AI,AI都回答不了.
你们能先裸机安装看看确定真的能用能安装好,然后才信心放出来行吗??能靠谱一点,真的让人可用行吗?

xxx - 副本

1.py.json


import requests
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
import time
MAX_RETRIES = 500
retry_count = 0

while retry_count < MAX_RETRIES:
try:
device = torch.device("cpu")
#device = torch.device("cuda:0")
model_info = "BAAI/AquilaChat2-7B"
tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True, torch_dtype=torch.bfloat16)
model.eval()
model.to(device)
text = "请给出10个要到北京旅游的理由。"
from predict import predict
out = predict(model, text, tokenizer=tokenizer, max_gen_len=5200, top_p=0.95,
seed=1234, topk=100, temperature=0.9, sft=True, device=device,
model_name="AquilaChat2-7B")
print(out)
break # 如果成功加载并运行到这一步,说明没有问题了,跳出循环
except requests.exceptions.ChunkedEncodingError as e:
print(f"下载模型文件时出现错误: {e}")
print(f"正在进行第 {retry_count + 1} 次重试...")
# 可以在这里添加一些等待时间,避免过于频繁地重试导致问题持续存在
time.sleep(5) # 等待5秒后再重试,可根据实际情况调整等待时间
retry_count += 1
except Exception as other_e:
print(f"出现其他未知错误: {other_e}")
break # 对于其他未知错误,直接跳出循环,避免无限重试

if retry_count == MAX_RETRIES:
print("已达到最大重试次数,仍然无法成功下载模型文件,请检查网络连接或手动下载模型文件后配置本地加载。")

@ftgreat
Copy link
Contributor

ftgreat commented Nov 19, 2024

感谢使用和反馈。

  1. 看你给的使用方式是加载huggingface上的模型,需要确认模型和配置文件是否全部下载完成。
    提示缺失的文件huggingface上是有的,怀疑是不是没有下载完全。
    image

  2. 模型需要在cuda上运行,cpu上没有试过,cpu上使用的话我们一般用其他推理框架比如llama.cpp这些

@ftgreat
Copy link
Contributor

ftgreat commented Nov 19, 2024

假设模型下载目录为A,“from predict import predict”不存在的报错,可以试试
PYTHONPATH=A python main.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants