1
+ #! /bin/bash
2
+
3
+ check_command () {
4
+ command -v " $1 " > /dev/null 2>&1
5
+ }
6
+
7
+ ensure_installed () {
8
+ local pkg=" $1 "
9
+ if ! check_command " $pkg " ; then
10
+ echo " $pkg is not installed. Installing $pkg ..."
11
+
12
+ # Determine if sudo is needed
13
+ if check_command sudo; then
14
+ SUDO=" sudo"
15
+ else
16
+ SUDO=" "
17
+ fi
18
+
19
+ # Detect OS and install accordingly
20
+ OS=" $( uname -s) "
21
+ if [[ " $OS " == " Linux" ]]; then
22
+ if check_command apt-get; then
23
+ $SUDO apt-get update && $SUDO apt-get install -y " $pkg "
24
+ fi
25
+ else
26
+ echo " Unsupported OS: $OS . Please install $pkg manually."
27
+ exit 1
28
+ fi
29
+ else
30
+ echo " $pkg is already installed."
31
+ fi
32
+ }
33
+
34
+ ensure_mpi_installed () {
35
+ local pkg=" $1 "
36
+ if dpkg -l | grep -q " $pkg " ; then
37
+ echo " $pkg is already installed."
38
+ else
39
+ echo " $pkg is not installed. Installing $pkg ..."
40
+
41
+ # Determine if sudo is needed
42
+ if check_command sudo; then
43
+ SUDO=" sudo"
44
+ else
45
+ SUDO=" "
46
+ fi
47
+
48
+ # Detect OS and install accordingly
49
+ OS=" $( uname -s) "
50
+ if [[ " $OS " == " Linux" ]]; then
51
+ if check_command apt-get; then
52
+ $SUDO apt-get update && $SUDO apt-get install -y " $pkg "
53
+ fi
54
+ else
55
+ echo " Unsupported OS: $OS . Please install $pkg manually."
56
+ exit 1
57
+ fi
58
+ fi
59
+ }
60
+
61
+ ensure_pytest_installed (){
62
+ if check_command pip; then
63
+ echo " pip is installed, installing pytest..."
64
+ pip install pytest
65
+ else
66
+ echo " pip is not installed. Please install pip first."
67
+ exit 1
68
+ fi
69
+ }
70
+
71
+ echo " Setting up the environment"
72
+
73
+ OS=" $( uname -s) "
74
+ ARCH=" $( uname -m) "
75
+ PYTHON_VERSION=" $( python3 -c ' import sys; print(f"cp{sys.version_info.major}{sys.version_info.minor}")' ) "
76
+
77
+
78
+ # getting the file name for TensorRT-LLM download
79
+ if [[ " $OS " == " Linux" && " $ARCH " == " x86_64" && " $PYTHON_VERSION " == " cp312" ]]; then
80
+ FILE=" tensorrt_llm-0.17.0.post1-cp312-cp312-linux_x86_64.whl"
81
+ elif [[ " $OS " == " Linux" && " $ARCH " == " aarch64" && " $PYTHON_VERSION " == " cp312" ]]; then
82
+ FILE=" tensorrt_llm-0.17.0.post1-cp312-cp312-linux_aarch64.whl"
83
+ elif [[ " $OS " == " Linux" && " $ARCH " == " x86_64" && " $PYTHON_VERSION " == " cp310" ]]; then
84
+ FILE=" tensorrt_llm-0.17.0.post1-cp310-cp310-linux_x86_64.whl"
85
+ elif [[ " $OS " == " Linux" && " $ARCH " == " aarch64" && " $PYTHON_VERSION " == " cp310" ]]; then
86
+ FILE=" tensorrt_llm-0.17.0.post1-cp310-cp310-linux_aarch64.whl"
87
+ else:
88
+ echo " Unsupported platform: OS=$OS ARCH=$ARCH PYTHON=$PYTHON_VERSION "
89
+ exit 1
90
+ fi
91
+
92
+ # Download the selected file
93
+ URL=" https://pypi.nvidia.com/tensorrt-llm/$FILE "
94
+ echo " Downloading $FILE from $URL ..."
95
+
96
+ echo " Downloading ...."
97
+ # Installing wget
98
+ ensure_installed wget
99
+ # Downloading the package
100
+ wget " $URL "
101
+ echo " Download complete: $FILE "
102
+
103
+ UNZIP_DIR=" tensorrt_llm_unzip"
104
+ if [[ ! -d " $UNZIP_DIR " ]]; then
105
+ echo " Creating directory: $UNZIP_DIR "
106
+ mkdir -p " $UNZIP_DIR "
107
+ echo " extracting $FILE to $UNZIP_DIR ..."
108
+ # Installing unzip
109
+ ensure_installed unzip
110
+ # unzip the TensorRT-LLM package
111
+ unzip -q " $FILE " -d " $UNZIP_DIR "
112
+ echo " Unzip complete"
113
+ fi
114
+
115
+
116
+ export TRTLLM_PLUGINS_PATH=" $( pwd) /${UNZIP_DIR} /tensorrt_llm/libs/libnvinfer_plugin_tensorrt_llm.so"
117
+ echo ${TRTLLM_PLUGINS_PATH}
118
+
119
+ ensure_mpi_installed libmpich-dev
120
+ ensure_mpi_installed libopenmpi-dev
121
+
122
+ run_tests () {
123
+ cd ..
124
+ export PYTHONPATH=$( pwd) # Set PYTHONPATH to the current directory
125
+ echo " Running pytest on distributed/test_nccl_ops.py..."
126
+ pytest distributed/test_nccl_ops.py
127
+ }
128
+
129
+ run_mpi_tests (){
130
+ cd distributed
131
+ echo " Running test_distributed_simple_example with mpirun..." ---
132
+ mpirun -n 1 --allow-run-as-root python test_distributed_simple_example.py
133
+ }
134
+
135
+ ensure_pytest_installed
136
+ run_tests
137
+ run_mpi_tests
0 commit comments