GPU Setup for Local LLM (Ollama)
Configure local GPU-accelerated LLMs using Ollama for offline AI analysis on NVIDIA CUDA or AMD ROCm.
Overview
Run AI-powered vulnerability analysis entirely on your own infrastructure with Ollama, a local LLM runtime. Scan data never leaves your account, you avoid per-token API charges on high-volume scanning, and the system keeps working offline. This guide covers GPU requirements, driver installation for NVIDIA (CUDA) and AMD (ROCm), Ollama setup, and HailBytes ASM integration.
Prerequisites
- HailBytes ASM instance (AWS/Azure) with GPU-enabled instance type
- NVIDIA GPU with 8GB+ VRAM (16GB+ recommended), or AMD GPU with ROCm support (e.g., MI210, MI300X, Radeon RX 7900 XT/XTX)
- Ubuntu 22.04 or 24.04 (matches the hardened HailBytes ASM Marketplace image)
- Root or sudo access to the server
- At least 50GB free disk space for models
What You'll Learn
- GPU requirements and instance selection (NVIDIA and AMD)
- Installing NVIDIA drivers + CUDA toolkit
- Installing AMD ROCm for Radeon Instinct / Radeon GPUs
- Setting up Ollama for local LLM inference on either vendor
- Downloading and running LLM models
- Configuring HailBytes ASM to use Ollama
- Model selection and performance tuning
Step 1: Choose GPU-Enabled Instance
Select a cloud instance with suitable GPU capabilities. Larger models require more VRAM. HailBytes ASM supports both NVIDIA (CUDA) and AMD (ROCm) GPUs.
Recommended AWS Instances
| Instance Type | GPU | VRAM | Best For |
|---|---|---|---|
| g4dn.2xlarge | NVIDIA T4 | 16GB | Small models (7B-13B) — 8 vCPU, the entry size |
| g4dn.4xlarge | NVIDIA T4 | 16GB | Medium models (13B-20B) — 16 vCPU |
| g5.2xlarge | NVIDIA A10G | 24GB | Large models (30B-70B) |
| p3.2xlarge | NVIDIA V100 | 16GB | High performance needs |
| g4ad.2xlarge | AMD Radeon Pro V520 | 8GB | AMD ROCm path, 7B models |
Azure GPU Instances
| Instance Type | GPU | VRAM | Best For |
|---|---|---|---|
| NC8as_T4_v3 | NVIDIA T4 | 16GB | Small to medium models |
| NC12s_v3 | NVIDIA V100 ×2 | 2 × 16GB | Production workloads |
| NC24ads_A100_v4 | NVIDIA A100 | 80GB | Largest models (70B+) |
| ND_MI300X_v5 | AMD Instinct MI300X | 192GB | AMD ROCm path, very large models |
Step 2: Install GPU Drivers
Step 2a: Install NVIDIA Drivers (NVIDIA path)
If you're using an NVIDIA GPU, install NVIDIA drivers and the CUDA toolkit. (For AMD GPUs, skip to Step 2b.)
# SSH into your GPU instance
ssh user@your-asm-server
# Update system packages
sudo apt update && sudo apt upgrade -y
# Check if GPU is detected
lspci | grep -i nvidia
# You should see output like:
# 00:1e.0 3D controller: NVIDIA Corporation TU104GL [Tesla T4] (rev a1)
# Install NVIDIA driver
sudo apt install -y nvidia-driver-535
# Or use CUDA toolkit installer (includes drivers)
wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.23.06_linux.run
sudo sh cuda_12.3.0_545.23.06_linux.run
# Follow installer prompts:
# - Accept license
# - Install NVIDIA driver: YES
# - Install CUDA toolkit: YES
# - Install samples: Optional
# Reboot to load drivers
sudo rebootAfter reboot, verify GPU is accessible:
# Check NVIDIA driver installation
nvidia-smi
# Expected output:
# +-----------------------------------------------------------------------------+
# | NVIDIA-SMI 545.23.06 Driver Version: 545.23.06 CUDA Version: 12.3 |
# |-------------------------------+----------------------+----------------------+
# | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
# | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
# |===============================+======================+======================|
# | 0 Tesla T4 Off | 00000000:00:1E.0 Off | 0 |
# | N/A 34C P0 27W / 70W | 0MiB / 15360MiB | 0% Default |
# +-------------------------------+----------------------+----------------------+Step 2b: Install AMD ROCm (AMD path)
If you're using an AMD GPU (Radeon Instinct MI210/MI300X, Radeon RX 7900 XT/XTX, or any ROCm-supported card), install AMD ROCm instead of CUDA.
# SSH into your AMD GPU instance
ssh user@your-asm-server
# Confirm the GPU is visible
lspci | grep -i amd | grep -i -E 'vga|3d|display'
# Install ROCm 6.x on Ubuntu 22.04 / 24.04
sudo apt update && sudo apt install -y wget gnupg
# Add the AMD ROCm apt repository
wget -qO - https://repo.radeon.com/rocm/rocm.gpg.key | \
sudo gpg --dearmor -o /etc/apt/keyrings/rocm.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/6.1 jammy main" | \
sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update
sudo apt install -y rocm-hip-libraries rocm-smi rocminfo
# Add your user to render and video groups
sudo usermod -aG render,video $USER
# Reboot to load the kernel driver
sudo rebootAfter reboot, verify ROCm sees the GPU:
# Check that ROCm sees your GPU
rocm-smi
# Expected output (excerpt):
# ============================ ROCm System Management ============================
# GPU Temp AvgPwr SCLK MCLK Fan Perf PwrCap VRAM% GPU%
# 0 38.0c 92.0W 1700Mhz 1300Mhz 0% auto 300.0W 0% 0%
# ================================================================================
# And confirm the ROCm runtime can enumerate it
rocminfo | grep -E 'Name:|Marketing Name:' | headStep 3: Install Docker with GPU Container Toolkit
Ollama runs in Docker, so we need Docker with GPU support. Use the toolkit that matches your GPU vendor.
# Install Docker (both vendors)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add current user to docker group
sudo usermod -aG docker $USER
# --- NVIDIA path ---
# Install NVIDIA Container Toolkit
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
# Configure Docker to use NVIDIA runtime
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Test GPU access in Docker
docker run --rm --gpus all nvidia/cuda:12.3.0-base-ubuntu22.04 nvidia-smi
# --- AMD ROCm path ---
# AMD GPUs are exposed through /dev/kfd and /dev/dri devices.
# No special container toolkit is required, just pass the devices through.
docker run --rm \
--device=/dev/kfd --device=/dev/dri \
--group-add video --group-add render \
rocm/rocm-terminal rocm-smiStep 4: Install Ollama
Install Ollama to run LLM models locally with GPU acceleration. Ollama auto-detects NVIDIA CUDA and AMD ROCm at runtime.
# Install Ollama (works for both NVIDIA and AMD)
curl -fsSL https://ollama.ai/install.sh | sh
# --- NVIDIA: Run Ollama in Docker with CUDA ---
docker run -d --gpus all \
-v ollama:/root/.ollama \
-p 11434:11434 \
--name ollama \
ollama/ollama
# --- AMD: Run Ollama in Docker with ROCm ---
docker run -d \
--device=/dev/kfd --device=/dev/dri \
--group-add video --group-add render \
-v ollama:/root/.ollama \
-p 11434:11434 \
--name ollama \
ollama/ollama:rocm
# Verify Ollama is running (either path)
curl http://localhost:11434/api/version
# Response:
# {"version":"0.1.17"}Ollama is now running and ready to download models.
Step 5: Download and Test LLM Models
Choose and download an appropriate model for vulnerability analysis.
Recommended Models for Security Analysis
| Model | Size | VRAM Required | Quality |
|---|---|---|---|
| llama2:7b | 3.8GB | 8GB | Good for basic analysis |
| llama2:13b | 7.4GB | 16GB | Better reasoning |
| mixtral:8x7b | 26GB | 24GB+ | Excellent analysis |
| codellama:13b | 7.4GB | 16GB | Code-focused analysis |
| mistral:7b | 4.1GB | 8GB | Fast and capable |
# Download a model (this may take 5-15 minutes depending on model size)
ollama pull llama2:13b
# Or using Docker
docker exec -it ollama ollama pull llama2:13b
# Test the model
ollama run llama2:13b
# Interactive prompt will appear - test it:
>>> Analyze this vulnerability: SQL injection in login form parameter 'username'
# Model will respond with analysis
# Exit with: /bye
# List installed models
ollama list
# Expected output:
# NAME ID SIZE MODIFIED
# llama2:13b d5611f7b5f14 7.4 GB 2 minutes agoMonitor GPU usage during model inference with watch -n 1 nvidia-smi (NVIDIA) or watch -n 1 rocm-smi (AMD).
Step 6: Configure HailBytes ASM to Use Ollama
Update HailBytes ASM configuration to use local Ollama instead of OpenAI.
# SSH into HailBytes ASM server
cd /opt/hailbytes-asm
# Edit environment configuration
nano .env
# Add/update these variables:
AI_ENABLED=true
AI_PROVIDER=ollama
OLLAMA_API_URL=http://localhost:11434
OLLAMA_MODEL=llama2:13b
OLLAMA_TIMEOUT=120 # Seconds to wait for response
OLLAMA_NUM_PREDICT=2048 # Max tokens to generate
# Disable OpenAI (if previously configured)
OPENAI_ENABLED=false
# Save and exit (Ctrl+X, Y, Enter)
# Restart HailBytes ASM services
docker-compose restart web celery
# Check logs for successful connection
docker-compose logs -f celery | grep -i ollamaHailBytes ASM will now use your local Ollama installation for all AI analysis. The same configuration works whether Ollama is backed by NVIDIA CUDA or AMD ROCm.
Step 7: Test AI Analysis with Ollama
Verify that vulnerability analysis works with your local LLM.
# Test Ollama API directly
curl -X POST http://localhost:11434/api/generate -d '{
"model": "llama2:13b",
"prompt": "Analyze this SQL injection vulnerability and provide remediation steps.",
"stream": false
}'
# Test via HailBytes ASM API
curl -X POST http://localhost:8082/api/vulnerabilities/1/analyze/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"use_ai": true}'
# Monitor GPU usage during analysis
# NVIDIA:
watch -n 1 nvidia-smi
# AMD:
watch -n 1 rocm-smiPerformance Monitoring
# Check GPU utilization (NVIDIA)
nvidia-smi --query-gpu=timestamp,name,utilization.gpu,utilization.memory,memory.used,memory.total \
--format=csv -l 1
# Check GPU utilization (AMD)
rocm-smi --showuse --showmemuse --showtemp -l 1
# Monitor Ollama logs
docker logs -f ollama
# Check HailBytes ASM Celery worker processing
docker exec -it hailbytes-asm-celery-1 celery -A hailbytes_asm inspect active
# Benchmark inference speed
time ollama run llama2:13b "Analyze this XSS vulnerability"Performance Optimization
Optimize model performance for faster vulnerability analysis:
Ollama Configuration Options
# Create Modelfile for custom configuration
FROM llama2:13b
# Set GPU layers (higher = more GPU usage = faster)
PARAMETER num_gpu 99
# Temperature (0-1, lower = more focused)
PARAMETER temperature 0.3
# Context window size
PARAMETER num_ctx 4096
# Stop sequences
PARAMETER stop ""
PARAMETER stop "User:"
# Custom system prompt for security analysis
SYSTEM You are an expert security researcher analyzing vulnerabilities in web applications...# Create custom model from Modelfile
ollama create hailbytes-asm-security -f Modelfile
# Use the custom model
ollama run hailbytes-asm-security
# Update HailBytes ASM to use custom model
# In .env: OLLAMA_MODEL=hailbytes-asm-securityModel Selection Guide
Choosing the Right Model
| Use Case | Recommended Model | Reasoning |
|---|---|---|
| Budget/Small GPU | mistral:7b or llama2:7b | Low VRAM requirement, fast |
| Balanced Performance | llama2:13b | Good quality/speed ratio |
| Code Analysis | codellama:13b | Trained on code |
| Best Quality | mixtral:8x7b | Excellent reasoning |
| High Volume | mistral:7b | Fast inference |
Cost Comparison: Ollama vs OpenAI
Local LLMs with Ollama eliminate per-request API costs but require GPU infrastructure. GPU instance rates below are estimates scaled from published AWS on-demand pricing; GPU SKU availability and rates change between generations and regions, so revalidate before you commit.
Monthly Cost Analysis (1000 scans/month)
| Solution | Setup | Monthly Cost |
|---|---|---|
| OpenAI GPT-4 | API only | $2,000-3,000 |
| OpenAI GPT-3.5 | API only | $100-200 |
| Ollama (g4dn.2xlarge) | AWS EC2 + NVIDIA T4 GPU, 8 vCPU | ~$543 |
| Ollama (g5.2xlarge) | AWS EC2 + NVIDIA A10G GPU, 8 vCPU | ~$964 |
| Ollama (g4ad.2xlarge) | AWS EC2 + AMD V520 (ROCm), 8 vCPU | ~$496 |
What the table leaves out, and why. The HailBytes ASM marketplace meter is not a row here because it applies whichever LLM you choose: the GPU instance in the Ollama rows and the plain 8-vCPU instance in the OpenAI rows both meter at 8 vCPU, $1,400/month. So read the table as the incremental cost of choosing Ollama. Against a non-GPU 8-vCPU instance at roughly $280/month of infrastructure, the GPU premium is about $216/month (g4ad.2xlarge), $263 (g4dn.2xlarge) or $684 (g5.2xlarge).
Break-even analysis, and the one method that holds. Both options run on the same 8-vCPU instance and carry the same $1,400/month meter, so those two lines cancel and the only honest comparison is the incremental one: the GPU premium above a non-GPU instance, against the API spend you avoid. At the table’s 1,000 scans/month basis GPT-4 works out at $2–$3 per scan and GPT-3.5 at $0.10–$0.20, so break-even is simply premium ÷ cost per scan:
g4ad.2xlarge(+$216/mo): 72–108 scans/month against GPT-4; 1,080–2,160 against GPT-3.5.g4dn.2xlarge(+$263/mo): 88–132 scans/month against GPT-4; 1,315–2,630 against GPT-3.5.g5.2xlarge(+$684/mo): 228–342 scans/month against GPT-4; 3,420–6,840 against GPT-3.5.
Two figures this page previously carried have been retired. The “~50 scans/month vs GPT-3.5” claim was wrong by two orders of magnitude. And a second “total monthly platform spend” calculation compared the GPU instance plus the meter against API spend alone — that double-counts, because the OpenAI path pays the same meter and the same baseline infrastructure, so it made Ollama look worse than it is at the low end and better at the high end. Only the incremental figures above are load-bearing. AMD ROCm instances remain the cheapest path for 7B-class models; against GPT-3.5 the local option does not pay off at low scan volumes on any GPU shape.
Troubleshooting
Common Issues
GPU Not Detected:
- NVIDIA: run
nvidia-smi; if it errors, reinstall drivers - AMD: run
rocm-smiandrocminfo; confirm the user is in therenderandvideogroups - Check Docker has GPU access (NVIDIA):
docker run --gpus all nvidia/cuda:12.3.0-base nvidia-smi - Check Docker has GPU access (AMD):
docker run --device=/dev/kfd --device=/dev/dri --group-add video --group-add render rocm/rocm-terminal rocm-smi - Restart Docker daemon after driver installation
Slow Inference:
- Model may be running on CPU - check
nvidia-smi/rocm-smiduring inference - Reduce model size (use 7B instead of 13B)
- Increase GPU instance size
- Set
num_gpuparameter higher in Modelfile
Out of Memory Errors:
- Model too large for available VRAM
- Use smaller model or larger GPU instance
- Reduce
num_ctx(context window) in configuration - Monitor memory with
nvidia-smiorrocm-smi
Advanced: Multiple Models
Run different models for different types of analysis:
# Download multiple models
ollama pull mistral:7b # Fast, for low/medium severity
ollama pull llama2:13b # Balanced, for high severity
ollama pull codellama:13b # Code-focused, for SAST findings
# Configure HailBytes ASM to use different models by severity
# In HailBytes ASM settings:
AI_MODEL_CRITICAL=llama2:13b
AI_MODEL_HIGH=llama2:13b
AI_MODEL_MEDIUM=mistral:7b
AI_MODEL_LOW=mistral:7bNext Steps
Configure AI Analysis
Learn about OpenAI integration and AI-powered vulnerability prioritization.
View Tutorial →Related Tutorials
- Deploy HailBytes ASM on AWS — if you also want a cloud GPU instance running Ollama remotely.
- Deploy HailBytes ASM on Azure — the Microsoft-side equivalent.
- Browse the full tutorial library or see the HailBytes ASM product page.
Get the Free HailBytes ASM Getting Started Guide
A 7-part email series covering everything from your first deployment to advanced configuration and real-world workflows. One email per day, no spam.