pycharm搭建本地环境训练deepseek模型时遇到问题求救

利用pycharm搭建本地环境,训练deepseek大模型时,在python脚本中import torch,torch.__version__输出结果为none,torch.cuda.is_available()输出结果为False,导致出错:

The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable. CUDA is required but not available for bitsandbytes. Please consider installing the multi-platform enabled version of bitsandbytes, which is currently a work in progress. Please check currently supported platforms and installation...

请教大神,这个问题该怎么解决。

### 加载并使用本地 DeepSeek 模型 为了在 PyCharm 中加载并使用本地 DeepSeek 模型对表格数据进行预测,需遵循一系列配置和编程操作。 #### 安装必要的环境 确保环境中已安装 Python 3 并且其版本与 DeepSeek-R1 模型兼容[^1]。推荐使用 Anaconda 来管理依赖项以及创建隔离的工作环境。对于集成开发环境的选择,可以考虑使用 PyCharm 进行项目管理和代码编写工作[^2]。 #### 准备工作空间 启动 PyCharm 后,新建或打开现有项目,在此项目内设置合适的虚拟环境来安装所需的库文件和其他资源包。 #### 导入所需库 在项目的 `requirements.txt` 文件中添加如下条目以确保所有必需的软件包被正确安装: ```plaintext numpy==最新稳定版 pandas==最新稳定版 torch==DeepSeek所支持的具体版本 transformers==对应于DeepSeek模型的版本 ``` 接着运行命令更新当前环境中的Python包列表: ```bash pip install -r requirements.txt ``` #### 编写预测脚本 创建一个新的 Python 脚本来处理输入的数据集,并调用预训练好的 DeepSeek 模型来进行预测分析。下面是一个简单的例子展示如何实现这一点: ```python import pandas as pd from transformers import AutoModelForSequenceClassification, AutoTokenizer def load_model(model_path): tokenizer = AutoTokenizer.from_pretrained(model_path) model = AutoModelForSequenceClassification.from_pretrained(model_path) return tokenizer, model def predict_table_data(df, tokenizer, model): predictions = [] for index, row in df.iterrows(): text_input = str(row['text_column']) # 假设表中有名为 'text_column' 的列用于存储待分类文本 inputs = tokenizer(text_input, return_tensors="pt", truncation=True, padding=True) outputs = model(**inputs)[0] prediction = int(outputs.argmax(dim=-1)) predictions.append(prediction) df["prediction"] = predictions return df if __name__ == "__main__": data_file = "./data/sample.csv" sample_df = pd.read_csv(data_file) local_deepseek_path = "/path/to/local/deepseek/model" tokz, mdl = load_model(local_deepseek_path) result_df = predict_table_data(sample_df, tokz, mdl) output_file = "./output/predictions.csv" result_df.to_csv(output_file, index=False) ``` 上述代码片段展示了怎样读取 CSV 格式的表格数据、初始化 Hugging Face 提供的支持多类别的序列分类器(即这里的 DeepSeek),并对每一行记录执行推理计算得出最终的结果保存回新的CSV文档里去。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值