Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added '--allow-growth' flag #9779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added '--allow-growth' flag
added '--allow-growth' flag to choose to limit GPU growth. This solves `failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED` issue if caused due to GPU memory limit.  #3502
  • Loading branch information
uniquetrij authored Mar 5, 2021
commit fad33a4ec17b3796987b7d7ad5b7f1a9956fecd4
14 changes: 14 additions & 0 deletions research/object_detection/model_main_tf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,27 @@
('Whether or not to record summaries during'
' training.'))

flags.DEFINE_boolean('allow_growth', False,
('Whether or not to limit gpu memory growth.'))

FLAGS = flags.FLAGS


def main(unused_argv):
flags.mark_flag_as_required('model_dir')
flags.mark_flag_as_required('pipeline_config_path')
tf.config.set_soft_device_placement(True)

if FLAGS.allow_growth:
gpus = tf.config.list_physical_devices('GPU')
if gpus:
try:
# Currently, memory growth needs to be the same across GPUs
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
except RuntimeError as e:
# Memory growth must be set before GPUs have been initialized
pass

if FLAGS.checkpoint_dir:
model_lib_v2.eval_continuously(
Expand Down