def Gpu(pull=False):
    """ Check for support of GPUs, and return what's available """
    gpu = (False, '')

    try:
        image = 'nvidia/cuda:8.0-runtime'
        image_name, tag = image.split(':')
        d_client = docker.from_env()
        nvidia_image = d_client.images.list(name=image)

        if pull and len(nvidia_image) == 0:
            try:
                d_client.images.pull(image_name, tag=tag)
                nvidia_image = d_client.images.list(name=image)
            except Exception as e:  # pragma: no cover
                logger.error('Something with the GPU went wrong ' + str(e))

        if len(nvidia_image) > 0:
            cmd = 'nvidia-docker run --rm ' + image + ' nvidia-smi -L'
            proc = Popen([cmd],
                         stdout=PIPE,
                         stderr=PIPE,
                         shell=True,
                         close_fds=True)
            gpus = proc.stdout.read()
            err = proc.stderr.read()
            if gpus:
                gpu_str = ''
                for line in gpus.strip().split('\n'):
                    gpu_str += line.split(' (UUID: ')[0] + ', '
                gpu = (True, gpu_str[:-2])
            else:
                if err:
                    gpu = (False, 'Unknown', str(err))
                else:
                    gpu = (False, 'None')
        else:
            gpu = (False, 'None')
    except Exception as e:  # pragma: no cover
        gpu = (False, 'Unknown', str(e))
    return gpu
Check for support of GPUs, and return what's available