summaryrefslogtreecommitdiff
path: root/containers/tests/test_gpu_container.sh
diff options
context:
space:
mode:
Diffstat (limited to 'containers/tests/test_gpu_container.sh')
-rwxr-xr-xcontainers/tests/test_gpu_container.sh146
1 files changed, 0 insertions, 146 deletions
diff --git a/containers/tests/test_gpu_container.sh b/containers/tests/test_gpu_container.sh
deleted file mode 100755
index 593f927..0000000
--- a/containers/tests/test_gpu_container.sh
+++ /dev/null
@@ -1,146 +0,0 @@
1#!/bin/bash
2
3# Container Test Script for rocky_dev_gpu:latest
4# This script tests all the functionality of the GPU-enabled container
5
6set -e
7
8CONTAINER_NAME="rocky_dev_gpu_test_$$"
9IMAGE_NAME="rocky_dev_gpu:latest"
10TEST_PORT=$(shuf -i 40000-50000 -n 1)
11
12# Cleanup function
13cleanup() {
14 echo ""
15 echo "Cleaning up..."
16 podman stop $CONTAINER_NAME >/dev/null 2>&1 || true
17 podman rm $CONTAINER_NAME >/dev/null 2>&1 || true
18 echo "Container $CONTAINER_NAME removed"
19}
20
21# Set trap to cleanup on exit
22trap cleanup EXIT
23
24echo "=== Rocky Dev GPU Container Test Suite ==="
25echo "Container: $CONTAINER_NAME"
26echo "Port: $TEST_PORT"
27echo ""
28
29# Function to run commands in container
30run_in_container() {
31 podman exec $CONTAINER_NAME bash -c "$1"
32}
33
34# Function to check if command exists
35check_command() {
36 local cmd=$1
37 echo -n "Checking $cmd... "
38 if run_in_container "command -v $cmd" >/dev/null 2>&1; then
39 echo "✓"
40 return 0
41 else
42 echo "✗"
43 return 1
44 fi
45}
46
47# Start container with GPU support
48echo "1. Starting GPU container..."
49podman run -d -p ${TEST_PORT}:22 --device nvidia.com/gpu=all --name $CONTAINER_NAME $IMAGE_NAME
50sleep 5
51
52echo ""
53echo "2. Testing base container functionality..."
54echo "(Inherited from rocky_dev:latest)"
55
56# Quick check of base tools
57echo -n "Development tools: "
58for cmd in gcc g++ make cmake git python3; do
59 run_in_container "command -v $cmd" >/dev/null 2>&1 || { echo "✗ Missing $cmd"; exit 1; }
60done
61echo "✓"
62
63echo -n "Rust toolchain: "
64run_in_container "source /root/.cargo/env && cargo --version" >/dev/null 2>&1 && echo "✓" || echo "✗"
65
66echo -n "Node.js: "
67run_in_container "source /root/.nvm/nvm.sh && node --version" >/dev/null 2>&1 && echo "✓" || echo "✗"
68
69echo ""
70echo "3. Testing GPU-specific packages..."
71# Check for GPU utilities
72check_command lspci
73check_command nvidia-smi || echo " (nvidia-smi requires actual GPU hardware)"
74
75# Check for kernel packages
76echo -n "Checking kernel headers... "
77run_in_container "rpm -q kernel-headers" >/dev/null 2>&1 && echo "✓" || echo "✗"
78
79echo -n "Checking kernel-devel... "
80run_in_container "rpm -q kernel-devel" >/dev/null 2>&1 && echo "✓" || echo "✗"
81
82echo -n "Checking pciutils... "
83run_in_container "rpm -q pciutils" >/dev/null 2>&1 && echo "✓" || echo "✗"
84
85echo ""
86echo "4. Testing NVIDIA container toolkit..."
87echo -n "Checking nvidia-container-toolkit... "
88run_in_container "rpm -q nvidia-container-toolkit" >/dev/null 2>&1 && echo "✓" || echo "✗"
89
90echo ""
91echo "5. Testing GPU environment variables..."
92# Check environment variables
93echo -n "NVIDIA_VISIBLE_DEVICES... "
94run_in_container "echo \$NVIDIA_VISIBLE_DEVICES" | grep -q "all" && echo "✓ Set to 'all'" || echo "✗ Not set correctly"
95
96echo -n "NVIDIA_DRIVER_CAPABILITIES... "
97run_in_container "echo \$NVIDIA_DRIVER_CAPABILITIES" | grep -q "compute,utility" && echo "✓ Set to 'compute,utility'" || echo "✗ Not set correctly"
98
99echo ""
100echo "6. Testing GPU test script..."
101# Check if gpu-test.sh exists and is executable
102echo -n "Checking /usr/local/bin/gpu-test.sh... "
103run_in_container "test -x /usr/local/bin/gpu-test.sh" && echo "✓ Exists and executable" || echo "✗ Not found or not executable"
104
105# Run the GPU test script
106echo ""
107echo "Running GPU test script:"
108echo "------------------------"
109run_in_container "/usr/local/bin/gpu-test.sh" || echo "Note: Some GPU tests may fail without actual GPU hardware"
110echo "------------------------"
111
112echo ""
113echo "7. Testing workspace directory..."
114# Check workspace directory
115echo -n "Checking /workspace directory... "
116run_in_container "test -d /workspace" && echo "✓ Exists" || echo "✗ Not found"
117
118echo ""
119echo "8. Testing PCI device detection..."
120# Try to detect any NVIDIA devices
121echo "PCI devices (filtered for NVIDIA/GPU):"
122run_in_container "lspci 2>/dev/null | grep -iE '(nvidia|vga|3d|display)' || echo ' No GPU devices detected (this is normal without GPU hardware)'"
123
124echo ""
125echo "9. Testing container GPU device access..."
126# Check if container has GPU device access
127echo -n "Checking /dev/nvidia* devices... "
128if run_in_container "ls /dev/nvidia* 2>/dev/null" >/dev/null 2>&1; then
129 echo "✓ GPU devices found"
130 run_in_container "ls -la /dev/nvidia*"
131else
132 echo "✗ No GPU devices (normal without GPU hardware)"
133fi
134
135echo ""
136echo "=== Test Summary ==="
137echo "GPU Support Status:"
138if run_in_container "command -v nvidia-smi && nvidia-smi" >/dev/null 2>&1; then
139 echo " ✓ Full GPU support detected"
140else
141 echo " ⚠ GPU tools installed but no GPU hardware detected"
142 echo " This is normal when running without NVIDIA GPU"
143fi
144echo ""
145echo "All tests completed successfully!"
146echo "Container will be automatically cleaned up." \ No newline at end of file