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] Fix cuda link target of cumem_allocator in CPU env #12863

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

guoyuhong
Copy link
Contributor

@guoyuhong guoyuhong commented Feb 7, 2025

FIX #12862

It looks like that the build system could not find -lcuda correctly in the CPU container.
list(APPEND CUMEM_LIBS cuda) is too simple for a CPU build env, ld cannot find the location. It is better to use CUDA::cuda_driver which is a full path.

Copy link

github-actions bot commented Feb 7, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the ci/build label Feb 7, 2025
@guoyuhong guoyuhong force-pushed the fix_cumem_allocator_cmake branch from 38bf907 to 3b09f0c Compare February 7, 2025 03:06
Signed-off-by: YuhongGuo <yuhong.gyh@antgroup.com>
@guoyuhong guoyuhong changed the title Fix cuda link target of cumem_allocator in CPU env [Build] Fix cuda link target of cumem_allocator in CPU env Feb 7, 2025
@guoyuhong
Copy link
Contributor Author

@tlrmchlsmth do you some comments on this code change?

@@ -192,7 +192,7 @@ set_gencode_flags_for_srcs(
if(VLLM_GPU_LANG STREQUAL "CUDA")
message(STATUS "Enabling cumem allocator extension.")
# link against cuda driver library
list(APPEND CUMEM_LIBS cuda)
list(APPEND CUMEM_LIBS CUDA::cuda_driver)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems reasonable to me -- @youkaichao WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually can we just delete this line completely? We have this link line in define_gpu_extension_target already:

vllm/cmake/utils.cmake

Lines 437 to 443 in 2ae8890

# Don't use `TORCH_LIBRARIES` for CUDA since it pulls in a bunch of
# dependencies that are not necessary and may not be installed.
if (GPU_LANGUAGE STREQUAL "CUDA")
target_link_libraries(${GPU_MOD_NAME} PRIVATE CUDA::cudart CUDA::cuda_driver)
else()
target_link_libraries(${GPU_MOD_NAME} PRIVATE ${TORCH_LIBRARIES})
endif()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per my analysis, only when GPU_LANGUAGE STREQUAL "CUDA" the CUDA::cudart lib is linked in define_gpu_extension_target. However, the GPU_LANGUAGE for cumem_allocator is CXX. I think that is why extra libcuda is added to CUMEM_LIBS.

Copy link
Collaborator

@tlrmchlsmth tlrmchlsmth left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Verified that this doesn't break my existing build process. I also feel comfortable with the change as this is the official way to do it -see https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html.

Going to see if this avoids the ld issues that popped up when I tried #12424

@tlrmchlsmth tlrmchlsmth added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 10, 2025
@guoyuhong
Copy link
Contributor Author

@tlrmchlsmth Thanks. I also tested whether we could remove this line of code. The building process was fine but there will be undefined symbol as follows.

image

Copy link
Member

@youkaichao youkaichao left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

@youkaichao youkaichao merged commit da31719 into vllm-project:main Feb 11, 2025
51 of 71 checks passed
@guoyuhong guoyuhong deleted the fix_cumem_allocator_cmake branch February 12, 2025 02:32
SzymonOzog pushed a commit to SzymonOzog/vllm that referenced this pull request Feb 12, 2025
…ect#12863)

Signed-off-by: YuhongGuo <yuhong.gyh@antgroup.com>
Co-authored-by: Tyler Michael Smith <tyler@neuralmagic.com>
Signed-off-by: SzymonOzog <szymon.ozog@aleph-alpha.com>
kwang1012 pushed a commit to kwang1012/vllm that referenced this pull request Feb 12, 2025
…ect#12863)

Signed-off-by: YuhongGuo <yuhong.gyh@antgroup.com>
Co-authored-by: Tyler Michael Smith <tyler@neuralmagic.com>
panf2333 pushed a commit to yottalabsai/vllm that referenced this pull request Feb 18, 2025
…ect#12863)

Signed-off-by: YuhongGuo <yuhong.gyh@antgroup.com>
Co-authored-by: Tyler Michael Smith <tyler@neuralmagic.com>
kerthcet pushed a commit to kerthcet/vllm that referenced this pull request Feb 21, 2025
…ect#12863)

Signed-off-by: YuhongGuo <yuhong.gyh@antgroup.com>
Co-authored-by: Tyler Michael Smith <tyler@neuralmagic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/build ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Installation]: building wheel failed in CPU containers with CUDA libs
3 participants