install_base.sh
The install_base.sh
script is a Bash script designed to initialise and prepare the NVIDIA TensorRT Large Language Model (LLM) Docker container environment by installing necessary dependencies, configuring the environment, and ensuring compatibility with the host's development environment.
This script caters to different Linux distributions, specifically Ubuntu and CentOS, by checking the system's ID and executing the appropriate installation and configuration commands.
Shebang and Bash Options
#!/bin/bash
: Specifies the script should be run with Bash.set -ex
: Sets the script to exit immediately if any command exits with a non-zero status (-e
) and prints each command to standard error before execution (-x
), aiding in debugging.
Function Definitions
set_bash_env
This function ensures that a file specified by the BASH_ENV
variable exists and is configured to source another environment file specified by the ENV
variable.
This is essential for preserving and automatically loading environment variables across different shell sessions within the Docker container.
init_ubuntu
Handles the initialisation for Ubuntu-based containers.
It updates the package lists, installs essential tools and libraries (like ccache
, gdb
, git-lfs
, libffi-dev
, etc.), and configures the LD_LIBRARY_PATH
environment variable to include CUDA library paths.
It also conditionally installs openmpi-bin
and libopenmpi-dev
if not already present and cleans up the apt cache to reduce the image size.
Additionally, it removes any pre-installed TensorRT packages to avoid version conflicts.
install_python_centos
Installs a specific Python version on CentOS containers by first removing any existing Python 3 installations, downloading the specified Python version, configuring, compiling, and installing it into /opt/python/
.
It also sets up the environment so that this Python version is used by default.
install_pyp_centos
Installs Python packages urllib3
(with a version constraint) and pytest
using pip3, specifically for CentOS containers.
OS Detection and Script Logic
The script detects the operating system by reading the ID
value from /etc/os-release
and branches its execution flow accordingly:
For
ubuntu
, it callsinit_ubuntu
to set up the environment.For
centos
, it installs Python, additional Python packages, GCC, and development tools through their respective functions.If the OS is not recognized, it prints an error message and exits.
Summary
install_base.sh
is a script tailored for setting up NVIDIA TensorRT LLM Docker containers with the necessary development tools, libraries, and environment configurations.
Last updated