TensorRT-LLM Docker镜像制作

在镜像内安装trt-llm

在trt-llm的docker中默认的基础镜像是nvcr.io/nvidia/pytorch:23.08-py3。因此,尝试在该基础镜像中安装trt-llm。

依赖:

  • TensorRT 9.1.0.4 
  • docker版本23.08

步骤:

1. 宿主机联网,启动容器,容器内也要联网

 启动镜像的方法:

2023-10-26 09:07:57 docker run --gpus all -it --privileged --network=host --shm-size=16G --ulimit memlock=-1 --name trt-llm -v /var/lib/placements:/workspace nvcr.io/nvidia/pytorch:23.08-py3

2. 在容器内拉取TensorRT-LLM仓库

# TensorRT-LLM uses git-lfs, which needs to be installed in advance.
apt-get update && apt-get -y install git git-lfs

git clone https://github.com/NVIDIA/TensorRT-LLM.git
cd TensorRT-LLM
git submodule update --init --recursive
git lfs install
git lfs pull

3. 安装必要的依赖,然后构建tensorrt_llm的whl

cd /home/gqjiang/src/llmtest/
cd docker/common/
bash install_base.sh
bash install_cmake.sh 
bash install_tensorrt.sh 
bash install_polygraphy.sh 
bash install_pytorch.sh skip
cd ../..
python3 ./scripts/build_wheel.py --clean  --trt_root /usr/local/tensorrt

注意:

  • 该过程中,安装tensorrt过程比较长

  • 预留出至少100G左右的磁盘空间

此外,还可以直接按照官方方法安装

一步构建tensorrt_llm的whl

# TensorRT-LLM uses git-lfs, which needs to be installed in advance.
apt-get update && apt-get -y install git git-lfs

git clone https://github.com/NVIDIA/TensorRT-LLM.git
cd TensorRT-LLM
git submodule update --init --recursive
git lfs install
git lfs pull


make -C docker release_build

你可能感兴趣的:(docker,人工智能)