diff --git a/CMakeLists.txt b/CMakeLists.txt index 872f6e3..7f06766 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,13 +100,15 @@ if (USE_CUDA AND NOT APPLE) set(USE_CUDA OFF) endif() endif() -if(USE_CUDA) + +if(NOT USE_CUDA) message(STATUS "Compiling for CPU only") +else() + message(STATUS "CUDA found, compiling for CPU and GPU") endif() # Find required packages # Attempt to find pybind11 automatically find_package(pybind11 CONFIG QUIET) - # If pybind11 is not found, use Python to find it if(NOT pybind11_FOUND) message(STATUS "pybind11 not found automatically, attempting to locate with Python") @@ -155,7 +157,6 @@ endif() # Include directories include_directories(${pybind11_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/gbrl/src/cpp) - # Graphviz if (GRAPHVIZ_FOUND) add_definitions(-DUSE_GRAPHVIZ) @@ -198,7 +199,6 @@ set(CPP_SOURCES pybind11_add_module(gbrl_cpp MODULE ${CPP_SOURCES} ${CUDA_SOURCES}) target_compile_definitions(gbrl_cpp PRIVATE MODULE_NAME="gbrl_cpp") - # Platform-specific settings and linking if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_libraries(gbrl_cpp PRIVATE OpenMP::OpenMP_CXX) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 9dd547d..10f3a1c 100755 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -2,7 +2,7 @@ Quickstart ========== Prerequisites ------------ +------------- python3.9 or higher @@ -49,7 +49,17 @@ After installation, set the necessary environment variables: CUDA ~~~~ -Ensure that ``CUDA_HOME`` is set. +GBRL compiles CUDA and requires NVCC. Ensure that ``CUDA_HOME`` is set. Verify that NVCC exists by running the command + +.. code-block:: console + + nvcc --version + +.. note:: + + CUDA installation via anaconda may not install the full CUDAToolkit. + Run ``conda install cuda -c nvidia`` to install the full CUDAToolkit. + For integration with Microsoft Visual Studio, copy the following files: .. code-block:: console diff --git a/gbrl/src/cpp/node.cpp b/gbrl/src/cpp/node.cpp index ea76bc1..5bfdcea 100755 --- a/gbrl/src/cpp/node.cpp +++ b/gbrl/src/cpp/node.cpp @@ -25,12 +25,12 @@ TreeNode::TreeNode(int *sample_indices, const int n_samples, const int n_num_fea sample_indices(sample_indices), n_samples(n_samples), n_num_features(n_num_features), n_cat_features(n_cat_features), output_dim(output_dim), policy_dim(policy_dim), depth(depth), node_idx(node_idx), feature_value(0.0), feature_idx(0){ - if (depth > 0){ - this->split_conditions = new splitCondition[depth]; - for (int d = 0; d < depth; d++){ - this->split_conditions[d].categorical_value = nullptr; - } - } + if (depth > 0){ + this->split_conditions = new splitCondition[depth]; + for (int d = 0; d < depth; d++){ + this->split_conditions[d].categorical_value = nullptr; + } + } } TreeNode::~TreeNode(){ diff --git a/setup.py b/setup.py index d7c6ffc..0819771 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import subprocess import setuptools import platform +import shutil from setuptools import setup, Extension from setuptools.command.build_ext import build_ext from distutils import log @@ -30,6 +31,11 @@ def finalize_options(self): self.cmake_verbose = os.getenv('DEBUG', '0') == '1' def run(self): + for folder_name in ['build', 'dist', 'gbrl.egg-info']: + folder_path = os.path.join(os.path.dirname(__file__), folder_name) + if os.path.exists(folder_path): + log.info(f"Cleaning up existing '{folder_name}' folder...") + shutil.rmtree(folder_path) try: subprocess.check_output(['cmake', '--version']) except OSError: @@ -46,7 +52,7 @@ def build_extension(self, ext): '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, '-DPYTHON_EXECUTABLE=' + sys.executable, '-DPYTHON_INCLUDE_DIR=' + sysconfig.get_path('include'), - '-DCMAKE_BUILD_TYPE=' + cfg + '-DCMAKE_BUILD_TYPE=' + cfg, ] if sysconfig.get_config_var('LIBRARY') is not None: cmake_args.append('-DPYTHON_LIBRARY=' + sysconfig.get_config_var('LIBRARY')) @@ -108,5 +114,4 @@ def move_built_library(self, build_temp): }, packages=['gbrl'], include_package_data=True, - # packages=setuptools.find_packages(where='gbrl'), )