kvikio icon indicating copy to clipboard operation
kvikio copied to clipboard

No-CUDA build

Open madsbk opened this issue 1 year ago • 5 comments

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

cc. @qkoziol

madsbk avatar Apr 26 '24 07:04 madsbk

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.

qkoziol avatar Apr 26 '24 16:04 qkoziol

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

madsbk avatar Apr 29 '24 06:04 madsbk

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 avatar May 01 '24 23:05 qkoziol

Testing w/legate.io now

qkoziol avatar May 01 '24 23:05 qkoziol

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.

wence- avatar May 08 '24 09:05 wence-

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 avatar May 22 '24 20:05 qkoziol

@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(...);

qkoziol avatar May 22 '24 20:05 qkoziol

@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 avatar May 23 '24 09:05 madsbk

@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?

madsbk avatar May 23 '24 09:05 madsbk

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

KyleFromNVIDIA avatar May 23 '24 13:05 KyleFromNVIDIA

/merge

madsbk avatar May 27 '24 15:05 madsbk