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

Open
#2,264 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, pytorch
Domain
documentation

Research direction

In the InternLM/Tutorial repository, search for the L1 G4000 tutorial and the listed conda and pip commands. Review the dependency-installation order and the torch/CUDA verification snippet. Done means the documented sequence preserves the requested PyTorch 2.0.1 with CUDA 11.7 and explains how to verify it before model inference.

Written by the indexing model from the issue text.

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
Dominant language
Python
Stars
2k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from InternLM/Tutorial

All issues in InternLM/Tutorial

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.