53 const bool allow_growth =
true,
54 const double per_process_gpu_memory_fraction = 0,
55 const std::string& visible_device_list =
"") {
57 tf::SessionOptions options = tf::SessionOptions();
58 tf::ConfigProto* config = &options.config;
59 tf::GPUOptions* gpu_options = config->mutable_gpu_options();
60 gpu_options->set_allow_growth(allow_growth);
61 gpu_options->set_per_process_gpu_memory_fraction(
62 per_process_gpu_memory_fraction);
63 gpu_options->set_visible_device_list(visible_device_list);
79 const bool allow_growth =
true,
80 const double per_process_gpu_memory_fraction = 0,
81 const std::string& visible_device_list =
"") {
85 allow_growth, per_process_gpu_memory_fraction, visible_device_list);
86 tf::Status status = tf::NewSession(options, &session);
88 throw std::runtime_error(
"Failed to create new session: " +
tf::SessionOptions makeSessionOptions(const bool allow_growth=true, const double per_process_gpu_memory_fraction=0, const std::string &visible_device_list="")
Helps to quickly create SessionOptions.
tf::Session * createSession(const bool allow_growth=true, const double per_process_gpu_memory_fraction=0, const std::string &visible_device_list="")
Creates a new TensorFlow session.