Abdalkaderdev commited on
Commit
f917448
ยท
1 Parent(s): 1e76709

Add Google Cloud deployment scripts

Browse files
Files changed (2) hide show
  1. deploy_to_gcp.ps1 +69 -0
  2. setup_vm.sh +61 -0
deploy_to_gcp.ps1 ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ORA Google Cloud Deployment Script
2
+ # Run this in PowerShell as Administrator
3
+
4
+ Write-Host "๐Ÿš€ ORA Google Cloud Deployment" -ForegroundColor Cyan
5
+ Write-Host "================================" -ForegroundColor Cyan
6
+
7
+ # Step 1: Check if gcloud is installed
8
+ Write-Host "`n๐Ÿ“ฆ Checking Google Cloud SDK..." -ForegroundColor Yellow
9
+ if (!(Get-Command gcloud -ErrorAction SilentlyContinue)) {
10
+ Write-Host "โŒ Google Cloud SDK not found!" -ForegroundColor Red
11
+ Write-Host "Please install it from: https://cloud.google.com/sdk/docs/install" -ForegroundColor Yellow
12
+ Write-Host "After installation, run this script again." -ForegroundColor Yellow
13
+ exit
14
+ }
15
+
16
+ Write-Host "โœ… Google Cloud SDK found!" -ForegroundColor Green
17
+
18
+ # Step 2: Login to Google Cloud
19
+ Write-Host "`n๐Ÿ” Logging in to Google Cloud..." -ForegroundColor Yellow
20
+ gcloud auth login
21
+
22
+ # Step 3: Set project
23
+ Write-Host "`n๐Ÿ“‹ Enter your Google Cloud Project ID:" -ForegroundColor Yellow
24
+ $PROJECT_ID = Read-Host "Project ID"
25
+ gcloud config set project $PROJECT_ID
26
+
27
+ # Step 4: Enable required APIs
28
+ Write-Host "`nโš™๏ธ Enabling required APIs..." -ForegroundColor Yellow
29
+ gcloud services enable compute.googleapis.com
30
+ gcloud services enable containerregistry.googleapis.com
31
+
32
+ # Step 5: Create VM with GPU
33
+ Write-Host "`n๐Ÿ–ฅ๏ธ Creating VM with T4 GPU..." -ForegroundColor Yellow
34
+ Write-Host "This will use your $2000 credit (~$0.35/hour)" -ForegroundColor Cyan
35
+
36
+ $VM_NAME = "ora-gpu-vm"
37
+ $ZONE = "us-central1-a"
38
+
39
+ gcloud compute instances create $VM_NAME `
40
+ --zone=$ZONE `
41
+ --machine-type=n1-standard-4 `
42
+ --accelerator=type=nvidia-tesla-t4,count=1 `
43
+ --image-family=pytorch-latest-gpu `
44
+ --image-project=deeplearning-platform-release `
45
+ --boot-disk-size=100GB `
46
+ --metadata="install-nvidia-driver=True" `
47
+ --tags=ora-vm
48
+
49
+ # Step 6: Create firewall rule
50
+ Write-Host "`n๐Ÿ”ฅ Creating firewall rule..." -ForegroundColor Yellow
51
+ gcloud compute firewall-rules create allow-ora `
52
+ --allow tcp:80,tcp:7860 `
53
+ --source-ranges 0.0.0.0/0 `
54
+ --target-tags=ora-vm
55
+
56
+ # Step 7: Get VM IP
57
+ Write-Host "`n๐Ÿ“ Getting VM IP address..." -ForegroundColor Yellow
58
+ $VM_IP = gcloud compute instances describe $VM_NAME --zone=$ZONE --format="get(networkInterfaces[0].accessConfigs[0].natIP)"
59
+
60
+ Write-Host "`nโœ… VM Created Successfully!" -ForegroundColor Green
61
+ Write-Host "================================" -ForegroundColor Cyan
62
+ Write-Host "VM Name: $VM_NAME" -ForegroundColor White
63
+ Write-Host "Zone: $ZONE" -ForegroundColor White
64
+ Write-Host "IP Address: $VM_IP" -ForegroundColor White
65
+ Write-Host "`n๐Ÿ“ Next Steps:" -ForegroundColor Yellow
66
+ Write-Host "1. SSH into VM: gcloud compute ssh $VM_NAME --zone=$ZONE" -ForegroundColor White
67
+ Write-Host "2. Run the setup script on the VM (see setup_vm.sh)" -ForegroundColor White
68
+ Write-Host "3. Access ORA at: http://$VM_IP" -ForegroundColor White
69
+ Write-Host "`n๐Ÿ’ฐ Cost: ~$0.35/hour with T4 GPU (using your credits)" -ForegroundColor Cyan
setup_vm.sh ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Run this script on the GCP VM after SSH-ing in
3
+
4
+ echo "๐Ÿš€ Setting up ORA on GCP VM with GPU"
5
+ echo "======================================"
6
+
7
+ # Update system
8
+ echo "๐Ÿ“ฆ Updating system..."
9
+ sudo apt-get update
10
+
11
+ # Install Docker
12
+ echo "๐Ÿณ Installing Docker..."
13
+ curl -fsSL https://get.docker.com -o get-docker.sh
14
+ sudo sh get-docker.sh
15
+ sudo usermod -aG docker $USER
16
+
17
+ # Install NVIDIA Container Toolkit
18
+ echo "๐ŸŽฎ Installing NVIDIA Container Toolkit..."
19
+ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
20
+ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
21
+ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
22
+ sudo apt-get update
23
+ sudo apt-get install -y nvidia-container-toolkit
24
+ sudo systemctl restart docker
25
+
26
+ # Install Git LFS
27
+ echo "๐Ÿ“ฅ Installing Git LFS..."
28
+ sudo apt-get install -y git-lfs
29
+ git lfs install
30
+
31
+ # Clone ORA repository
32
+ echo "๐Ÿ“‚ Cloning ORA repository..."
33
+ cd ~
34
+ git clone https://huggingface.co/spaces/Abdalkaderdev/ORA
35
+ cd ORA
36
+
37
+ # Build Docker image
38
+ echo "๐Ÿ—๏ธ Building Docker image..."
39
+ sudo docker build -t ora-app .
40
+
41
+ # Run ORA with GPU
42
+ echo "๐Ÿš€ Starting ORA with GPU..."
43
+ sudo docker run -d \
44
+ --gpus all \
45
+ -p 80:7860 \
46
+ --name ora-app \
47
+ --restart unless-stopped \
48
+ -v $(pwd)/important:/app/important \
49
+ ora-app
50
+
51
+ echo ""
52
+ echo "โœ… ORA is now running!"
53
+ echo "======================================"
54
+ echo "Access ORA at: http://$(curl -s ifconfig.me)"
55
+ echo ""
56
+ echo "๐Ÿ“Š Check logs: sudo docker logs -f ora-app"
57
+ echo "๐Ÿ”„ Restart: sudo docker restart ora-app"
58
+ echo "๐Ÿ›‘ Stop: sudo docker stop ora-app"
59
+ echo ""
60
+ echo "๐Ÿ’ฐ Remember: This VM costs ~$0.35/hour"
61
+ echo "๐Ÿ›‘ Stop VM when not using: gcloud compute instances stop ora-gpu-vm --zone=us-central1-a"