llama_index [Bug]:无法在tensor rt llms docker镜像中导入Llama索引模块,

dxpyg8gm  于 22天前  发布在  Docker
关注(0)|答案(1)|浏览(27)

Bug描述

尽管我遵循了llama index的最新文档,但仍然无法导入llama index。
问题1:
Llama index文档链接:https://docs.llamaindex.ai/en/stable/examples/llm/nvidia_tensorrt/
版本:
ubuntu:22.04
cuda : 12.2
架构-->Arm 64
jetpack - 6.0
问题2:
Nvidia jetson容器链接:https://github.com/dusty-nv/jetson-containers?tab=readme-ov-file
版本:
ubuntu:22.04
cuda : 12.2
架构-->Arm 64
jetpack - 6.0
请提供将TensorRT LLM与一些llama index rag模块集成的标准解决方案。
使用的设备:Advantech Jetson Orin NX - 16 GB变体

版本

llama-index 0.10.50

重现步骤

问题1:

  1. 按照llama index文档,逐步执行提供的命令。
  2. 在文档中的第3个命令时出现错误。
    "pip3 install tensorrt_llm==0.8.0 -U --extra-index-url https://pypi.nvidia.com "
    问题2:
  3. 按照dusty nv文档,逐步执行提供的命令。
  4. 在相关日志中出现相同的错误,"$ jetson-containers run $(autotag tensorrt-llm)"

相关日志/回溯

Error:
Looking in indexes: https://pypi.org/simple, https://pypi.nvidia.com
Collecting tensorrt_llm==0.8.0
  Downloading tensorrt-llm-0.8.0.tar.gz (6.9 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
 
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-r7zpl9ve/tensorrt-llm_382951b6d5f34b8798d95f1967eb0620/setup.py", line 90, in <module>
          raise RuntimeError("Bad params")
      RuntimeError: Bad params
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
 
× Encountered error while generating package metadata.
╰─> See above for output.
 
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
v09wglhw

v09wglhw1#

要解决在Advantech Jetson Orin NX - 16 GB变体设备上导入TensorRT LLM Docker镜像中的Llama Index模块时遇到的问题,请按照以下步骤操作:

  1. 确保已安装CUDA 12.2或更高版本:
    验证您的设备是否安装了Nvidia CUDA 12.2或更高版本,因为运行TensorRT-LLM需要它。

  2. 安装tensorrt_llm:
    使用以下pip命令安装tensorrt_llm包:

pip3 install tensorrt_llm -U --extra-index-url https://pypi.nvidia.com
  • 准备Llama2模型文件:

按照TensorRT-LLM GitHub仓库中的说明创建必要的模型文件。应生成以下文件:

  • Llama_float16_tp1_rank0.engine

  • config.json

  • model.cache

  • 整理模型文件:

创建一个名为model的目录,并将生成的文件移动到该目录中:

mkdir model
mv Llama_float16_tp1_rank0.engine config.json model.cache model/
  • 安装Llama Index集成:

为NVIDIA TensorRT安装Llama Index集成:

pip install llama-index-llms-nvidia-tensorrt
  • 运行示例代码:

使用以下Python代码初始化并运行LocalTensorRTLLM:

from llama_index.llms.nvidia_tensorrt import LocalTensorRTLLM

def completion_to_prompt(completion):
    return f"<s> [INST] {completion} [/INST] "

def messages_to_prompt(messages):
    content = ""
    for message in messages:
        content += str(message) + "\n"
    return f"<s> [INST] {content} [/INST] "

llm = LocalTensorRTLLM(
    model_path="./model",
    engine_name="llama_float16_tp1_rank0.engine",
    tokenizer_dir="meta-llama/Llama-2-13b-chat",
    completion_to_prompt=completion_to_prompt,
    messages_to_prompt=messages_to_prompt,
)

resp = llm.complete("Who is Paul Graham?")
print(str(resp))

故障排除 RuntimeError: Bad params

如果您在安装tensorrt_llm过程中遇到RuntimeError: Bad params错误,请按照以下步骤操作:

  1. 确保正确安装:
    重新安装tensorrt_llm:
pip3 install tensorrt_llm -U --extra-index-url https://pypi.nvidia.com
  1. 检查CUDA版本:
    确保您已安装Nvidia CUDA 12.2或更高版本。

  2. 验证模型路径:
    确保提供的model_path存在并包含必要的文件(Llama_float16_tp1_rank0.engine, config.json, model.cache)。

  3. 检查配置文件:
    确保模型目录中的config.json文件格式正确,并包含所有必要的配置。

  4. 验证Tensor并行和流水线并行大小:
    确保config.json中的tensor_parallelpipeline_parallel大小与运行时大小相匹配。

  5. 检查GPU可用性:
    确保有可用的CUDA启用的GPU,并设置正确的设备。

  6. 验证分词器目录:
    确保提供的tokenizer_dir正确,并包含必要的分词器文件。

  7. 检查采样配置:
    确保采样配置参数正确设置。

启用调试模式

要获取有关x1m9n9xx更多信息以解决x9nx错误,请在创建x9nx对象时启用x9nx:
x9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nxbx9nn

相关问题