EG/diagnose_gpu.sh
2025-08-01 12:40:56 +08:00

71 lines
2.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "🔍 GPU和OpenGL诊断报告"
echo "=========================="
echo ""
echo "1. 硬件信息:"
echo "-------------"
lspci | grep -i vga
echo ""
echo "2. NVIDIA驱动状态"
echo "------------------"
if command -v nvidia-smi &> /dev/null; then
nvidia-smi --query-gpu=name,driver_version,memory.total --format=csv,noheader,nounits
echo "✅ NVIDIA驱动已安装"
else
echo "❌ NVIDIA驱动未安装"
fi
echo ""
echo "3. 集成显卡OpenGL信息"
echo "----------------------"
glxinfo | grep -E "(OpenGL version|OpenGL vendor|OpenGL renderer)"
echo ""
echo "4. NVIDIA GPU OpenGL信息"
echo "-------------------------"
if command -v nvidia-smi &> /dev/null; then
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep -E "(OpenGL version|OpenGL vendor|OpenGL renderer)"
else
echo "❌ 无法测试NVIDIA GPU OpenGL"
fi
echo ""
echo "5. RenderPipeline要求检查"
echo "-------------------------"
echo "需要OpenGL 4.3 或更高版本"
# 检查集成显卡版本
INTEL_VERSION=$(glxinfo | grep "OpenGL version" | grep -o '[0-9]\+\.[0-9]\+' | head -1)
echo "集成显卡版本:$INTEL_VERSION"
if command -v nvidia-smi &> /dev/null; then
NVIDIA_VERSION=$(__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep "OpenGL version" | grep -o '[0-9]\+\.[0-9]\+' | head -1)
echo "NVIDIA GPU版本$NVIDIA_VERSION"
# 简单的版本比较
if [[ $(echo "$NVIDIA_VERSION >= 4.3" | bc -l) -eq 1 ]]; then
echo "✅ NVIDIA GPU满足RenderPipeline要求"
else
echo "❌ NVIDIA GPU不满足RenderPipeline要求"
fi
else
echo "❌ 无法检查NVIDIA GPU版本"
fi
echo ""
echo "6. 推荐解决方案:"
echo "----------------"
if command -v nvidia-smi &> /dev/null; then
echo "✅ 使用 ./run_with_nvidia.sh 启动应用程序"
else
echo "❌ 需要安装NVIDIA驱动"
echo " sudo apt update"
echo " sudo apt install nvidia-driver-535" # 或其他版本
fi
echo ""
echo "诊断完成!"