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

No-CUDA build #373

Merged
merged 11 commits into from
May 27, 2024
Merged

No-CUDA build #373

merged 11 commits into from
May 27, 2024

Conversation

madsbk
Copy link
Member

@madsbk madsbk commented Apr 26, 2024

Support an environment where CUDA isn't available. Only pread() and pwrite() is available in this configuration.

cc. @qkoziol

@madsbk madsbk added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Apr 26, 2024
@qkoziol
Copy link

qkoziol commented Apr 26, 2024

Not working for me yet on my Mac -

`
(legate) qkoziol@qkoziol-mlt kvikio % ./build.sh kvikio
building kvikio...
Processing /Users/qkoziol/dev/Legate/kvikio/python
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: kvikio
Building wheel for kvikio (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for kvikio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
WARNING: Use cmake.version instead of cmake.minimum-version with scikit-build-core >= 0.8
*** scikit-build-core 0.9.2 using CMake 3.29.2 (wheel)
2024-04-26 11:28:53,810 - scikit_build_core - WARNING - No license files found, set wheel.license-files to [] to suppress this warning
*** Configuring CMake...
2024-04-26 11:28:53,899 - scikit_build_core - WARNING - libdir/ldlibrary: /opt/homebrew/Caskroom/miniconda/base/envs/legate/lib/libpython3.11.a is not a real file!
2024-04-26 11:28:53,899 - scikit_build_core - WARNING - Can't find a Python library, got libdir=/opt/homebrew/Caskroom/miniconda/base/envs/legate/lib, ldlibrary=libpython3.11.a, multiarch=darwin, masd=None
CMake Warning:
Ignoring empty string ("") provided on the command line.

  loading initial cache file build/cp311-cp311-macosx_14_0_arm64/CMakeInit.txt
  CMake Error at /opt/homebrew/Caskroom/miniconda/base/envs/legate/share/cmake-3.29/Modules/Internal/CMakeCUDAFindToolkit.cmake:104 (message):
    Failed to find nvcc.
  
    Compiler requires the CUDA toolkit.  Please set the CUDAToolkit_ROOT
    variable.
  Call Stack (most recent call first):
    /opt/homebrew/Caskroom/miniconda/base/envs/legate/share/cmake-3.29/Modules/CMakeDetermineCUDACompiler.cmake:85 (cmake_cuda_find_toolkit)
    CMakeLists.txt:23 (project)
  
  
  -- Configuring incomplete, errors occurred!
  
  *** CMake configuration failed
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for kvikio
Failed to build kvikio
ERROR: Could not build wheels for kvikio, which is required to install pyproject.toml-based projects
`

I think the scikit-build-core may be a red herring (since it's installed in my conda environment), and it's more likely that the missing nvcc is actually the problem.

@madsbk
Copy link
Member Author

madsbk commented Apr 29, 2024

Try ./build.sh libkvikio, this PR only changes the C++ header-only library.

@qkoziol
Copy link

qkoziol commented May 1, 2024

MacOS doesn't have O_DIRECT, so I commented out this line in cpp/include/kvikio/file_handle.hpp:

// if (o_direct) { file_flags |= O_DIRECT; }

After that, ./build.sh libkvikio worked :-)

@qkoziol
Copy link

qkoziol commented May 1, 2024

Testing w/legate.io now

@madsbk madsbk force-pushed the no-cuda-with-wapper branch from 5312e15 to 11eb68b Compare May 6, 2024 08:47
@madsbk madsbk marked this pull request as ready for review May 6, 2024 08:48
@madsbk madsbk requested review from a team as code owners May 6, 2024 08:48
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

cpp/include/kvikio/shim/cuda.hpp Outdated Show resolved Hide resolved
@@ -15,8 +15,7 @@
*/
#pragma once

#include <cuda.h>

#include <kvikio/shim/cuda_h_wrapper.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion/nit: Shall we call this kvikio/shim/cuda_h.hpp ? Or maybe shim/cuda.hpp ?

Copy link
Member Author

@madsbk madsbk May 9, 2024

Choose a reason for hiding this comment

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

We already have kvikio/shim/cuda.hpp and kvikio/shim/cufile.hpp.
Should we rename the wrappers to:

kvikio/shim/cuda_h.hpp
kvikio/shim/cufile_h.hpp

Or maybe

kvikio/shim/cuda_stub.hpp
kvikio/shim/cufile_stub.hpp

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer XXX_stub.hpp over XXX_h.hpp. Though neither of them are fully satisfactory. I guess my only quibble with wrapper is that it suggests something that the header file is not doing: in the case where the real header is available, it just #includes that and no more.

@wence-
Copy link
Contributor

wence- commented May 8, 2024

MacOS doesn't have O_DIRECT, so I commented out this line in cpp/include/kvikio/file_handle.hpp:

// if (o_direct) { file_flags |= O_DIRECT; }

After that, ./build.sh libkvikio worked :-)

@qkoziol, could you please open a separate issue for this so we don't lose track.

@madsbk madsbk requested a review from a team as a code owner May 9, 2024 12:29
Copy link
Contributor

@KyleFromNVIDIA KyleFromNVIDIA left a comment

Choose a reason for hiding this comment

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

I almost remarked on the change to update-version.sh to point out rapidsai/build-planning#15, but then I realized it was an example project, which is one of the few exceptions to the "no-hard-coding-of-RAPIDS-version" rule.

CMake changes approved.

@qkoziol
Copy link

qkoziol commented May 22, 2024

MacOS doesn't have O_DIRECT, so I commented out this line in cpp/include/kvikio/file_handle.hpp:
// if (o_direct) { file_flags |= O_DIRECT; }
After that, ./build.sh libkvikio worked :-)

@qkoziol, could you please open a separate issue for this so we don't lose track.

Yes, will do

@qkoziol
Copy link

qkoziol commented May 22, 2024

@madsbk - One more change was necessary to get the CPU-only build of legate.io working:

diff --git a/cpp/include/kvikio/shim/cufile_h_wrapper.hpp b/cpp/include/kvikio/shim/cufile_h_wrapper.hpp
index 72131de..d73f04b 100644
--- a/cpp/include/kvikio/shim/cufile_h_wrapper.hpp
+++ b/cpp/include/kvikio/shim/cufile_h_wrapper.hpp
@@ -58,8 +58,7 @@ struct CUfileDescr_t {
   } handle;
 };

-const char* cufileop_status_error(...) { return "KvikIO not compiled with cuFile.h"; };
-static inline const char* cufileop_status_error(CUfileOpError err) { return CUFILE_ERRSTR(err); };
+static const char* cufileop_status_error(...) { return "KvikIO not compiled with cuFile.h"; };
 CUfileError_t cuFileHandleRegister(...);
 CUfileError_t cuFileHandleDeregister(...);
 ssize_t cuFileRead(...);

@madsbk
Copy link
Member Author

madsbk commented May 23, 2024

@madsbk - One more change was necessary to get the CPU-only build of legate.io working:

diff --git a/cpp/include/kvikio/shim/cufile_h_wrapper.hpp b/cpp/include/kvikio/shim/cufile_h_wrapper.hpp
index 72131de..d73f04b 100644
--- a/cpp/include/kvikio/shim/cufile_h_wrapper.hpp
+++ b/cpp/include/kvikio/shim/cufile_h_wrapper.hpp
@@ -58,8 +58,7 @@ struct CUfileDescr_t {
   } handle;
 };

-const char* cufileop_status_error(...) { return "KvikIO not compiled with cuFile.h"; };
-static inline const char* cufileop_status_error(CUfileOpError err) { return CUFILE_ERRSTR(err); };
+static const char* cufileop_status_error(...) { return "KvikIO not compiled with cuFile.h"; };
 CUfileError_t cuFileHandleRegister(...);
 CUfileError_t cuFileHandleDeregister(...);
 ssize_t cuFileRead(...);

I am surprised that this is needed, what error did you get?

@madsbk
Copy link
Member Author

madsbk commented May 23, 2024

@KyleFromNVIDIA do we need to add

if(CUDAToolkit_FOUND)
  target_link_libraries(kvikio INTERFACE CUDA::toolkit)
  target_compile_definitions(kvikio INTERFACE KVIKIO_CUDA_FOUND)
else()
  message(WARNING "Building KvikIO without CUDA")
endif()

to the FINAL_CODE_BLOCK as we do in the cufile case?

@KyleFromNVIDIA
Copy link
Contributor

@madsbk That's how I would do it, yes.

cpp/CMakeLists.txt Show resolved Hide resolved
@madsbk
Copy link
Member Author

madsbk commented May 27, 2024

/merge

@rapids-bot rapids-bot bot merged commit 1d87e5f into rapidsai:branch-24.06 May 27, 2024
35 checks passed
@madsbk madsbk deleted the no-cuda-with-wapper branch July 25, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves an existing functionality non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants