From 6bc59e1c7be648726a2584ca33434875e70cfd33 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 30 Sep 2020 15:02:24 -0400 Subject: [PATCH 1/8] build/python: don't pass --library-dir argument For all I can tell it's not actually recognized by setuptools, nor actually used, and in any case, there is no more actual library. --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 16148a127..d7eace809 100755 --- a/build.sh +++ b/build.sh @@ -133,12 +133,12 @@ if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" if [[ ${INSTALL_TARGET} != "" ]]; then echo "building rmm..." - python setup.py build_ext --inplace --library-dir="${LIBRMM_BUILD_DIR}" + python setup.py build_ext --inplace echo "installing rmm..." python setup.py install --single-version-externally-managed --record=record.txt else echo "building rmm..." - python setup.py build_ext --inplace --library-dir="${LIBRMM_BUILD_DIR}" + python setup.py build_ext --inplace fi fi From 099e3d35286df631019860028ab38be3695f3bc4 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 30 Sep 2020 20:18:58 -0400 Subject: [PATCH 2/8] build/python: add fallback to INSTALL_PREFIX --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index d7eace809..f09bfd557 100755 --- a/build.sh +++ b/build.sh @@ -45,9 +45,9 @@ PER_THREAD_DEFAULT_STREAM=OFF RAN_CMAKE=0 # Set defaults for vars that may not have been defined externally -# FIXME: if INSTALL_PREFIX is not set, check PREFIX, then check -# CONDA_PREFIX, but there is no fallback from there! -INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX}}} +# If INSTALL_PREFIX is not set, check PREFIX, then check +# CONDA_PREFIX, then fall back to install inside of $LIBRMM_BUILD_DIR +INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX:=$LIBRMM_BUILD_DIR/install}}} PARALLEL_LEVEL=${PARALLEL_LEVEL:=""} function hasArg { From 1acb22c48dff75e8977af68a026ae04cf96d460e Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 30 Sep 2020 20:20:51 -0400 Subject: [PATCH 3/8] build/python: use installed location of C++ RMM for python build Various existing hardcoded paths were not actually used anymore, this is generally cleaner, and importantly, if the C++ build pulled in external dependencies that were not locally installed, this will ensure that these are used in the python build. --- build.sh | 1 + python/setup.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index f09bfd557..b6700433c 100755 --- a/build.sh +++ b/build.sh @@ -131,6 +131,7 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" + export INSTALL_PREFIX if [[ ${INSTALL_TARGET} != "" ]]; then echo "building rmm..." python setup.py build_ext --inplace diff --git a/python/setup.py b/python/setup.py index b798fcaf7..bc36689ad 100644 --- a/python/setup.py +++ b/python/setup.py @@ -52,6 +52,11 @@ def get_cuda_version_from_header(cuda_include_dir): cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") CUDA_VERSION = get_cuda_version_from_header(cuda_include_dir) +INSTALL_PREFIX = os.environ.get("INSTALL_PREFIX", False) +if not os.path.isdir(INSTALL_PREFIX): + raise OSError(f"Invalid INSTALL_PREFIX: directory does not exist: {INSTALL_PREFIX}") +rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") + # Preprocessor step to specify correct pxd file with # valid symbols for specific version of CUDA. @@ -78,9 +83,7 @@ def get_cuda_version_from_header(cuda_include_dir): nthreads = 0 include_dirs = [ - "../include/rmm", - "../include", - "../build/include", + rmm_include_dir, os.path.dirname(sysconfig.get_path("include")), cuda_include_dir, ] From 780aa38585efafaea6e29691ee0d503b405c70ab Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 30 Sep 2020 21:30:23 -0400 Subject: [PATCH 4/8] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8398dd7d0..7656830a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - PR #579 CMake: handle thrust via target - PR #581 Improve logging documentation - PR #585 Update ci/local/README.md +- PR #588 Use installed C++ RMM in python build ## Bug Fixes From fd006071b059e576b3436db34f6168250dcb9f89 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 30 Sep 2020 23:13:49 -0400 Subject: [PATCH 5/8] autopep8 --- python/setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index bc36689ad..7bc3eb1bd 100644 --- a/python/setup.py +++ b/python/setup.py @@ -54,7 +54,8 @@ def get_cuda_version_from_header(cuda_include_dir): INSTALL_PREFIX = os.environ.get("INSTALL_PREFIX", False) if not os.path.isdir(INSTALL_PREFIX): - raise OSError(f"Invalid INSTALL_PREFIX: directory does not exist: {INSTALL_PREFIX}") + raise OSError( + f"Invalid INSTALL_PREFIX: directory does not exist: {INSTALL_PREFIX}") rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") # Preprocessor step to specify correct pxd file with From 98ffb8a139215c6d09c3b08da5328b85f290a931 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 30 Sep 2020 23:26:15 -0400 Subject: [PATCH 6/8] reformat via black --- python/rmm/rmm.py | 3 ++- python/setup.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index 9e75ed00f..2f240655e 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -202,7 +202,8 @@ def get_ipc_handle(self, memory): start, end = cuda.cudadrv.driver.device_extents(memory) ipchandle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes cuda.cudadrv.driver.driver.cuIpcGetMemHandle( - ctypes.byref(ipchandle), start, + ctypes.byref(ipchandle), + start, ) source_info = cuda.current_context().device.get_device_identity() offset = memory.handle.value - start diff --git a/python/setup.py b/python/setup.py index 7bc3eb1bd..9cac7a52a 100644 --- a/python/setup.py +++ b/python/setup.py @@ -55,7 +55,8 @@ def get_cuda_version_from_header(cuda_include_dir): INSTALL_PREFIX = os.environ.get("INSTALL_PREFIX", False) if not os.path.isdir(INSTALL_PREFIX): raise OSError( - f"Invalid INSTALL_PREFIX: directory does not exist: {INSTALL_PREFIX}") + f"Invalid INSTALL_PREFIX: directory does not exist: {INSTALL_PREFIX}" + ) rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") # Preprocessor step to specify correct pxd file with @@ -110,7 +111,9 @@ def get_cuda_version_from_header(cuda_include_dir): ], nthreads=nthreads, compiler_directives=dict( - profile=False, language_level=3, embedsignature=True, + profile=False, + language_level=3, + embedsignature=True, ), ) @@ -134,7 +137,9 @@ def get_cuda_version_from_header(cuda_include_dir): ], nthreads=nthreads, compiler_directives=dict( - profile=False, language_level=3, embedsignature=True, + profile=False, + language_level=3, + embedsignature=True, ), ) From ef39dcbf24567fc889b46ea41e23fb1943b19df4 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Thu, 1 Oct 2020 23:43:03 -0400 Subject: [PATCH 7/8] reformat again with black-19.10b0 --- python/rmm/rmm.py | 3 +-- python/setup.py | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index 2f240655e..9e75ed00f 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -202,8 +202,7 @@ def get_ipc_handle(self, memory): start, end = cuda.cudadrv.driver.device_extents(memory) ipchandle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes cuda.cudadrv.driver.driver.cuIpcGetMemHandle( - ctypes.byref(ipchandle), - start, + ctypes.byref(ipchandle), start, ) source_info = cuda.current_context().device.get_device_identity() offset = memory.handle.value - start diff --git a/python/setup.py b/python/setup.py index 9cac7a52a..b63ba0c90 100644 --- a/python/setup.py +++ b/python/setup.py @@ -111,9 +111,7 @@ def get_cuda_version_from_header(cuda_include_dir): ], nthreads=nthreads, compiler_directives=dict( - profile=False, - language_level=3, - embedsignature=True, + profile=False, language_level=3, embedsignature=True, ), ) @@ -137,9 +135,7 @@ def get_cuda_version_from_header(cuda_include_dir): ], nthreads=nthreads, compiler_directives=dict( - profile=False, - language_level=3, - embedsignature=True, + profile=False, language_level=3, embedsignature=True, ), ) From fbbeb15c6386d3ece6eef4cda8d20f992b3fcf50 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 14 Oct 2020 22:53:25 -0400 Subject: [PATCH 8/8] review feedback: don't require INSTALL_PREFIX to be set If it is not set, fall back to using the uninstalled headers in the source tree. --- python/setup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/setup.py b/python/setup.py index 2b75419d7..c77aaa2e2 100644 --- a/python/setup.py +++ b/python/setup.py @@ -53,11 +53,11 @@ def get_cuda_version_from_header(cuda_include_dir): CUDA_VERSION = get_cuda_version_from_header(cuda_include_dir) INSTALL_PREFIX = os.environ.get("INSTALL_PREFIX", False) -if not os.path.isdir(INSTALL_PREFIX): - raise OSError( - f"Invalid INSTALL_PREFIX: directory does not exist: {INSTALL_PREFIX}" - ) -rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") +if os.path.isdir(INSTALL_PREFIX): + rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") +else: + # use uninstalled headers in source tree + rmm_include_dir = "../include" # Preprocessor step to specify correct pxd file with # valid symbols for specific version of CUDA.