Skip to content

Commit b9f517b

Browse files
cpu only env compat
Signed-off-by: Yuan Tong <13075180+tongyuantongyu@users.noreply.github.com>
1 parent 74ef39a commit b9f517b

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

jenkins/L0_Test.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ def getPytestBaseCommandLine(
10781078
if (stageName.contains("-Ray-")) {
10791079
testCmdLine += ["--run-ray"]
10801080
}
1081-
def unittestMarkExpr = (stageName.startsWith("CPU-") || stageName.contains("-CPU-")) ? "cpu_only and not disabled" : "not cpu_only"
1081+
def unittestMarkExpr = (stageName.startsWith("CPU-")) ? "cpu_only and not disabled" : "not cpu_only"
10821082
testCmdLine += ["--unittest-markexpr=${unittestMarkExpr}"]
10831083
if (extraArgs) {
10841084
testCmdLine += extraArgs
@@ -2911,7 +2911,7 @@ def renderTestDB(pipeline, testContext, llmSrc, stageName, preDefinedMakoOpts=nu
29112911

29122912
if (!makoOpts) {
29132913
def makoArgs = getMakoArgsFromStageName(stageName)
2914-
if (stageName.startsWith("CPU-") || stageName.contains("-CPU-")) {
2914+
if (stageName.startsWith("CPU-")) {
29152915
def cpuName = env.targetArch == AARCH64_TRIPLE ? "aarch64" : "x86_64"
29162916
makoOpts = transformMakoArgsToJson(
29172917
["Mako options:"] + makoArgs + [
@@ -3518,7 +3518,10 @@ def runLLMTestlistOnPlatformImpl(pipeline, platform, testList, config=VANILLA_CO
35183518
sh "nproc && free -g && hostname"
35193519
echoNodeAndGpuInfo(pipeline, stageName)
35203520
sh "cat ${MODEL_CACHE_DIR}/README"
3521-
sh "nvidia-smi && nvidia-smi -q && nvidia-smi topo -m"
3521+
sh "nvidia-smi && nvidia-smi -q && nvidia-smi topo -m || echo nvidia-smi missing"
3522+
if (stageName.startsWith("CPU-")) {
3523+
sh "ln -s /usr/local/cuda/compat/lib.real /usr/local/cuda/compat/lib"
3524+
}
35223525
sh "df -h"
35233526

35243527
// setup HF_HOME to cache model and datasets

tensorrt_llm/profiler.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
import contextlib
1516
import time
1617
from functools import partial
1718
from typing import Literal, Optional, Tuple, Union
@@ -110,18 +111,23 @@ def summary():
110111
MemUnitType = Literal["GiB", "MiB", "KiB"]
111112

112113

113-
class PyNVMLContext:
114-
def __enter__(self):
115-
if pynvml is not None:
114+
@contextlib.contextmanager
115+
def pynvml_context():
116+
has_pynvml = pynvml is not None
117+
if has_pynvml:
118+
try:
116119
pynvml.nvmlInit()
120+
except pynvml.NVMLError:
121+
has_pynvml = False
117122

118-
def __exit__(self, type, value, traceback):
119-
if pynvml is not None:
120-
pynvml.nvmlShutdown()
123+
yield
124+
125+
if has_pynvml:
126+
pynvml.nvmlShutdown()
121127

122128

123129
if pynvml is not None:
124-
with PyNVMLContext():
130+
with pynvml_context():
125131
_device_get_memory_info_fn = partial(
126132
pynvml.nvmlDeviceGetMemoryInfo,
127133
version=pynvml.nvmlMemory_v2,
@@ -147,7 +153,7 @@ def device_memory_info(device: Optional[Union[torch.device, int]] = None) -> Tup
147153
if device is None:
148154
device = torch.cuda.current_device()
149155
index = device.index if isinstance(device, torch.device) else device
150-
with PyNVMLContext():
156+
with pynvml_context():
151157
handle = pynvml.nvmlDeviceGetHandleByIndex(index)
152158
mem_info = _device_get_memory_info_fn(handle)
153159
return mem_info.used, mem_info.free, mem_info.total

tests/integration/defs/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,13 +1797,17 @@ def get_gpu_device_list():
17971797
suffix = ".exe" if is_windows() else ""
17981798
# TODO: Use NRSU because we can't assume nvidia-smi across all platforms.
17991799
cmd = " ".join(["nvidia-smi" + suffix, "-L"])
1800-
output = check_output(cmd, shell=True, cwd=temp_dirname)
1800+
try:
1801+
output = check_output(cmd, shell=True, cwd=temp_dirname)
1802+
except sp.CalledProcessError:
1803+
return []
18011804
return [l.strip() for l in output.strip().split("\n")]
18021805

18031806

18041807
def check_device_contain(keyword_list):
18051808
"check device not contain keyword"
1806-
device = get_gpu_device_list()[0]
1809+
devices = get_gpu_device_list()
1810+
device = devices[0] if devices else ""
18071811
return any(keyword in device for keyword in keyword_list)
18081812

18091813

0 commit comments

Comments
 (0)