Skip to content

Commit c7fa609

Browse files
tomeras91LeiWang1999
authored andcommitted
[CI/Build] build on empty device for better dev experience (vllm-project#4773)
Signed-off-by: LeiWang1999 <leiwang1999@outlook.com>
1 parent 749757b commit c7fa609

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

requirements-cuda.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ nvidia-ml-py # for pynvml package
77
torch == 2.4.0
88
# These must be updated alongside torch
99
torchvision == 0.19 # Required for phi3v processor. See https://github.com/pytorch/vision?tab=readme-ov-file#installation for corresponding version
10-
xformers == 0.0.27.post2 # Requires PyTorch 2.4.0
11-
vllm-flash-attn == 2.6.1 # Requires PyTorch 2.4.0
10+
xformers == 0.0.27.post2; platform_system == 'Linux' and platform_machine == 'x86_64' # Requires PyTorch 2.4.0
11+
vllm-flash-attn == 2.6.1; platform_system == 'Linux' and platform_machine == 'x86_64' # Requires PyTorch 2.4.0

setup.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ def embed_commit_hash():
6161

6262
VLLM_TARGET_DEVICE = envs.VLLM_TARGET_DEVICE
6363

64-
# vLLM only supports Linux platform
65-
assert sys.platform.startswith(
66-
"linux"), "vLLM only supports Linux platform (including WSL)."
64+
if not sys.platform.startswith("linux"):
65+
logger.warning(
66+
"vLLM only supports Linux platform (including WSL). "
67+
"Building on %s, "
68+
"so vLLM may not be able to run correctly", sys.platform)
69+
VLLM_TARGET_DEVICE = "empty"
6770

6871
MAIN_CUDA_VERSION = "12.1"
6972

@@ -231,6 +234,10 @@ def build_extensions(self) -> None:
231234
subprocess.check_call(["cmake", *build_args], cwd=self.build_temp)
232235

233236

237+
def _no_device() -> bool:
238+
return VLLM_TARGET_DEVICE == "empty"
239+
240+
234241
def _is_cuda() -> bool:
235242
has_cuda = torch.version.cuda is not None
236243
return (VLLM_TARGET_DEVICE == "cuda" and has_cuda
@@ -350,7 +357,9 @@ def find_version(filepath: str) -> str:
350357
def get_vllm_version() -> str:
351358
version = find_version(get_path("vllm", "version.py"))
352359

353-
if _is_cuda():
360+
if _no_device():
361+
version += "+empty"
362+
elif _is_cuda():
354363
cuda_version = str(get_nvcc_cuda_version())
355364
if cuda_version != MAIN_CUDA_VERSION:
356365
cuda_version_str = cuda_version.replace(".", "")[:3]
@@ -404,7 +413,9 @@ def _read_requirements(filename: str) -> List[str]:
404413
resolved_requirements.append(line)
405414
return resolved_requirements
406415

407-
if _is_cuda():
416+
if _no_device():
417+
requirements = _read_requirements("requirements-cuda.txt")
418+
elif _is_cuda():
408419
requirements = _read_requirements("requirements-cuda.txt")
409420
cuda_major, cuda_minor = torch.version.cuda.split(".")
410421
modified_requirements = []
@@ -453,6 +464,9 @@ def _read_requirements(filename: str) -> List[str]:
453464
ext_modules = []
454465
package_data["vllm"].append("*.so")
455466

467+
if _no_device():
468+
ext_modules = []
469+
456470
setup(
457471
name="vllm",
458472
version=get_vllm_version(),

0 commit comments

Comments
 (0)