[GPU-Plugin] Support for building to specific GPU architectures (#2390)
* Support for builing gpu-plugins to specific GPU architectures 1. Option GPU_COMPUTE_VER exposed from both Makefile and CMakeLists.txt 2. updater_gpu documentation updated accordingly * Re-introduced GPU_COMPUTE_VER option in the cmake flow. This seems to fix the compile-time, rdc=true and copy-constructor related errors seen and discussed in PR #2390.
This commit is contained in:
parent
65d2513714
commit
34dfe2f6de
@ -3,6 +3,8 @@ project (xgboost)
|
||||
find_package(OpenMP)
|
||||
|
||||
option(PLUGIN_UPDATER_GPU "Build GPU accelerated tree construction plugin")
|
||||
set(GPU_COMPUTE_VER 50;52;60;61 CACHE STRING
|
||||
"Space separated list of compute versions to be built against")
|
||||
if(PLUGIN_UPDATER_GPU)
|
||||
find_package(CUDA REQUIRED)
|
||||
endif()
|
||||
@ -107,35 +109,29 @@ if(PLUGIN_UPDATER_GPU)
|
||||
set(NCCL_DIRECTORY ${PROJECT_SOURCE_DIR}/nccl)
|
||||
include_directories(${NCCL_DIRECTORY}/src)
|
||||
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${CUDA_LIBRARIES})
|
||||
|
||||
#Find cub
|
||||
set(CUB_DIRECTORY ${PROJECT_SOURCE_DIR}/cub/)
|
||||
include_directories(${CUB_DIRECTORY})
|
||||
|
||||
#Find cub
|
||||
set(CUB_DIRECTORY ${PROJECT_SOURCE_DIR}/cub/)
|
||||
include_directories(${CUB_DIRECTORY})
|
||||
#Find googletest
|
||||
set(GTEST_DIRECTORY "${CACHE_PREFIX}" CACHE PATH "Googletest directory")
|
||||
include_directories(${GTEST_DIRECTORY}/include)
|
||||
|
||||
# plugin
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-lineinfo;--expt-extended-lambda")
|
||||
#gencode flags
|
||||
set(GENCODE_FLAGS "")
|
||||
foreach(ver ${GPU_COMPUTE_VER})
|
||||
set(GENCODE_FLAGS "${GENCODE_FLAGS}-gencode arch=compute_${ver},code=sm_${ver};")
|
||||
endforeach()
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--expt-extended-lambda;${GENCODE_FLAGS};-lineinfo;")
|
||||
if(NOT MSVC)
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xcompiler -fPIC")
|
||||
endif()
|
||||
set(CUDA_SOURCES
|
||||
plugin/updater_gpu/src/updater_gpu.cu
|
||||
plugin/updater_gpu/src/gpu_hist_builder.cu
|
||||
)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/Utils.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/Cuda.cmake)
|
||||
# use below for forcing specific arch
|
||||
#cuda_compile(CUDA_OBJS ${CUDA_SOURCES} ${CUDA_NVCC_FLAGS} -arch=compute_52)
|
||||
# use below for auto-detect, but gpu_grow currently doesn't work with 61
|
||||
xgboost_cuda_compile(CUDA_OBJS ${CUDA_SOURCES} ${CUDA_NVCC_FLAGS})
|
||||
if(MSVC)
|
||||
else()
|
||||
cuda_add_library(updater_gpu STATIC ${CUDA_SOURCES})
|
||||
set(LINK_LIBRARIES ${LINK_LIBRARIES} updater_gpu)
|
||||
endif()
|
||||
cuda_compile(CUDA_OBJS ${CUDA_SOURCES} ${CUDA_NVCC_FLAGS})
|
||||
else()
|
||||
set(CUDA_OBJS "")
|
||||
set(updater_gpu "")
|
||||
endif()
|
||||
|
||||
add_library(objxgboost OBJECT ${SOURCES})
|
||||
|
||||
4
Makefile
4
Makefile
@ -93,12 +93,12 @@ endif
|
||||
CFLAGS += $(OPENMP_FLAGS)
|
||||
|
||||
# for using GPUs
|
||||
COMPUTE ?= 60 35
|
||||
GPU_COMPUTE_VER ?= 50 52 60 61
|
||||
NVCC = nvcc
|
||||
INCLUDES = -Iinclude -I$(DMLC_CORE)/include -I$(RABIT)/include
|
||||
INCLUDES += -I$(CUB_PATH)
|
||||
INCLUDES += -I$(GTEST_PATH)/include
|
||||
CODE = $(foreach ver,$(COMPUTE),-gencode arch=compute_$(ver),code=sm_$(ver))
|
||||
CODE = $(foreach ver,$(GPU_COMPUTE_VER),-gencode arch=compute_$(ver),code=sm_$(ver))
|
||||
NVCC_FLAGS = --std=c++11 $(CODE) $(INCLUDES) -lineinfo --expt-extended-lambda
|
||||
NVCC_FLAGS += -Xcompiler=$(OPENMP_FLAGS) -Xcompiler=-fPIC
|
||||
ifeq ($(PLUGIN_UPDATER_GPU),ON)
|
||||
|
||||
@ -90,12 +90,27 @@ Visual studio community 2015, supported by cuda toolkit (http://docs.nvidia.com/
|
||||
|
||||
### For Developers!
|
||||
|
||||
In case you want to build only for a specific GPU(s), for eg. GP100 and GP102,
|
||||
whose compute capability are 60 and 61 respectively:
|
||||
```bash
|
||||
$ cmake .. -DPLUGIN_UPDATER_GPU=ON -DGPU_COMPUTE_VER="60;61"
|
||||
```
|
||||
By default, the versions will include support for all GPUs in Maxwell and Pascal architectures.
|
||||
|
||||
### Using make
|
||||
Now, it also supports the usual 'make' flow to build gpu-enabled tree construction plugins. It's currently only tested on Linux. From the xgboost directory
|
||||
```bash
|
||||
# make sure CUDA SDK bin directory is in the 'PATH' env variable
|
||||
$ make PLUGIN_UPDATER_GPU=ON
|
||||
```
|
||||
|
||||
Similar to cmake, if you want to build only for a specific GPU(s):
|
||||
```bash
|
||||
$ make PLUGIN_UPDATER_GPU=ON GPU_COMPUTE_VER="60 61"
|
||||
```
|
||||
|
||||
### For Developers!
|
||||
|
||||
Now, some of the code-base inside gpu plugins have googletest unit-tests inside 'tests/'.
|
||||
They can be enabled run along with other unit-tests inside '<xgboostRoot>/tests/cpp' using:
|
||||
```bash
|
||||
@ -131,19 +146,11 @@ $ make PLUGIN_UPDATER_GPU=ON GTEST_PATH=${CACHE_PREFIX} test
|
||||
[Mitchell, Rory, and Eibe Frank. Accelerating the XGBoost algorithm using GPU computing. No. e2911v1. PeerJ Preprints, 2017.](https://peerj.com/preprints/2911/)
|
||||
|
||||
## Author
|
||||
<<<<<<< HEAD
|
||||
Rory Mitchell,
|
||||
Jonathan C. McKinney,
|
||||
Shankara Rao Thejaswi Nanditale,
|
||||
Vinay Deshpande,
|
||||
and the rest of the H2O.ai and NVIDIA team.
|
||||
=======
|
||||
Rory Mitchell
|
||||
Jonathan C. McKinney
|
||||
Shankara Rao Thejaswi Nanditale
|
||||
Vinay Deshpande
|
||||
... and the rest of the H2O.ai and NVIDIA team.
|
||||
>>>>>>> d2fbbdf4a39fa1f0af5cbd59a7912cf5caade34e
|
||||
|
||||
Please report bugs to the xgboost/issues page.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user