InternLM / InternLM/Tutorial

关于L1 G4000文档的修改小建议

Ouverte
#2,264 0 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
2k
Forks
1.5k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

关于这个教程文档,我有些修改的小建议。

文档中的配置环境的顺序是这样的:
```
# 1. 创建并激活环境
conda create -n llamaindex python=3.10
conda activate llamaindex

# 2. 首先安装特定版本的 PyTorch,并确保使用 CUDA 11.7
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia

# 3. 安装基础依赖
pip install einops==0.7.0 protobuf==5.26.1

# 4. 安装 LLamaIndex 相关
pip install llama-index==0.10.38
pip install llama-index-llms-huggingface==0.2.0
pip install "transformers[torch]==4.41.1"
pip install "huggingface_hub[inference]==0.23.1" huggingface_hub==0.23.1
pip install sentence-transformers==2.7.0
pip install sentencepiece==0.2.0

# 5. 安装向量依赖包
pip install llama-index-embeddings-huggingface==0.2.0
pip install llama-index-embeddings-instructor==0.1.3
```
**存在的问题是:匹配cuda11.7的torch安装在前,但是其后安装 LLamaIndex 相关的指令会稳定触发torch的升级到最新版本,而新版本的PyTorch (2.5.1) 默认使用CUDA 12.4**
```
pip install llama-index==0.10.38 llama-index-llms-huggingface==0.2.0 "transformers[torch]==4.41.1" "huggingface_hub[inference]==0.23.1" huggingface_hub==0.23.1 sentence-transformers==2.7.0 sentencepiece==0.2.0

pip install llama-index-embeddings-huggingface==0.2.0 llama-index-embeddings-instructor==0.1.3
```
这样,当进行到模型推理的步骤时,就会有
```
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling cublasCreate(handle)
```
报错,也就是说安装教程的顺序走,稳定会在模型推理的的时候遇到cuda报错(虽然文档有一行对应的提示)

必须再次重新安装正确的torch:
```
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
```

---

文档里关于环境配置的内容也许可以这样修改:
```
# 1. 创建并激活环境
conda create -n llamaindex python=3.10
conda activate llamaindex

# 2. 安装基础依赖
pip install einops==0.7.0 protobuf==5.26.1

# 3. 先安装 LlamaIndex 和相关包,让它自动处理依赖关系
# 注意:此时 pip 会安装与你当前环境不同的 torch 版本。
pip install llama-index==0.10.38 llama-index-llms-huggingface==0.2.0 "transformers[torch]==4.41.1" "huggingface_hub[inference]==0.23.1" huggingface_hub==0.23.1 sentence-transformers==2.7.0 sentencepiece==0.2.0

# 4. 安装向量依赖包
pip install llama-index-embeddings-huggingface==0.2.0 llama-index-embeddings-instructor==0.1.3

# 5. 强制重装特定版本的 PyTorch (这会覆盖/降级之前自动安装的版本)
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
```

安装完成后,验证 torch 是否正确安装并使用了指定的 CUDA 版本:
```
import torch
print(torch.__version__) # 应输出类似 '2.0.1'
print(torch.version.cuda) # 应输出 '11.7'
print(torch.cuda.is_available())# 应输出 True
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.