From 9437b62d7593623f08769d13a55b03eaa9d8472f Mon Sep 17 00:00:00 2001 From: Nick Sarkauskas Date: Mon, 26 Feb 2024 11:47:40 -0800 Subject: [PATCH 1/2] Find libcuda.so automatically if --with-cuda-lib is not passed. Finding CUDA libraries without having to specify both --with-cuda and --with-cuda-lib was requested in github issue https://github.com/open-mpi/ompi/issues/12264 Signed-off-by: Nick Sarkauskas (cherry picked from commit cad3d9a9ebc4c23981a82c2ca918a6c6ca29d274) --- config/opal_check_cuda.m4 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/opal_check_cuda.m4 b/config/opal_check_cuda.m4 index 27afe55e38c..9ddb97ccf79 100644 --- a/config/opal_check_cuda.m4 +++ b/config/opal_check_cuda.m4 @@ -50,9 +50,18 @@ AC_ARG_WITH([cuda], [AS_HELP_STRING([--with-cuda(=DIR)], [Build cuda support, optionally adding DIR/include])]) AC_MSG_CHECKING([if --with-cuda is set]) + +# Search for libcuda.so in $with_cuda if the user didn't pass --with-cuda-libdir +# Otherwise check for cuda in the default path, /usr/local/cuda. If the default +# path doesn't exist, set with_cuda_libdir to empty. AC_ARG_WITH([cuda-libdir], [AS_HELP_STRING([--with-cuda-libdir=DIR], - [Search for CUDA libraries in DIR])]) + [Search for CUDA libraries in DIR])], + [], + [AS_IF([test -d "$with_cuda"], + [with_cuda_libdir=$(dirname $(find $with_cuda -name libcuda.so) 2> /dev/null)], + [with_cuda_libdir=$(dirname $(find /usr/local/cuda -name libcuda.so) 2> /dev/null)]) + ]) # Note that CUDA support is off by default. To turn it on, the user has to # request it. The user can just ask for --with-cuda and it that case we From e69aae0966b5f692b3159e6bab64e553f70ba9b3 Mon Sep 17 00:00:00 2001 From: Nick Sarkauskas Date: Thu, 29 Feb 2024 14:06:16 -0800 Subject: [PATCH 2/2] Update docs to reflect change that configure script will automatically find libcuda.so Also, redirect the find output to /dev/null to avoid unnecessary output Signed-off-by: Nick Sarkauskas (cherry picked from commit d57ab5b11ece0251c97c22dc821221bba7fbf01c) --- config/opal_check_cuda.m4 | 4 ++-- docs/tuning-apps/networking/cuda.rst | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config/opal_check_cuda.m4 b/config/opal_check_cuda.m4 index 9ddb97ccf79..87f5dc01ef1 100644 --- a/config/opal_check_cuda.m4 +++ b/config/opal_check_cuda.m4 @@ -59,8 +59,8 @@ AC_ARG_WITH([cuda-libdir], [Search for CUDA libraries in DIR])], [], [AS_IF([test -d "$with_cuda"], - [with_cuda_libdir=$(dirname $(find $with_cuda -name libcuda.so) 2> /dev/null)], - [with_cuda_libdir=$(dirname $(find /usr/local/cuda -name libcuda.so) 2> /dev/null)]) + [with_cuda_libdir=$(dirname $(find $with_cuda -name libcuda.so 2> /dev/null) 2> /dev/null)], + [with_cuda_libdir=$(dirname $(find /usr/local/cuda -name libcuda.so 2> /dev/null) 2> /dev/null)]) ]) # Note that CUDA support is off by default. To turn it on, the user has to diff --git a/docs/tuning-apps/networking/cuda.rst b/docs/tuning-apps/networking/cuda.rst index c6f44955e51..188cf841881 100644 --- a/docs/tuning-apps/networking/cuda.rst +++ b/docs/tuning-apps/networking/cuda.rst @@ -41,14 +41,16 @@ Open MPI offers two flavors of CUDA support: shell$ ./configure --prefix=/path/to/ucx-cuda-install --with-cuda=/usr/local/cuda --with-gdrcopy=/usr # Configure Open MPI this way - shell$ ./configure --with-cuda=/usr/local/cuda --with-cuda-libdir=/usr/local/cuda/lib64/stubs/ --with-ucx=/path/to/ucx-cuda-install + shell$ ./configure --with-cuda=/usr/local/cuda --with-ucx=/path/to/ucx-cuda-install #. Via internal Open MPI CUDA support Regardless of which flavor of CUDA support (or both) you plan to use, Open MPI should be configured using the ``--with-cuda=`` -and ``--with-cuda-libdir=`` configure options to -build CUDA support into Open MPI. +configure option to build CUDA support into Open MPI. The configure +script will automatically search the path given for ``libcuda.so``. If it cannot +be found, please also pass ``--with-cuda-libdir``. For example: +``--with-cuda= --with-cuda-libdir=/usr/local/cuda/lib64/stubs``. Open MPI supports building with CUDA libraries and running on systems without CUDA libraries or hardware. In order to take advantage of @@ -65,7 +67,7 @@ An example configure command would look like the following: .. code-block:: sh # Configure Open MPI this way - shell$ ./configure --with-cuda=/usr/local/cuda --with-cuda-libdir=/usr/local/cuda/lib64/stubs \ + shell$ ./configure --with-cuda=/usr/local/cuda \ --enable-mca-dso=btl-smcuda,rcache-rgpusm,rcache-gpusm,accelerator-cuda /////////////////////////////////////////////////////////////////////////