Skip to content

Commit

Permalink
[XLA:Python] Allow growth in BFCAllocator.
Browse files Browse the repository at this point in the history
With this change, the BFCAllocator no longer allocates 90% of
available GPU memory by default. Instead it grows the total allocation
dynamically.

PiperOrigin-RevId: 250927329
  • Loading branch information
skye authored and tensorflower-gardener committed May 31, 2019
1 parent adab543 commit 805b7cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions tensorflow/compiler/xla/python/local_client.cc
Expand Up @@ -208,12 +208,11 @@ static StatusOr<std::unique_ptr<se::MultiDeviceAdapter>> CreateBFCAllocator(
device_ordinal);
}
size_t allocator_memory = free_memory * memory_fraction;
LOG(INFO) << "XLA backend reserving " << allocator_memory << " out of "
<< total_memory << " bytes on device " << device_ordinal
<< " for BFCAllocator.";
LOG(INFO) << "XLA backend will use up to " << allocator_memory
<< " bytes on device " << device_ordinal << " for BFCAllocator.";

auto gpu_bfc_allocator = absl::make_unique<tensorflow::BFCAllocator>(
sub_allocator.release(), allocator_memory, /*allow_growth=*/false,
sub_allocator.release(), allocator_memory, /*allow_growth=*/true,
absl::StrCat("GPU_", device_ordinal, "_bfc"));
allocators.emplace_back(std::move(gpu_bfc_allocator));
}
Expand Down
5 changes: 3 additions & 2 deletions tensorflow/compiler/xla/python/local_client.h
Expand Up @@ -197,8 +197,9 @@ struct AllocatorConfig {
};
Kind kind = Kind::kDefault;

// Only used if kind == kBFC. Fraction of available memory to allocate.
double memory_fraction = .9;
// Only used if kind == kBFC. The maximum fraction of available memory to
// allocate.
double memory_fraction = 1.0;
};

// Encapsulates the state of Python session with XLA.
Expand Down

0 comments on commit 805b7cc

Please sign in to comment.