| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -uo pipefail |
| DEST=${1:-./nvidia-docs} |
| VER=${2:-} |
| mkdir -p "$DEST" |
| HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) |
| PY=$(command -v python3 || command -v python || true) |
|
|
| |
| |
| |
| if [ -z "$VER" ] && command -v nvcc >/dev/null 2>&1; then |
| V=$(nvcc --version | grep -oE 'release [0-9]+\.[0-9]+' | head -1 | cut -d' ' -f2) |
| [ -n "$V" ] && VER="$V.0" |
| fi |
| if [ -n "$VER" ] && curl -sSL --fail --max-time 60 -o /dev/null \ |
| "https://docs.nvidia.com/cuda/archive/$VER/cuda-c-programming-guide/index.html" 2>/dev/null; then |
| BASE="https://docs.nvidia.com/cuda/archive/$VER" |
| echo "fetching docs for CUDA $VER (matched to this toolkit)" |
| else |
| [ -n "$VER" ] && echo "no archive for CUDA $VER; falling back to the current docs" |
| BASE="https://docs.nvidia.com/cuda" |
| fi |
| NSIGHT="https://docs.nvidia.com/nsight-compute" |
| |
| |
| |
| |
|
|
| DOCS=" |
| cuda-c-programming-guide|$BASE/cuda-c-programming-guide/index.html |
| cuda-c-best-practices-guide|$BASE/cuda-c-best-practices-guide/index.html |
| parallel-thread-execution|$BASE/parallel-thread-execution/index.html |
| inline-ptx-assembly|$BASE/inline-ptx-assembly/index.html |
| ampere-tuning-guide|$BASE/ampere-tuning-guide/index.html |
| ada-tuning-guide|$BASE/ada-tuning-guide/index.html |
| hopper-tuning-guide|$BASE/hopper-tuning-guide/index.html |
| blackwell-tuning-guide|$BASE/blackwell-tuning-guide/index.html |
| nsight-compute-profiling-guide|$NSIGHT/ProfilingGuide/index.html |
| nsight-compute-cli|$NSIGHT/NsightComputeCli/index.html |
| " |
|
|
| ok=0; fail=0 |
| for entry in $DOCS; do |
| name=${entry%%|*} |
| url=${entry#*|} |
| html="$DEST/$name.html" |
| if ! curl -sSL --fail --max-time 120 -o "$html" "$url" 2>/dev/null; then |
| echo " FAIL $name" |
| fail=$((fail + 1)) |
| continue |
| fi |
| if [ -n "$PY" ] && [ -f "$HERE/_html2txt.py" ]; then |
| "$PY" "$HERE/_html2txt.py" "$html" > "$DEST/$name.txt" 2>/dev/null || rm -f "$DEST/$name.txt" |
| fi |
| if [ -f "$DEST/$name.txt" ]; then |
| echo " ok $name ($(du -h "$DEST/$name.txt" | cut -f1) text)" |
| else |
| echo " ok $name (html only -- no python3 for the text rendering)" |
| fi |
| ok=$((ok + 1)) |
| done |
|
|
| cat > "$DEST/LICENSE-NOTICE.txt" <<'NOTE' |
| These documents were downloaded from https://docs.nvidia.com and are |
| Copyright (c) NVIDIA Corporation. All rights reserved. |
|
|
| They are NOT covered by the license of the repository that shipped this script, |
| and they are NOT redistributable. The CUDA EULA (https://docs.nvidia.com/cuda/eula/) |
| permits distribution only of the files enumerated in its Attachment A -- runtime |
| libraries such as libcudart.so -- and documentation is not among them. |
|
|
| You obtained this copy directly from NVIDIA, for your own use, under NVIDIA's terms. |
| Do not re-publish these files. If you need to share them, share the fetch script instead. |
| NOTE |
| |
| echo |
| echo "$ok fetched, $fail failed -> $DEST" |
| echo "search with: KDOCS=$DEST tools/search_docs.sh <pattern>" |
| echo "Copyright (c) NVIDIA Corporation. Not redistributable; see $DEST/LICENSE-NOTICE.txt" |
| |