-
Notifications
You must be signed in to change notification settings - Fork 423
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: Help cmake find UCX on system #7096
Conversation
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we add it to rpm/deb files as well?
cmake/ucx-config.cmake.in
Outdated
# Copyright (C) NVIDIA Corporation. 2021. ALL RIGHTS RESERVED. | ||
# | ||
|
||
set(UCX_LIBRARIES "@prefix@/lib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libdir@
(it could be lib64)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libdir@
will be replaced by ${exec_prefix}/lib
, but in the context of cmake, exec_prefix
is not defined. But I can do something like
set(prefix "@prefix@")
set(exec_prefix "@exec_prefix@")
set_target_properties(ucx::ucs PROPERTIES
IMPORTED_LOCATION "@libdir@/libucs.so"
INTERFACE_INCLUDE_DIRECTORIES "@includedir@"
)
cmake/ucx-targets.cmake.in
Outdated
add_library(ucx::ucs SHARED IMPORTED) | ||
|
||
set_target_properties(ucx::ucs PROPERTIES | ||
IMPORTED_LOCATION "@prefix@/lib/libucs.so" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libdir@
instead of @prefix/lib
in all places
cmake/ucx-targets.cmake.in
Outdated
|
||
set_target_properties(ucx::ucp PROPERTIES | ||
IMPORTED_LOCATION "@prefix@/lib/libucp.so" | ||
INTERFACE_INCLUDE_DIRECTORIES "@prefix@/include" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is also @includedir
With this PR it is automatically added to the deb package. I don't know about rpm, but it should be automatic as well. |
cmake/ucx-config.cmake.in
Outdated
set(prefix "@prefix@") | ||
set(exec_prefix "@exec_prefix@") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we include ucx-targets.cmake, can avoid re-defining prefix and exec_prefix?
BTW, why need to separate to 2 cmake files (ucx-config and ucx-targets)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this PR to avoid redefinition. There are two separate files because other projects do so. I guess this is how cmake generates these files (See https://cmake.org/cmake/help/git-stage/guide/importing-exporting/index.html#exporting-targets-from-the-build-tree). But I don't know if this separation is required or not.
cmake/Makefile.am
Outdated
cmake_DATA = \ | ||
ucx-targets.cmake \ | ||
ucx-config.cmake \ | ||
ucx-config-version.cmake |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls remove horizontal spaces before \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There is build error from RPM:
|
01de486
to
70463b4
Compare
@yosefe The rpm problem should be fixed now. |
@zasdfgbnm-nvidia BTW, maybe it's worth adding a small test for cmake?
|
@yosefe Yes, I think it is worth it. I will copy-paste https://github.com/zasdfgbnm/cmake-ucx-ucc/tree/master/Tests/ucx to this repository and take a look at how to add it to CI here. |
@zasdfgbnm one option is to copy-paste this to |
buildlib/tools/builds.sh
Outdated
cd /tmp/cmake-ucx | ||
cmake --build . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to return to previous directory after the test
examples/cmake/test_ucp.c
Outdated
ucp_context_h ucp_context; | ||
ucp_params_t ucp_params; | ||
memset(&ucp_params, 0, sizeof(ucp_params)); | ||
ucp_params.field_mask = UCP_PARAM_FIELD_FEATURES; | ||
ucp_params.features = UCP_FEATURE_AM; | ||
ucs_status_t status = ucp_init(&ucp_params, NULL, &ucp_context); | ||
assert(status == UCS_OK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{
ucp_params_t ucp_params = {};
ucp_context_h ucp_context;
ucs_status_t status;
ucp_params.field_mask = UCP_PARAM_FIELD_FEATURES;
ucp_params.features = UCP_FEATURE_AM;
status = ucp_init(&ucp_params, NULL, &ucp_context);
assert(status == UCS_OK);
ucp_cleanup(ucp_context)
return 0;
}
assert(UCS_OK == status); | ||
|
||
/* Create a worker object */ | ||
status = uct_worker_create(async, UCS_THREAD_MODE_SINGLE, &worker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls destroy the created objects and return 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
examples/cmake/CMakeLists.txt
Outdated
@@ -0,0 +1,11 @@ | |||
cmake_minimum_required(VERSION 3.5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add NVIDIA copyright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -0,0 +1,14 @@ | |||
#include <ucp/api/ucp.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add NVIDIA copyright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -0,0 +1,16 @@ | |||
#include <uct/api/uct.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add NVIDIA copyright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
|
0562bd2
to
a9b0fc4
Compare
The cmake in CI is super old (2.8), the latest is 3.21, that's why it fails with
I have changed the cmake_minimum_required(VERSION 3.5) in the example to cmake_minimum_required(VERSION 2.8) Let's see if it works now. If not, I recommend upgrading the cmake, instead of writing workarounds to support old versions. |
The CI is running on multiple different systems per the required support matrix. In this case, can skip this particular test if cmake version on the system is too old. |
buildlib/tools/builds.sh
Outdated
build_cmake_examples() { | ||
echo "==== Build CMake sample ====" | ||
|
||
${WORKSPACE}/contrib/configure-release --prefix=$ucx_inst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if which cmake
then
... (the current test script)
else
azure_log_warning "cmake executable not found, skipping cmake test"
fi
Test failures seem unrelated |
This PR makes the installation script writes cmake config files to ${prefix}/lib/cmake/ucx so that cmake projects can easily find UCX installed on the system. PyTorch uses cmake, so this will be helpful for PyTorch to integrate the ucx/ucc backend to upstream.
This PR is tested by: https://github.com/zasdfgbnm/cmake-ucx-ucc, please let me know if you want cmake testes to be included in this repository as well.
Related: openucx/ucc#255