GPU-powered virtual machines have become essential for modern AI development. Whether you're training machine learning models, running inference at scale, or experimenting with deep learning, Vultr's GPU instances provide the computational power you need at competitive prices. In this guide, we'll walk you through setting up GPU instances on Vultr and running your first AI workload.

Why Choose Vultr for AI Development?

Vultr offers dedicated GPU instances powered by NVIDIA hardware, making it an excellent choice for AI and machine learning workloads. Unlike cloud giants that charge premium prices, Vultr provides cost-effective GPU computing with pay-as-you-go pricing. Their instances feature NVIDIA T4, A100, and H100 GPUs, delivering the performance needed for training large language models, computer vision tasks, and real-time inference.

Key advantages include:

  • NVIDIA A100 GPUs - Industry-standard ML training hardware
  • Competitive pricing - Starting at $0.70/hour for GPU instances
  • Global data centers - Deploy close to your users
  • Flexible scaling - Add or remove GPU instances on demand

Prerequisites

Before we begin, ensure you have:

  • A Vultr account (sign up at vultr.com)
  • Basic knowledge of Python and command line
  • An understanding of machine learning concepts

Step 1: Deploy Your Vultr GPU Instance

Let's start by deploying a GPU-optimized Vultr instance:

  1. Log in to your Vultr dashboard
  2. Click "Deploy New Server"
  3. Select "GPU" as the server type
  4. Choose your GPU type:
    • NVIDIA T4 - Best for inference and smaller models
    • NVIDIA A100 - Ideal for training large models
    • NVIDIA H100 - Cutting-edge performance
  5. Select your preferred location
  6. Choose "Ubuntu 22.04 LTS" or "Rocky Linux 9" as the operating system
  7. Select a plan (we recommend at least 4 vCPU + 50GB SSD)
  8. Click "Deploy Now"

Your GPU instance will be ready within 2-3 minutes.

Step 2: Install CUDA and Drivers

Once your server is ready, connect via SSH and install the NVIDIA drivers:

# Update your system
sudo apt update && sudo apt upgrade -y

# Add NVIDIA repository
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update

# Install CUDA Toolkit
sudo apt install cuda-toolkit-12-4 -y

# Reboot to load drivers
sudo reboot

After rebooting, verify the installation:

nvidia-smi

You should see your GPU listed with driver version, memory usage, and utilization.

Step 3: Set Up Python and ML Frameworks

Now let's install Python and popular ML frameworks:

# Install Python and pip
sudo apt install python3 python3-pip python3-venv -y

# Create a virtual environment
python3 -m venv ml-env
source ml-env/bin/activate

# Install PyTorch with CUDA support
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

# Install TensorFlow
pip install tensorflow

# Install common ML libraries
pip install numpy pandas scikit-learn transformers accelerate

Step 4: Run Your First ML Workload

Let's test our setup with a simple PyTorch example:

python3 << 'EOF'
import torch

print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")

if torch.cuda.is_available():
    print(f"GPU: {torch.cuda.get_device_name(0)}")
    print(f"GPU Memory: {torch.cuda.get_device_properties(0).total_memory / 1e9:.2f} GB")
    
    # Simple GPU computation
    device = torch.device("cuda")
    x = torch.randn(1000, 1000, device=device)
    y = torch.randn(1000, 1000, device=device)
    z = torch.matmul(x, y)
    print(f"Matrix multiplication completed on GPU!")
else:
    print("CUDA not available")
EOF

If everything is set up correctly, you'll see your GPU information and the computation will complete successfully.

Real-World Example: Training a Image Classifier

Let's train a simple image classifier using PyTorch and your GPU:

# Create training_script.py
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision import datasets, transforms

# Check GPU
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f"Using device: {device}")

# Simple CNN model
class SimpleCNN(nn.Module):
    def __init__(self):
        super(SimpleCNN, self).__init__()
        self.conv1 = nn.Conv2d(3, 16, 3, padding=1)
        self.conv2 = nn.Conv2d(16, 32, 3, padding=1)
        self.fc = nn.Linear(32 * 8 * 8, 10)
        
    def forward(self, x):
        x = torch.relu(self.conv1(x))
        x = torch.max_pool2d(torch.relu(self.conv2(x)), 2)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x

# Load CIFAR-10 data
transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize((0.5,), (0.5,))
])

train_data = datasets.CIFAR10('./data', train=True, download=True, transform=transform)
train_loader = torch.utils.data.DataLoader(train_data, batch_size=64, shuffle=True)

# Train the model
model = SimpleCNN().to(device)
optimizer = optim.Adam(model.parameters(), lr=0.001)
criterion = nn.CrossEntropyLoss()

print("Training started...")
for epoch in range(3):
    total_loss = 0
    for batch_idx, (data, target) in enumerate(train_loader):
        data, target = data.to(device), target.to(device)
        
        optimizer.zero_grad()
        output = model(data)
        loss = criterion(output, target)
        loss.backward()
        optimizer.step()
        
        total_loss += loss.item()
        
    print(f"Epoch {epoch+1}/3 - Loss: {total_loss/len(train_loader):.4f}")

print("Training completed!")

This script downloads the CIFAR-10 dataset, trains a CNN on your GPU, and demonstrates the power of GPU-accelerated training.

Deploying Models for Inference

Once trained, you can deploy your model for real-time inference using Flask or FastAPI:

# Install FastAPI and uvicorn
pip install fastapi uvicorn

# Create inference_server.py
from fastapi import FastAPI, UploadFile
import torch
from PIL import Image
import transforms from torchvision

app = FastAPI()
model = torch.jit.load('model.pt')
model.eval()

@app.post("/predict")
async def predict(file: UploadFile):
    image = Image.open(file.file).convert('RGB')
    transform = transforms.Compose([
        transforms.Resize((32, 32)),
        transforms.ToTensor(),
        transforms.Normalize((0.5,), (0.5,))
    ])
    
    with torch.no_grad():
        prediction = model(transform(image).unsqueeze(0))
        class_id = prediction.argmax().item()
    
    return {"class_id": class_id}

Run the server with: uvicorn inference_server:app --host 0.0.0.0 --port 80

Cost Optimization Tips

To get the most value from your GPU instances:

  • Use spot instances - Save up to 70% on compute costs
  • Batch processing - Process multiple requests together
  • Auto-scaling - Scale based on demand
  • Model optimization - Use quantization and pruning to reduce inference costs

Conclusion

Setting up GPU instances on Vultr opens up powerful AI development capabilities at a fraction of cloud provider costs. Whether you're training custom models, running inference at scale, or experimenting with deep learning, Vultr's GPU instances provide the performance you need.

Ready to get started? Deploy your GPU instance today and start building AI applications!

Start Building with Vultr GPU

Get $100 free credit when you sign up and deploy your first GPU instance.

Deploy GPU Instance