コード例 #1
0
        def _connect():
            try:
                self.connection_props = deepdrive_client.create(
                    '127.0.0.1', 9876)
                if isinstance(self.connection_props, int):
                    raise Exception(
                        'You have an old version of the deepdrive client - try uninstalling and reinstalling with pip'
                    )
                if not self.connection_props or not self.connection_props[
                        'max_capture_resolution']:
                    # Try again
                    return
                self.client_id = self.connection_props['client_id']
                server_version = semvar(
                    self.connection_props['server_protocol_version']).version
                # TODO: For dev, store hash of .cpp and .h files on extension build inside VERSION_DEV, then when
                #   connecting, compute same hash and compare. (Need to figure out what to do on dev packaged version as
                #   files may change - maybe ignore as it's uncommon).
                #   Currently, we timestamp the build, and set that as the version in the extension. This is fine unless
                #   you change shared code and build the extension only, then the versions won't change, and you could
                #   see incompatibilities.

                if semvar(
                        self.client_version).version[:2] != server_version[:2]:
                    raise RuntimeError(
                        'Server and client major/minor version do not match - server is %s and client is %s'
                        % (server_version, self.client_version))

            except deepdrive_client.time_out:
                _connect()
コード例 #2
0
def check_bindings_version():
    # TODO: Bindings name change
    bindings_version = semvar(
        pkg_resources.get_distribution(
            c.BINDINGS_PACKAGE_NAME).version).version[:2]
    client_version = c.MAJOR_MINOR_VERSION
    if bindings_version != client_version:
        print("""ERROR: Python bindings version mismatch. 

Expected {client_version_str}, got {bindings_version_str}

HINT:

For binary sim distributions, try:
pip install package=={client_version_str}.*

For source sim distributions, try:
cd <your-sim-sources>/Plugins/DeepDrivePlugin/Source/DeepDrivePython
python build/build.py --type dev

""".format(
            client_version=client_version,
            bindings_version=bindings_version,
            client_version_str='.'.join(str(vx) for vx in client_version),
            bindings_version_str='.'.join(str(vx) for vx in bindings_version),
        ))
        exit(1)
コード例 #3
0
def check_tensorflow_gpu(is_install=False):
    error_msg = \
        '\n\n*** Warning: %s, Tensorflow agents will not be available. ' \
        '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 ' \
        '\n\n'
    print('Checking for valid Tensorflow installation')
    # noinspection PyUnresolvedReferences
    if not check_nvidia_docker():
        print(error_msg % 'Using Docker but not nvidia-docker runtime',
              file=sys.stderr)
        ret = False
    else:
        if not is_install:
            import h5py  # importing tensorflow later causes seg faults
        try:
            # noinspection PyUnresolvedReferences
            import tensorflow as tf
        except ImportError:
            print(error_msg % 'Tensorflow not installed', file=sys.stderr)
            ret = False
        else:
            min_version = '1.7'
            max_version = '2.0'
            if semvar(tf.__version__) < semvar(min_version):
                warn_msg = 'Tensorflow %s is less than the minimum ' \
                           'required version (%s)' \
                           % (tf.__version__, min_version)
                print(error_msg % warn_msg, file=sys.stderr)
                ret = False
            elif semvar(tf.__version__) >= semvar(max_version):
                warn_msg = 'Tensorflow %s is greater or equal to the maximum ' \
                           'required version (%s)' \
                           % (tf.__version__, min_version)
                print(error_msg % warn_msg, file=sys.stderr)
                ret = False
            else:
                print('Tensorflow %s detected - meets min version'
                      ' (%s)' % (tf.__version__, min_version))
                ret = True

    return ret
コード例 #4
0
ファイル: install.py プロジェクト: OSSDC/deepdrive-1
def get_tf_valid():
    error_msg = '\n\n*** Warning: %s, baseline imitation learning agent will not be available. ' \
                '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 ' \
                '\n\n'

    print('Checking for valid Tensorflow installation')
    try:
        # noinspection PyUnresolvedReferences
        import tensorflow as tf
        check = tf.constant(
            'string tensors are not tensors but are called tensors in tensorflow'
        )
        with tf.Session(config=tf.ConfigProto(
                log_device_placement=False,
                gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.01,
                                          allow_growth=True))) as sess:
            if not get_available_gpus():
                print(
                    '\n\n*** Warning: %s \n\n' %
                    'Tensorflow could not find a GPU, performance will be severely degraded on CPU. '
                    'HINT: Try "pip install tensorflow-gpu"')
                return False
            sess.run(check)
            print('Tensorflow is working on the GPU.')

    except ImportError:
        print(error_msg % 'Tensorflow not installed', file=sys.stderr)
        return False
    except Exception:
        print(error_msg % 'Tensorflow not working', file=sys.stderr)
        return False

    min_version = '1.1'
    if semvar(tf.__version__) < semvar(min_version):
        warn_msg = 'Tensorflow %s is less than the minimum required version (%s)' % (
            tf.__version__, min_version)
        print(error_msg % warn_msg, file=sys.stderr)
        return False
    else:
        print('Tensorflow %s detected - meets min version (%s)' %
              (tf.__version__, min_version))
        return True
コード例 #5
0
ファイル: version.py プロジェクト: zhangfaquan/deepdrive
from distutils.version import LooseVersion as semvar

from config.directories import *

# Version
VERSION_STR = open(os.path.join(ROOT_DIR, 'VERSION')).read()
MAJOR_MINOR_VERSION = semvar(VERSION_STR).version[:2]
MAJOR_MINOR_VERSION_STR = '.'.join(str(vx) for vx in MAJOR_MINOR_VERSION)
コード例 #6
0
def get_version_info():
    version_str = open(os.path.join(DIR, 'VERSION')).read().strip()
    major_minor_version = semvar(version_str).version[:2]
    major_minor_version_str = '.'.join(str(vx) for vx in major_minor_version)
    return version_str, major_minor_version, major_minor_version_str