Skip to content

Instantly share code, notes, and snippets.

@mydansun
Last active January 8, 2026 14:10
Show Gist options
  • Select an option

  • Save mydansun/68e59befc0b22603142babf656411733 to your computer and use it in GitHub Desktop.

Select an option

Save mydansun/68e59befc0b22603142babf656411733 to your computer and use it in GitHub Desktop.
Install paddlepaddle
#!/usr/bin/env bash
set -euo pipefail
# Compare versions: return 0 if $1 >= $2
ver_ge() {
[[ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" == "$2" ]]
}
if ! command -v nvidia-smi >/dev/null 2>&1; then
echo "ERROR: nvidia-smi not found. Install NVIDIA driver / tools first." >&2
exit 1
fi
out="$(nvidia-smi 2>/dev/null || true)"
# Parse "CUDA Version: 12.9"
cuda_ver="$(printf '%s\n' "$out" \
| grep -oE 'CUDA Version:[[:space:]]*[0-9]+\.[0-9]+' \
| head -n1 \
| sed -E 's/.*CUDA Version:[[:space:]]*//')"
if [[ -z "${cuda_ver}" ]]; then
echo "ERROR: failed to parse CUDA Version from nvidia-smi output." >&2
echo "nvidia-smi output (first lines):" >&2
printf '%s\n' "$out" | head -n5 >&2
exit 1
fi
if ver_ge "$cuda_ver" "13.0"; then
#3.2.2 has bug on 50xx NVIDIA, wait for 3.3
#index_url="https://www.paddlepaddle.org.cn/packages/stable/cu130/"
index_url="https://www.paddlepaddle.org.cn/packages/stable/cu129/"
elif ver_ge "$cuda_ver" "12.9"; then
index_url="https://www.paddlepaddle.org.cn/packages/stable/cu129/"
elif ver_ge "$cuda_ver" "12.6"; then
index_url="https://www.paddlepaddle.org.cn/packages/stable/cu126/"
else
index_url="https://www.paddlepaddle.org.cn/packages/stable/cu118/"
fi
echo "Detected CUDA version: $cuda_ver"
echo "Installing paddlepaddle-gpu==3.2.2 from: $index_url"
python -m pip install --force-reinstall --no-cache-dir paddlepaddle-gpu==3.2.2 -i "$index_url"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment