Skip to content

Commit 10c0f52

Browse files
authored
Merge pull request #31 from intel/lmelo-changes04
Fastchat Example Refactor, Add Stable Diffusion Example
2 parents 069af62 + 09648ec commit 10c0f52

File tree

5 files changed

+122
-12
lines changed

5 files changed

+122
-12
lines changed

examples/gcp-linux-fastchat-simple/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ terraform apply
3333
2. SSH into newly created GCP VM
3434
3. **Run `source /usr/local/bin/run_demo.sh`**
3535
4. On your local computer, open a browser and navigate to **http://<VM_PLUBLIC_IP>:7860**. Get your Public IP from the "Compute Engine" section of the VM in the GCP console.
36-
5. Or use the https://xxxxxxx.gradio.live URL that is generated during the demo startup(see on screen logs)
37-
38-
<p align="center">
39-
<img src="https://github.com/intel/terraform-intel-gcp-vm/blob/main/images/gradio.png?raw=true" alt="Gradio_Output" width="900"/>
40-
</p>
4136

4237
Note: You may need permissions to run Terraform https://cloud.google.com/docs/terraform/get-started-with-terraform
4338

examples/gcp-linux-fastchat-simple/main.tf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
resource "random_id" "rid" {
2+
byte_length = 3
3+
}
4+
15
variable "project" {
26
type = string
37
description = "GCP Project ID"
@@ -10,10 +14,11 @@ module "linux_vm" {
1014
project = var.project
1115
boot_image_project = "ubuntu-os-cloud"
1216
boot_image_family = "ubuntu-2204-lts"
13-
name = "intel-fastchat"
17+
name = "intel-fastchat-${random_id.rid.dec}"
1418
zone = "us-central1-a"
15-
machine_type = "c3-standard-44"
16-
tags = ["fschat"]
19+
machine_type = "c3-standard-22"
20+
allow_stopping_for_update = true
21+
tags = ["fschat-${random_id.rid.dec}"]
1722
user_data = templatefile("./cloud_init.yml", {})
1823
access_config = [{
1924
nat_ip = null
@@ -24,14 +29,14 @@ module "linux_vm" {
2429

2530
resource "google_compute_firewall" "rules" {
2631
project = var.project
27-
name = "fastchat-firewall"
32+
name = "fastchat-firewall-${random_id.rid.dec}"
2833
network = "default"
2934
description = "Allows access to FastChat Webserver."
30-
35+
3136
allow {
3237
protocol = "tcp"
33-
ports = ["7860"]
38+
ports = ["22", "5000", "5001", "7860"]
3439
}
3540
source_ranges = [ "0.0.0.0/0" ]
36-
target_tags = ["fschat"]
41+
target_tags = ["fschat-${random_id.rid.dec}"]
3742
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<p align="center">
2+
<img src="https://github.com/intel/terraform-intel-gcp-vm/blob/main/images/logo-classicblue-800px.png?raw=true" alt="Intel Logo" width="250"/>
3+
</p>
4+
5+
# Intel Cloud Optimization Modules for Terraform
6+
7+
© Copyright 2023, Intel Corporation
8+
9+
## GCP C3 4th Gen Xeon(code named Sapphire Rapids) & Intel® Optimized Cloud Recipe for Stable Diffusion
10+
11+
This demo will showcase Stable Diffusion CPU inferencing using 4th Gen Xeon Scalable Processors on GCP.
12+
13+
## Usage
14+
15+
1. Log on to GCP Portal
16+
2. Enter the GCP Cloud Shell (terminal button on top right of page)
17+
3. Run the following commands in order:
18+
19+
20+
```bash
21+
git clone https://github.com/intel/terraform-intel-gcp-vm.git
22+
cd terraform-intel-gcp-vm/examples/gcp-linux-stable-diffusion
23+
terraform init
24+
terraform apply
25+
26+
# (enter your GCP project ID and "yes" to confirm)
27+
28+
```
29+
30+
## Run the Stable Diffusion Intel® OpenVino Optimized Demo
31+
32+
**NOTE - Wait ~5 minutes for the software to install**
33+
34+
**1-SSH into newly created GCP VM and run `source /usr/local/bin/run_demo.sh`**
35+
36+
**2-On your computer open a browser and navigate to http://<VM_PLUBLIC_IP>:5000**
37+
38+
## OPTIONAL - Run the default stock Stable Diffusion demo (not optimized)
39+
40+
**1-SSH into VM and run `source /usr/local/bin/not_optimized_run_demo.sh`**
41+
42+
**2-Browse to port 5001 instead http://<VM_PLUBLIC_IP>:5001**
43+
44+
45+
Note: You may need permissions to run Terraform https://cloud.google.com/docs/terraform/get-started-with-terraform
46+
47+
### Pre-requisites for running on a Workstation (bypass if using GCP Cloud Shell)
48+
49+
1. Google Cloud CLI: https://cloud.google.com/sdk/docs/install
50+
2. CGP account access configured: https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference.html#running-terraform-on-your-workstation
51+
3. Terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli
52+
4. Git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#cloud-config
2+
package_update: true
3+
package_upgrade: true
4+
5+
package:
6+
- git
7+
8+
ansible:
9+
install_method: distro
10+
package_name: ansible
11+
pull:
12+
url: "https://github.com/intel/optimized-cloud-recipes.git"
13+
playbook_name: "recipes/ai-stable_diffusion-amx-ubuntu/recipe.yml"
14+
15+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
resource "random_id" "rid" {
2+
byte_length = 3
3+
}
4+
5+
variable "project" {
6+
type = string
7+
description = "GCP Project ID"
8+
}
9+
10+
11+
#GCP Linux VM with Intel Cloud Optimized Recipe for FastChat
12+
module "linux_vm" {
13+
source = "intel/gcp-vm/intel"
14+
project = var.project
15+
boot_image_project = "ubuntu-os-cloud"
16+
boot_image_family = "ubuntu-2204-lts"
17+
name = "intel-diffusion-${random_id.rid.dec}"
18+
zone = "us-central1-a"
19+
machine_type = "c3-standard-44"
20+
#machine_type = "n2-standard-32"
21+
allow_stopping_for_update = true
22+
tags = ["diffusion-${random_id.rid.dec}"]
23+
user_data = templatefile("./cloud_init.yml", {})
24+
access_config = [{
25+
nat_ip = null
26+
public_ptr_domain_name = null
27+
network_tier = "PREMIUM"
28+
}, ]
29+
}
30+
31+
resource "google_compute_firewall" "rules" {
32+
project = var.project
33+
name = "diffusion-firewall-${random_id.rid.dec}"
34+
network = "default"
35+
description = "Allows access to Stable Diffusion"
36+
37+
allow {
38+
protocol = "tcp"
39+
ports = ["22", "5000", "5001", "7860"]
40+
}
41+
source_ranges = [ "0.0.0.0/0" ]
42+
target_tags = ["diffusion-${random_id.rid.dec}"]
43+
}

0 commit comments

Comments
 (0)