I'd like to limit GPU allocation of tensorflow in the C++ API. I know how to do it in python, and it's probably got something to do with struct SessionOptions passed into NewSession(), but I couldn't find more specific info on how to do it.
Edit: Stackoverflow is suggesting that my question is a duplicate. However I already link to that other post. That is how to do it in python. I'm specifically asking how to do it in C++.
Turns out to be quite simple:
tensorflow::SessionOptions session_options;
session_options.config.mutable_gpu_options()->set_allow_growth(allow_growth);
session_options.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(per_process_gpu_memory_fraction);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With