Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Make pypi install work on CPU platform #12874

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def load_module_from_path(module_name, path):
"Building on %s, "
"so vLLM may not be able to run correctly", sys.platform)
VLLM_TARGET_DEVICE = "empty"
elif (sys.platform.startswith("linux") and torch.version.cuda is None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check for torch.version.hip alongside torch.version.cuda, otherwise on ROCm it'll fall back to CPU

and os.getenv("VLLM_TARGET_DEVICE") is None):
# if cuda is not available and VLLM_TARGET_DEVICE is not set,
# fallback to cpu
VLLM_TARGET_DEVICE = "cpu"

MAIN_CUDA_VERSION = "12.1"

Expand Down Expand Up @@ -482,7 +487,6 @@ def get_vllm_version() -> str:
version = get_version(
write_to="vllm/_version.py", # TODO: move this to pyproject.toml
)

sep = "+" if "+" not in version else "." # dev versions might contain +

if _no_device():
Expand Down Expand Up @@ -520,7 +524,8 @@ def get_vllm_version() -> str:
elif _is_tpu():
version += f"{sep}tpu"
elif _is_cpu():
version += f"{sep}cpu"
if envs.VLLM_TARGET_DEVICE == "cpu":
version += f"{sep}cpu"
Comment on lines -523 to +528
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this guard now for cpu?

Copy link
Contributor Author

@wangxiyuan wangxiyuan Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little tricky here. Like L491 does,

if _no_device():
    if envs.VLLM_TARGET_DEVICE == "empty":
        version += f"{sep}empty"

it's used for check if the VLLM_TARGET_DEVICE is set by hand or not.
_is_cpu() means VLLM_TARGET_DEVICE is set to cpu by hand or by code logic. envs.VLLM_TARGET_DEVICE == "cpu" means it's set by hand.

When users build vllm by hand like VLLM_TARGET_DEVICE=cpu python setup.py install the version will will contains the suffix cpu which is the origin behavior.

When use pip install vllm, the version will not contain the suffix cpu. If it contains the suffix cpu , the error has inconsistent version: expected '0.7.2', but metadata has '0.7.2+cpu' will be raised by pip like the commit message say.

elif _is_xpu():
version += f"{sep}xpu"
else:
Expand Down