Unverified Commit d951be99 authored by Chip Kerchner's avatar Chip Kerchner Committed by GitHub
Browse files

Don't copy more than has been allocated to device_features. (#3752)

parent e754f23a
...@@ -408,7 +408,7 @@ void CUDATreeLearner::copyDenseFeature() { ...@@ -408,7 +408,7 @@ void CUDATreeLearner::copyDenseFeature() {
// looking for dword_features_ non-sparse feature-groups // looking for dword_features_ non-sparse feature-groups
if (!train_data_->IsMultiGroup(i)) { if (!train_data_->IsMultiGroup(i)) {
dense_feature_group_map_.push_back(i); dense_feature_group_map_.push_back(i);
auto sizes_in_byte = train_data_->FeatureGroupSizesInByte(i); auto sizes_in_byte = std::min(train_data_->FeatureGroupSizesInByte(i), static_cast<size_t>(num_data_));
void* tmp_data = train_data_->FeatureGroupData(i); void* tmp_data = train_data_->FeatureGroupData(i);
Log::Debug("Started copying dense features from CPU to GPU - 2"); Log::Debug("Started copying dense features from CPU to GPU - 2");
CUDASUCCESS_OR_FATAL(cudaMemcpyAsync(&device_features[copied_feature * num_data_], tmp_data, sizes_in_byte, cudaMemcpyHostToDevice, stream_[device_id])); CUDASUCCESS_OR_FATAL(cudaMemcpyAsync(&device_features[copied_feature * num_data_], tmp_data, sizes_in_byte, cudaMemcpyHostToDevice, stream_[device_id]));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment