-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.sh
More file actions
70 lines (55 loc) · 1.86 KB
/
Copy pathvalidate.sh
File metadata and controls
70 lines (55 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Validate the CUDA development environment (native, no Docker)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "=============================================="
echo " CUDA Environment Validation"
echo "=============================================="
echo ""
echo "[1/4] GPU Detection..."
nvidia-smi --query-gpu=name,memory.total,compute_cap --format=csv
echo ""
echo "[2/4] CUDA Compiler..."
nvcc --version | head -4
echo ""
echo "[3/4] CUDA Tools..."
echo " nvcc: $(which nvcc)"
echo " cuda-gdb: $(which cuda-gdb 2>/dev/null || echo 'not found')"
echo " compute-sanitizer: $(which compute-sanitizer 2>/dev/null || echo 'not found')"
echo " ncu: $(which ncu 2>/dev/null || echo 'not found')"
echo ""
echo "[4/4] Compile & Run Test..."
cd "$SCRIPT_DIR/workspace"
# Create test file
cat > hello_test.cu << 'CUDA'
#include <stdio.h>
#include <cuda_runtime.h>
__global__ void hello() {
if (threadIdx.x == 0) printf("Hello from GPU! Block %d\n", blockIdx.x);
}
int main() {
int count;
cudaGetDeviceCount(&count);
if (count == 0) { printf("No GPU found!\n"); return 1; }
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
printf("GPU: %s (sm_%d%d)\n", prop.name, prop.major, prop.minor);
printf("Memory: %.1f GB\n", prop.totalGlobalMem / 1e9);
printf("SMs: %d\n\n", prop.multiProcessorCount);
hello<<<4, 32>>>();
cudaDeviceSynchronize();
return 0;
}
CUDA
# Detect architecture and compile
ARCH=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -1 | tr -d ".")
echo "Compiling for sm_$ARCH..."
nvcc -O3 -arch=sm_${ARCH} -o hello_test hello_test.cu
./hello_test
# Cleanup
rm -f hello_test hello_test.cu
echo ""
echo "=============================================="
echo " [PASS] All validations successful!"
echo "=============================================="