()
| 69 | |
| 70 | |
| 71 | def get_tf_valid(): |
| 72 | error_msg = '\n\n*** Warning: %s, baseline imitation learning agent will not be available. ' \ |
| 73 | 'HINT: Install Tensorflow or use the python / virtualenv you have it already installed to. If you install, check out our Tensorflow install tips on the README ' \ |
| 74 | '\n\n' |
| 75 | |
| 76 | print('Checking for valid Tensorflow installation') |
| 77 | try: |
| 78 | # noinspection PyUnresolvedReferences |
| 79 | import tensorflow as tf |
| 80 | check = tf.constant('string tensors are not tensors but are called tensors in tensorflow') |
| 81 | with tf.Session(config=tf.ConfigProto(log_device_placement=False, |
| 82 | gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.01, |
| 83 | allow_growth=True))) as sess: |
| 84 | if not get_available_gpus(): |
| 85 | print('\n\n*** Warning: %s \n\n' % |
| 86 | 'Tensorflow could not find a GPU, performance will be severely degraded on CPU. ' |
| 87 | 'HINT: Try "pip install tensorflow-gpu"') |
| 88 | return False |
| 89 | sess.run(check) |
| 90 | print('Tensorflow is working on the GPU.') |
| 91 | |
| 92 | except ImportError: |
| 93 | print(error_msg % 'Tensorflow not installed', file=sys.stderr) |
| 94 | return False |
| 95 | except Exception: |
| 96 | print(error_msg % 'Tensorflow not working', file=sys.stderr) |
| 97 | return False |
| 98 | |
| 99 | min_version = '1.1' |
| 100 | if semvar(tf.__version__) < semvar(min_version): |
| 101 | warn_msg = 'Tensorflow %s is less than the minimum required version (%s)' % (tf.__version__, min_version) |
| 102 | print(error_msg % warn_msg, file=sys.stderr) |
| 103 | return False |
| 104 | else: |
| 105 | print('Tensorflow %s detected - meets min version (%s)' % (tf.__version__, min_version)) |
| 106 | return True |
| 107 | |
| 108 | |
| 109 | def get_available_gpus(): |
no test coverage detected