Install Vertex AI client libraries

Google Distributed Cloud (GDC) air-gapped offers three Vertex AI pre-trained services in a disconnected environment. These services include Optical Character Recognition (OCR), Translation, and Speech-to-Text.

Before you begin

Before downloading the tar file and extracting the client libraries, follow these instructions:

  1. If you haven't downloaded the gdcloud CLI, see Download the gdcloud CLI.

  2. Sign in to your environment.

    gdcloud set context && gdcloud auth login YOURCREDENTIAL
    
  3. Create a service account. In this example, the service account is named sa-foo.

    gdcloud iam service-account create sa-foo
    
  4. Bind the service account to the role cloud-ai-viewer, which grants permissions to access the Vertex AI services.

    gdcloud iam service-account role-binding sa-foo --role=cloudai-viewer
    
  5. Generate authentication credentials for the service account.

    gdcloud iam service-account get-cred sa-foo
    
  6. Verify that you have Python version 3.7 installed.

Installation

After completing the prerequisites, follow these steps to download the tar file, and use the tar file to install the client libraries:

  1. Download the client library you want to install. To learn which client libraries are available, see Client libraries.

    wget https://GDC_URL/.well-known/static/client-libraries/CLIENT_LIBRARY
    

    Replace the following:

    • GDC_URL: the URL of your organization in GDC.
    • CLIENT_LIBRARY: the filename of the client library you want to download.
  2. Extract the library file.

    tar -zxf centos-google-cloud-speech-2.15.0.tar.gz
    
  3. Use the pip install command to install the libraries into GDC.

    pip install -r google-cloud-<LIB>/requirements.txt --no-index --find-links google-cloud-<LIB>
    
  4. Create the following Python script to import the Translation client library:

    from google.cloud import translate
    translate_client = translate.Client(
     client_options={"API_ENDPOINT": "https://foo-translation.googleapis.com"})
    result
    = translate_client.translate(text, target_language="ru")
    
  5. Save the Python script as translation-service.py.

  6. Run the Python script.

    python translation-service.py
    

How to run client libraries

There are two ways to run a client library:

Client libraries

CentOS and Ubuntu OS support is provided for Optical Character Recognition (OCR), Translation, and Speech-to-Text client libraries, which GDC hosts.

The file names are in the following format: <OS>-google-cloud-<lib>-<version_number>.tar.gz.

  • centos-google-cloud-speech-2.15.0.tar.gz
  • centos-google-cloud-translate-3.8.0.tar.gz
  • centos-google-cloud-vision-3.0.0.tar.gz
  • ubuntu-google-cloud-speech-2.15.0.tar.gz
  • ubuntu-google-cloud-translate-3.8.0.tar.gz
  • ubuntu-google-cloud-vision-3.0.0.tar.gz