A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 17, 04:15 UTC
[CI/Build] respect the common environment variable MAX_JOBS (#3600)
youkaichao committed
Mar 24, 2024 at 17:04 UTC
42bc386129f6890aa1654c31aa17a415f7642a5e
2 files changed
+22
-6
docs/source/getting_started/installation.rst
+9
@@ -60,6 +60,15 @@ You can also build and install vLLM from source:
60
$ cd vllm
61
$ pip install -e . # This may take 5-10 minutes.
62
63
+.. tip::
64
+ To avoid your system being overloaded, you can limit the number of compilation jobs
65
+ to be run simultaneously, via the environment variable `MAX_JOBS`. For example:
66
+
67
+ .. code-block:: console
68
+
69
+ $ export MAX_JOBS=6
70
+ $ pip install -e .
71
+
72
.. tip::
73
If you have trouble building vLLM, we recommend using the NVIDIA PyTorch Docker image.
74
setup.py
+13
-6
@@ -1,6 +1,7 @@
1
import io
2
import os
3
import re
4
+import logging
5
import subprocess
6
import sys
7
from typing import List
@@ -13,6 +14,7 @@ import torch
14
from torch.utils.cpp_extension import CUDA_HOME
15
16
ROOT_DIR = os.path.dirname(__file__)
17
+logger = logging.getLogger(__name__)
18
19
# vLLM only supports Linux platform
20
assert sys.platform.startswith(
@@ -54,12 +56,17 @@ class cmake_build_ext(build_ext):
56
# Determine number of compilation jobs and optionally nvcc compile threads.
57
#
58
def compute_num_jobs(self):
57
- try:
58
- # os.sched_getaffinity() isn't universally available, so fall back
59
- # to os.cpu_count() if we get an error here.
60
- num_jobs = len(os.sched_getaffinity(0))
61
- except AttributeError:
62
- num_jobs = os.cpu_count()
59
+ num_jobs = os.environ.get("MAX_JOBS", None)
60
+ if num_jobs is not None:
61
+ num_jobs = int(num_jobs)
62
+ logger.info(f"Using MAX_JOBS={num_jobs} as the number of jobs.")
63
+ else:
64
+ try:
65
+ # os.sched_getaffinity() isn't universally available, so fall
66
+ # back to os.cpu_count() if we get an error here.
67
+ num_jobs = len(os.sched_getaffinity(0))
68
+ except AttributeError:
69
+ num_jobs = os.cpu_count()
70
71
nvcc_threads = None
72
if _is_cuda():