diff --git a/include/LightGBM/cuda/vector_cudahost.h b/include/LightGBM/cuda/vector_cudahost.h index 03db3386d4c7..bd488d793d09 100644 --- a/include/LightGBM/cuda/vector_cudahost.h +++ b/include/LightGBM/cuda/vector_cudahost.h @@ -42,6 +42,7 @@ struct CHAllocator { T* allocate(std::size_t n) { T* ptr; if (n == 0) return NULL; + n = (n + kAlignedSize - 1) & -kAlignedSize; #ifdef USE_CUDA if (LGBM_config_::current_device == lgbm_device_cuda) { cudaError_t ret = cudaHostAlloc(&ptr, n*sizeof(T), cudaHostAllocPortable);