Sunday, February 23, 2025

GCP#1

Module 1: Logging into Google Cloud Console

Step 1: Sign in to Google Cloud

  1. Open Google Cloud Console.
  2. Sign in with your Google account.
  3. If this is your first time, you might need to create a new project.

Step 2: Create a Google Cloud Project

  1. Click on the project dropdown (top navigation bar).
  2. Select New Project.
  3. Give it a name (e.g., MyAIProject).
  4. Choose a billing account (if applicable) and location.
  5. Click Create.

Step 3: Enable Required APIs

  1. Go to APIs & Services > Library.
  2. Search for and enable:
    • Compute Engine API (for virtual machines)
    • AI & Machine Learning APIs (like Vertex AI)
    • Cloud Storage API (for storing data)
  3. Go to IAM & Admin and ensure you have the necessary permissions.

Module 2: Running an AI Project Using Ollama

Step 1: Set Up a Google Cloud VM

  1. Navigate to Compute Engine > VM Instances.
  2. Click Create Instance.
  3. Choose a machine type:
    • n1-standard-2 (for small workloads)
    • n1-highmem-4 (for AI models)
  4. Select Ubuntu 22.04 as the OS.
  5. Allow HTTP and HTTPS traffic.
  6. Click Create.

Step 2: Install Ollama on the VM

  1. Connect to your VM via SSH:
    gcloud compute ssh my-instance-name --zone=us-central1-a
    
  2. Install Ollama:
    curl -fsSL https://ollama.ai/install.sh | sh
    
  3. Start Ollama:
    ollama serve &
    
  4. Download an AI model:
    ollama pull deepseek-r1:1.5b
    

Step 3: Run AI Inference

  1. Install dependencies:
    pip install langchain langchain-ollama
    
  2. Create a Python script (app.py):
    from langchain_core.prompts import ChatPromptTemplate
    from langchain_ollama.llms import OllamaLLM
    
    template = """Question: {question}
    Answer: Let's think step by step."""
    prompt = ChatPromptTemplate.from_template(template)
    model = OllamaLLM(model="deepseek-r1:1.5b")
    chain = prompt | model
    response = chain.invoke({"question": "What is Mixture of Experts?"})
    print(response)
    
  3. Run the script:
    python app.py
    

Module 3: Creating an Angular Project

Step 1: Install Node.js and Angular CLI

  1. Install Node.js (LTS version) from Node.js.
  2. Install Angular CLI:
    npm install -g @angular/cli
    

Step 2: Create a New Angular Project

  1. Create the project:
    ng new my-angular-app --style=scss
    
  2. Navigate to the project folder:
    cd my-angular-app
    

Step 3: Add Angular Material

  1. Install Angular Material:
    ng add @angular/material
    
  2. Choose a theme (e.g., Indigo Pink).
  3. Enable typography and animations.

Step 4: Create a Sample Component

  1. Generate a component:
    ng generate component dashboard
    
  2. Modify dashboard.component.html:
    <mat-toolbar color="primary">Welcome to My AI Dashboard</mat-toolbar>
    <button mat-raised-button color="accent">Click Me</button>
    

Step 5: Run the Angular App

ng serve --open

🚀

No comments:

Post a Comment

#1 K8S Intro -Lab

GCP Kubernetes Hands-on Lab Objective By the end of this lab, students will be able to: Log in to Google Cloud Platform (GCP) Create a Kub...