def __init__(self):
        self._docker_host = os.environ.get('DOCKER_HOST') or None
        if self._docker_host:
            self._docker_host = self._docker_host.replace('tcp://', '')

        cert_path = os.environ.get('DOCKER_CERT_PATH') or None
        if cert_path:
            self._ssl_context = ssl.create_default_context(
                cafile=os.path.join(cert_path, 'ca.pem'))
            self._ssl_context.load_cert_chain(
                os.path.join(cert_path, 'cert.pem'),
                os.path.join(cert_path, 'key.pem'))
            self._ssl_context.check_hostname = False

        # Test to make sure that a connection can be established.
        try:
            self.test()
        except DockerException:
            print >> sys.stderr, """
On Linux, a valid Docker installation should create a Unix socket at
/var/run/docker.sock.

On Mac, DOCKER_HOST and optionally DOCKER_CERT_PATH should be defined. You need
to run the worker from the Docker shell.
"""
            raise
        
        # Find libcuda. We pick up the 64-bit version only and put it in a
        # semi-standard directory. It works for the Tensorflow Docker image.
        self._libcuda_files = []
        try:
            for lib in subprocess.check_output(['/sbin/ldconfig', '-p']).split('\n'):
                if 'libcuda.' not in lib or 'x86-64' not in lib:
                    continue
                self._libcuda_files.append(lib.split(' => ')[-1])
        except __HOLE__:
            # ldconfig isn't available on Mac OS X. Let's just say that we
            # don't support libcuda on Mac.
            print >> sys.stderr, """
No ldconfig found. Not loading libcuda libraries.
"""

        # Find all the NVIDIA device files.
        self._nvidia_device_files = []
        for filename in os.listdir('/dev'):
            if filename.startswith('nvidia'):
                self._nvidia_device_files.append(os.path.join('/dev', filename))
dataset/ETHPy150Open codalab/codalab-cli/worker/docker_client.py/DockerClient.__init__