-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathnvidia-bug-report.sh
More file actions
executable file
·2398 lines (2045 loc) · 77.3 KB
/
nvidia-bug-report.sh
File metadata and controls
executable file
·2398 lines (2045 loc) · 77.3 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# SPDX-FileCopyrightText: Copyright (c) 2004-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
PATH="/sbin:/usr/sbin:$PATH"
BASE_LOG_FILENAME="nvidia-bug-report.log"
# Bottlerocket: host root filesystem prefix
HOST_ROOT="${HOST_ROOT:-}"
if [ -d "/.bottlerocket/rootfs" ]; then
HOST_ROOT="/.bottlerocket/rootfs"
# Install required tools in admin container
dnf install -y -q which dmidecode acpica-tools 2>/dev/null || true
fi
# Bottlerocket: wrapper functions for host binaries
if [ -d "/.bottlerocket/rootfs" ]; then
__host_run() { chroot /.bottlerocket/rootfs "$@"; }
journalctl() { __host_run /usr/bin/journalctl "$@"; }
systemctl() { __host_run /usr/bin/systemctl "$@"; }
fi
# check if gzip is present
GZIP_CMD=`which gzip 2> /dev/null | head -n 1`
if [ $? -eq 0 -a "$GZIP_CMD" ]; then
GZIP_CMD="gzip -c"
else
GZIP_CMD="cat"
fi
DPY="$DISPLAY"
[ "$DPY" ] || DPY=":0"
set_filename() {
if [ "$GZIP_CMD" = "gzip -c" ]; then
LOG_FILENAME="$BASE_LOG_FILENAME.gz"
OLD_LOG_FILENAME="$BASE_LOG_FILENAME.old.gz"
else
LOG_FILENAME=$BASE_LOG_FILENAME
OLD_LOG_FILENAME="$BASE_LOG_FILENAME.old"
fi
}
query_order=""
separator_single="--------------------------------------------------------------------------------"
separator_double="================================================================================"
# Create temporary files to store skip and error summary entries.
SKIP_TMP=$(mktemp /tmp/nvidia_bug_report_skip.XXXXXX)
ERROR_TMP=$(mktemp /tmp/nvidia_bug_report_error.XXXXXX)
store_result() {
description="$1" # e.g., "NVIDIA GPU Details"
details="$2" # Details to display
# Create a sanitized version of the description for variable names
desc_sanitized=`echo "$description" | tr -c '[:alnum:]_' '_'`
# We'll store "SANITIZED|ORIGINAL" on one line (single-char delimiter).
line_item="$desc_sanitized|$description"
query_order="$query_order
$line_item"
eval "results_details_${desc_sanitized}=\"\$details\""
}
store_skip() {
description="$1"
details="$2"
description=$(echo "$description" | tr '\n' ' ')
details=$(echo "$details" | tr '\n' ' ')
echo "$description|$details" >> "$SKIP_TMP"
}
store_error() {
description="$1"
details="$2"
# Trim any leading/trailing whitespace from resolution.
resolution=$(echo "$3" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
description=$(echo "$description" | tr '\n' ' ')
details=$(echo "$details" | tr '\n' ' ')
resolution=$(echo "$resolution" | tr '\n' ' ')
printf "%s|%s|%s\n" "$description" "$details" "$resolution" >> "$ERROR_TMP"
}
report_skip() {
description="$1"
details="$2"
{
echo "____________________________________________"
echo ""
echo "Skipping: $description"
echo "$details"
echo ""
} | $GZIP_CMD >> "$LOG_FILENAME"
store_skip "$description" "$details"
}
report_and_store_error() {
description="$1"
details="$2"
exit_block="$3" # Optional parameter to indicate whether to exit the block
resolution="$4"
if [ -z "$resolution" ]; then
resolution="Contact NVIDIA for support"
fi
store_error "$description" "$details" "$resolution"
{
echo "____________________________________________"
echo ""
echo "Error: $description"
echo "$details"
echo "Resolution: $resolution"
echo ""
} | $GZIP_CMD >> "$LOG_FILENAME"
if [ "$exit_block" = "1" ]; then
echo "Exiting current block due to critical error: $description" | $GZIP_CMD >> "$LOG_FILENAME"
exit 1 # Exit the subshell to stop the current block
fi
}
print_skips_table() {
col1_header="Skipped Component"
col1_width=35
printf "%-${col1_width}s | Details\n" "$col1_header"
echo "$separator_double"
DETAIL_WIDTH=60
while IFS='|' read -r description details; do
[ -z "$description" ] && continue
wrapped=$(printf '%s\n' "$details" | fold -s -w $DETAIL_WIDTH)
first_line=$(printf '%s\n' "$wrapped" | sed -n '1p')
printf "%-${col1_width}s | %s\n" "$description" "$first_line"
rest_lines=$(printf '%s\n' "$wrapped" | sed '1d')
if [ -n "$rest_lines" ]; then
echo "$rest_lines" | while IFS= read -r detail_line; do
printf "%-${col1_width}s | %s\n" "" "$detail_line"
done
fi
echo "$separator_single"
done < "$SKIP_TMP"
}
print_errors_table() {
col1_width=35
col2_width=60
col3_width=20
header=$(printf "%-${col1_width}s | %-${col2_width}s | %-${col3_width}s" "Error Component" "Details" "Resolution")
sep_line=$(printf '%*s' $(expr $col1_width + $col2_width + $col3_width + 6) '' | tr ' ' '=')
echo "$header"
echo "$sep_line"
while IFS='|' read -r comp details resolution; do
[ -z "$comp" ] && continue
comp_wrapped=$(printf '%s\n' "$comp" | fold -s -w $col1_width)
details_wrapped=$(printf '%s\n' "$details" | fold -s -w $col2_width)
resolution_wrapped=$(printf '%s\n' "$resolution" | fold -s -w $col3_width)
comp_lines=$(printf '%s\n' "$comp_wrapped")
details_lines=$(printf '%s\n' "$details_wrapped")
resolution_lines=$(printf '%s\n' "$resolution_wrapped")
comp_count=$(printf '%s\n' "$comp_lines" | wc -l | sed 's/ //g')
details_count=$(printf '%s\n' "$details_lines" | wc -l | sed 's/ //g')
resolution_count=$(printf '%s\n' "$resolution_lines" | wc -l | sed 's/ //g')
max_lines=$(printf "%s\n" "$comp_count" "$details_count" "$resolution_count" | sort -nr | head -n 1)
i=1
while [ $i -le $max_lines ]; do
comp_line=$(printf '%s\n' "$comp_lines" | sed -n "${i}p")
details_line=$(printf '%s\n' "$details_lines" | sed -n "${i}p")
resolution_line=$(printf '%s\n' "$resolution_lines" | sed -n "${i}p")
printf "%-${col1_width}s | %-${col2_width}s | %-${col3_width}s\n" "$comp_line" "$details_line" "$resolution_line"
i=$(expr $i + 1)
done
sep_line_single=$(printf '%*s' $(expr $col1_width + $col2_width + $col3_width + 6) '' | tr ' ' '-')
echo "$sep_line_single"
done < "$ERROR_TMP"
}
print_versions_table() {
order_list="$query_order"
col1_header="Component"
col1_width=35
# Print header
printf "%-${col1_width}s | Details\n" "$col1_header"
echo "$separator_double"
echo "$order_list" | while IFS= read -r line
do
# Skip blank lines
[ -z "$line" ] && continue
# Extract sanitized + original description
sanitized="$(printf '%s' "$line" | cut -f1 -d'|')"
original="$(printf '%s' "$line" | cut -f2- -d'|')"
# Retrieve details from dynamic variables
eval details="\$results_details_${sanitized}"
# If details is empty, print "None" in the details column
if [ -z "$details" ]; then
details="None"
fi
# Split details into first line + rest
first_line="$(printf '%s\n' "$details" | sed -n '1p')"
printf "%-${col1_width}s | %s\n" "$original" "$first_line"
rest_lines="$(printf '%s\n' "$details" | sed '1d')"
if [ -n "$rest_lines" ]; then
echo "$rest_lines" | while IFS= read -r detail_line
do
printf "%-${col1_width}s | %s\n" "" "$detail_line"
done
fi
echo "$separator_single"
done
}
parse_ibv_devinfo() {
dev="$1"
shift
requested_fields="$*"
devinfo="$(ibv_devinfo -d "$dev" 2>/dev/null)"
hca_id="$(echo "$devinfo" | grep -m1 '^hca_id:' | awk '{print $2}')"
fw_ver="$(echo "$devinfo" | grep -m1 'fw_ver:' | awk '{print $2}')"
link_layer="$(echo "$devinfo" | grep -m1 'link_layer:' | awk '{print $2}')"
state="$(echo "$devinfo" | grep -m1 'state:' | sed -E 's/.*state:\s+([^ ]+).*/\1/')"
output=""
for field in $requested_fields
do
case "$field" in
device_name)
if [ "$dev" != "$hca_id" ]; then
output="$output""Device Name : $hca_id
"
fi
;;
fw_ver)
output="$output""Firmware Ver: $fw_ver
"
;;
link_layer)
output="$output""Link Layer : $link_layer
"
;;
state)
output="$output""Port State : $state
"
;;
esac
done
printf "%s" "$output"
}
run_query_ibv_devinfo() {
description="$1" # e.g., "InfiniBand Firmware Versions"
# Is ibv_devinfo present?
if ! command -v ibv_devinfo >/dev/null 2>&1; then
store_result "$description" "None"
return
fi
# Gather devices
devices="$(ibv_devinfo -l 2>/dev/null | sed -n 's/^[[:space:]]*\(mlx5_[0-9]*\)$/\1/p')"
# Parse each device
desired_fields="device_name fw_ver link_layer state"
aggregated_output=""
for dev in $devices
do
dev_output="$(parse_ibv_devinfo "$dev" "$desired_fields")"
aggregated_output="$aggregated_output""Device : $dev
$dev_output
"
done
# Store into our table
store_result "$description" "$aggregated_output"
}
check_command() {
cmd="$1" # Command to check
description="$2" # Description for the table entry
# Check if the command exists
if ! command -v "$cmd" >/dev/null 2>&1; then
# If the command is not found, log it to the table
store_result "$description" "$cmd command not found"
return 1
fi
return 0
}
# Function to detect if MODs driver is loaded vs standard RM driver
detect_driver_type() {
# Use timeout to prevent hangs, and check /proc/modules as fallback
if command -v timeout >/dev/null 2>&1; then
# Use timeout command if available
if timeout 5 lsmod 2>/dev/null | grep -q "^mods "; then
echo "Running MODs Driver on GPUs"
elif timeout 5 lsmod 2>/dev/null | grep -q "^nvidia "; then
echo "Running RM Driver on GPUs"
else
echo "GPU Driver not installed?"
fi
else
# Fallback: check /proc/modules directly (safer than lsmod)
if [ -r /proc/modules ]; then
if grep -q "^mods " /proc/modules 2>/dev/null; then
echo "Running MODs Driver on GPUs"
elif grep -q "^nvidia " /proc/modules 2>/dev/null; then
echo "Running RM Driver on GPUs"
else
echo "GPU Driver not installed?"
fi
else
echo "GPU Driver not installed?"
fi
fi
}
# Function to discover available IB devices
discover_ib_devices() {
ib_devices=""
fallback_devices=""
# Check if /sys/class/infiniband directory exists
if [ ! -d "/sys/class/infiniband" ]; then
return 1
fi
# Loop through each InfiniBand device directory
for dir in /sys/class/infiniband/*/device; do
# Check if the device directory exists
if [ -d "$dir" ]; then
# Define the path to the VPD file
vpd_file="$dir/vpd"
# Check if the VPD file exists and contains SW_MNG (NVL5+ system)
if [ -f "$vpd_file" ] && grep -q "SW_MNG" "$vpd_file" 2>/dev/null; then
# Extract the InfiniBand device name using parameter expansion
device_name="${dir%/device}" # Removes '/device' from the end of $dir
device_name="${device_name##*/}" # Extracts the part after the last '/'
# Add to fallback list (all SW_MNG devices with non-empty names)
if [ -n "$device_name" ]; then
fallback_devices="$fallback_devices $device_name"
# Check if pkey file exists for this device
pkey_file="/sys/class/infiniband/$device_name/ports/1/pkeys/0"
if [ -f "$pkey_file" ]; then
pkey_value=$(cat "$pkey_file" 2>/dev/null)
# Only include devices that are full members (0xffff) in primary list
if [ "$pkey_value" = "0xffff" ]; then
ib_devices="$ib_devices $device_name"
fi
fi
fi
fi
fi
done
# Remove leading spaces
ib_devices=$(echo "$ib_devices" | sed 's/^[[:space:]]*//')
fallback_devices=$(echo "$fallback_devices" | sed 's/^[[:space:]]*//')
# If no full member devices found, fall back to all SW_MNG devices
if [ -z "$ib_devices" ] && [ -n "$fallback_devices" ]; then
ib_devices="$fallback_devices"
fi
# If still no devices, fall back to default mlx5_0 if it exists
if [ -z "$ib_devices" ] && [ -d "/sys/class/infiniband/mlx5_0" ]; then
ib_devices="mlx5_0"
fi
echo "$ib_devices"
}
run_query_mlxlink() {
description="$1" # e.g., "Mellanox Link Firmware Versions"
query="$2" # Query string to match in 'mst status'
# Check if required commands exist
if ! check_command "mst" "$description"; then return; fi
if ! check_command "mlxlink" "$description"; then return; fi
# Discover available IB devices
ib_devices=$(discover_ib_devices)
if [ -z "$ib_devices" ]; then
store_result "$description" "No IB devices found"
return
fi
# Run mst status and capture output
mst_output=$(sudo mst status -v 2>&1)
if [ $? -ne 0 ]; then
store_result "$description" "Error running 'mst status': $mst_output"
return
fi
# Initialize result aggregation
aggregated_output=""
# Process each discovered IB device
for ib_device in $ib_devices; do
while IFS= read -r tmp_line; do
echo "$tmp_line" | grep "$query" | grep "$ib_device" >/dev/null 2>&1
if [ $? -eq 0 ]; then
# Extract device name
devName=$(echo "$tmp_line" | awk -F" " '{print $1}')
mlxlink_output=$(sudo mlxlink -d "$devName" 2>&1)
if [ $? -ne 0 ]; then
aggregated_output="$aggregated_output""Device: $devName
Error: $(echo "$mlxlink_output" | head -n 1)
"
continue
fi
aggregated_output="$aggregated_output""Device: $devName
$mlxlink_output
"
fi
done <<EOF
$(echo "$mst_output" | grep "$query" | grep "$ib_device")
EOF
done
# Store the result
if [ -z "$aggregated_output" ]; then
store_result "$description" "No devices matching query '$query'"
else
store_result "$description" "$aggregated_output"
fi
}
run_query() {
cmd="$1"
args="$2"
description="$3"
# If command is not found
if ! command -v "$cmd" >/dev/null 2>&1; then
store_result "$description" "None"
return
fi
# Capture all stdout+stderr
output=`$cmd $args 2>&1`
ret_code=$?
if [ "$description" = "OS Details" ] && [ "$ret_code" -eq 0 ]; then
os_details=""
if command -v lsb_release >/dev/null 2>&1; then
os_details="$os_details""Distribution : $(lsb_release -d -s)
"
elif [ -f ${HOST_ROOT}/etc/os-release ]; then
distline="$(grep '^PRETTY_NAME=' ${HOST_ROOT}/etc/os-release | cut -d= -f2- | tr -d '"')"
if [ -n "$distline" ]; then
os_details="$os_details""Distribution : $distline
"
else
os_details="$os_details""Distribution : Unknown
"
fi
else
os_details="$os_details""Distribution : Unknown
"
fi
os_details="$os_details""Kernel : $(uname -r)
"
os_details="$os_details""Hostname : $(cat /proc/sys/kernel/hostname 2>/dev/null || uname -n)
"
os_details="$os_details""Architecture : $(uname -m)
"
os_details="$os_details""Uptime : $(uptime -p 2>/dev/null || true)
"
output="$os_details"
fi
# Mark success or failure
if [ "$ret_code" -eq 0 ]; then
store_result "$description" "$output"
else
first_line="$(echo "$output" | head -n 1)"
store_result "$description" "Failed: $first_line"
fi
}
run_query_file() {
file_path="$1"
pattern="$2"
description="$3"
# Check if file is readable
if [ ! -r "$file_path" ]; then
store_result "$description" "None"
return
fi
# Grab matching lines
filtered_output=`grep "$pattern" "$file_path" 2>/dev/null`
ret_code=$?
if [ $ret_code -eq 0 ]; then
if [ -z "$filtered_output" ]; then
store_result "$description" "None"
else
store_result "$description" "$filtered_output"
fi
else
store_result "$description" "None"
fi
}
fetch_software_firmware_versions() {
run_query "vulkaninfo" "--version" "Vulkan Info"
# Detect driver type (MODs vs RM)
driver_type=$(detect_driver_type)
# Skip nvidia-smi calls in safe mode to avoid hangs when driver is not responding
if [ $BUG_REPORT_SAFE_MODE -eq 0 ]; then
run_query "nvidia-smi" "--version" "NVIDIA SMI"
run_query "nvidia-smi" "--query-gpu=name,driver_version,memory.total,vbios_version,pci.bus_id,serial --format=csv,noheader" \
"NVIDIA GPU Details"
else
# In safe mode, try to get driver version from modinfo as fallback
if command -v modinfo >/dev/null 2>&1; then
driver_version=$(modinfo nvidia 2>/dev/null | grep "^version:" | awk '{print $2}')
if [ -n "$driver_version" ]; then
store_result "NVIDIA SMI" "Driver version (from modinfo): $driver_version"
else
store_result "NVIDIA SMI" "Unable to fetch (safe mode - driver may be hung)"
fi
else
store_result "NVIDIA SMI" "Unable to fetch (safe mode - driver may be hung)"
fi
# Provide specific messaging for MODs driver
if echo "$driver_type" | grep -q "MODs Driver"; then
store_result "NVIDIA GPU Details" "Skipped in safe mode (MODs driver detected - nvidia-smi may hang)"
else
store_result "NVIDIA GPU Details" "Skipped in safe mode (driver may be hung)"
fi
fi
run_query "nvidia-settings" "--version" "NVIDIA Settings"
run_query "nv-fabricmanager" "--version" "NVIDIA Fabric Manager"
run_query "opensm" "--version" "NVIDIA Subnet Manager"
run_query "mlxlink" "--version" "Mellanox Link"
run_query "ibstat" "--version" "InfiniBand Status"
run_query "ibnetdiscover" "--version" "InfiniBand Network Discovery"
run_query_file "${HOST_ROOT}/var/log/dmesg" "MSE\|uCode\|NETIR" "NVIDIA MSE/NETIR Versions"
run_query_mlxlink "NVIDIA Switch Details" "Quantum"
run_query_ibv_devinfo "NVIDIA NIC Details"
run_query "uname" "-r" "OS Details"
print_versions_table
}
module_names="nvidia nvidia_drm nvidia_modeset nvidia_uvm nvidia_peermem"
usage_bug_report_message() {
echo "Please include the '$LOG_FILENAME' log file when reporting"
echo "your bug via the NVIDIA Linux forum (see forums.developer.nvidia.com)"
echo "or by sending email to 'linux-bugs@nvidia.com'."
echo ""
echo "By delivering '$LOG_FILENAME' to NVIDIA, you acknowledge"
echo "and agree that personal information may inadvertently be included in"
echo "the output. Notwithstanding the foregoing, NVIDIA will use the"
echo "output only for the purpose of investigating your reported issue."
}
usage() {
echo ""
echo "$(basename $0): NVIDIA Linux Graphics Driver bug reporting shell script."
echo ""
usage_bug_report_message
echo "Usage:"
echo " $(basename $0) [OPTIONS]"
echo ""
echo "Options:"
echo " -h, --help"
echo " Print this help message and exit."
echo ""
echo " --output-file <file>"
echo " Write output to <file>. If 'gzip' is available, the file will"
echo " automatically be compressed to <file>.gz."
echo " Default: nvidia-bug-report.log(.gz)."
echo ""
echo " --safe-mode"
echo " Disable certain queries that might hang the system. Useful if you"
echo " experience freezes, high CPU usage, or suspect problematic kernel modules."
echo ""
echo " --extra-system-data"
echo " Gather additional system information and CPU backtraces for deeper"
echo " debugging. Consider using this if the script hangs without --safe-mode"
echo " or you need more extensive kernel data."
echo ""
#VGX_SPECIFIC_CODE_START
if [ -n "$IS_XEN_HYPERVISOR" ]; then
echo " --domain-name \"<domain_name>\""
echo " Generate a bug report for the specified Xen virtual machine domain."
echo " Only valid if running within Xen dom0."
echo ""
fi
#VGX_SPECIFIC_CODE_END
echo " -v, --version"
echo " Show the current version of nvidia-bug-report.sh and exit."
echo " -V, --versions"
echo " Show the current versions of NVIDIA software and firmware on the node."
echo ""
echo "Description:"
echo " This script collects logs and configuration details—covering kernel"
echo " messages, GPU driver info, Xorg logs, hypervisor data (if applicable),"
echo " and more—to help diagnose NVIDIA driver or GPU-related issues. Run it"
echo " as root or with sudo for the most complete data."
echo ""
echo " If certain tools (e.g., 'nvidia-smi', 'lspci', 'mstflint') are missing,"
echo " the script will note \"Skipping...\" in the final report but continue"
echo " collecting other data."
echo ""
echo "Troubleshooting Tips:"
echo " - If the script hangs, try using '--safe-mode'."
echo " - If you need deeper system info (e.g., CPU backtraces), use '--extra-system-data'."
echo " - Check final '.log' or '.log.gz' for 'Skipping...' lines to see if any"
echo " dependencies were missing or commands failed."
echo " - Ensure you have installed recommended dependencies (see the full documentation"
echo " or 'system_requirements.rst'). Official releases of the NVIDIA driver/firmware"
echo " reduce hangs and incomplete captures."
echo ""
echo "Examples:"
echo " 1) sudo ./nvidia-bug-report.sh"
echo " Creates 'nvidia-bug-report.log.gz' if 'gzip' is installed."
echo ""
echo " 2) sudo ./nvidia-bug-report.sh --safe-mode"
echo " Skips queries known to cause hangs on certain systems."
echo ""
echo " 3) sudo ./nvidia-bug-report.sh --extra-system-data --output-file custom_report"
echo " Gathers extended kernel info into 'custom_report.log.gz' (compressed if possible)."
echo ""
}
NVIDIA_BUG_REPORT_CHANGE='$Change: 37062940 $'
NVIDIA_BUG_REPORT_VERSION=`echo "$NVIDIA_BUG_REPORT_CHANGE" | tr -c -d "[:digit:]"`
# Set the default filename so that it won't be empty in the usage message
set_filename
# Parse arguments: Optionally set output file, run in safe mode, include extra
# system data, or print help
BUG_REPORT_SAFE_MODE=0
BUG_REPORT_EXTRA_SYSTEM_DATA=0
SAVED_FLAGS=$@
while [ "$1" != "" ]; do
case "$1" in
-o | --output-file )
if [ -z "$2" ]; then
echo "Error: --output-file requires a filename argument."
usage
exit 1
elif [ "$(echo "$2" | cut -c 1)" = "-" ]; then
echo "Warning: Questionable filename \"$2\": possible missing argument?"
fi
BASE_LOG_FILENAME="$2"
# Override the default filename
set_filename
shift
;;
--safe-mode )
BUG_REPORT_SAFE_MODE=1
;;
--extra-system-data )
BUG_REPORT_EXTRA_SYSTEM_DATA=1
;;
-h | --help )
usage
exit 0
;;
-v | --version )
echo "${NVIDIA_BUG_REPORT_VERSION}"
exit 0
;;
-V | --versions )
fetch_software_firmware_versions
exit 0
;;
* )
echo "Error: Unknown option \"$1\"."
usage
exit 1
;;
esac
shift
done
#
# echo_metadata() - echo metadata of specified file
#
echo_metadata() {
printf "*** ls: "
/bin/ls -l --full-time "$1" 2> /dev/null
if [ $? -ne 0 ]; then
# Run dumb ls -l. We might not get one-second mtime granularity, but
# that is probably okay.
ls -l "$1" 2>&1
fi
}
#
# report_file() - print a report for the specified file to stdout: if it
# exists, dumps metadata and contents.
#
report_file() {
echo "____________________________________________"
echo ""
if [ ! -f "$1" ]; then
echo "*** $1 does not exist"
elif [ ! -r "$1" ]; then
echo "*** $1 is not readable"
else
echo "*** $1"
echo_metadata "$1"
cat "$1"
fi
echo ""
}
#
# append() - append the contents of the specified file to the log
#
append() {
report_file "$1" | $GZIP_CMD >> $LOG_FILENAME
}
#
# append_silent() - same as append(), but don't print anything
# if the file does not exist
#
append_silent() {
(
if [ -f "$1" -a -r "$1" ]; then
echo "____________________________________________"
echo ""
echo "*** $1"
echo_metadata "$1"
cat "$1"
echo ""
fi
) | $GZIP_CMD >> $LOG_FILENAME
}
#
# append_glob() - use the shell to expand a list of files, and invoke
# report_file for each of them; append the result to the log
#
append_glob() {
for append_glob_iterator in `ls $1 2> /dev/null;`; do
report_file "$append_glob_iterator"
done | $GZIP_CMD >> $LOG_FILENAME
}
#
# append_file_or_dir_silent() - if $1 is a regular file, append it; otherwise,
# if $1 is a directory, append all files under it. Don't print anything if the
# file does not exist.
#
append_file_or_dir_silent() {
if [ -f "$1" ]; then
append "$1"
elif [ -d "$1" ]; then
append_glob "$1/*"
fi
}
#
# append_binary_file() - Encode a binary file into a ascii string format
# using 'base64' and append the contents output to the log file
#
append_binary_file() {
(
base64=`which base64 2> /dev/null | head -n 1`
if [ $? -eq 0 -a -x "$base64" ]; then
if [ -f "$1" -a -r "$1" ]; then
echo "____________________________________________"
echo ""
echo "base64 \"$1\""
echo ""
base64 "$1" 2> /dev/null
echo ""
fi
else
report_skip "$1 output" "base64 not found"
echo ""
fi
) | $GZIP_CMD >> $LOG_FILENAME
}
#
# report_command() - print the output of the specified command to stdout
#
report_command() {
if [ -n "$1" ]; then
echo "$1"
echo ""
$1 2>&1
echo ""
fi
}
#
# search_string_in_logs() - search for string $2 in log file $1
#
search_string_in_logs() {
if [ -f "$1" ]; then
echo ""
if [ -r "$1" ]; then
echo " $1:"
grep $2 "$1" 2> /dev/null
return 0
else
echo "$1 is not readable"
fi
fi
return 1
}
#
# print_package_for_file() - Print the package that owns the file $1
#
print_package_for_file()
{
# Try to figure out which package manager we should use, and print which
# package owns a file.
pkgcmd=`which dpkg-query 2> /dev/null | head -n 1`
if [ $? -eq 0 -a -n "$pkgcmd" ]; then
pkgoutput=`"$pkgcmd" --search "$1" 2> /dev/null`
if [ $? -ne 0 -o "x$pkgoutput" = "x" ] ; then
echo No package found for $1
return
fi
pkgname=$(echo "$pkgoutput" | sed -e 's/:[[:space:]].*//')
if [ "x$pkgname" = "x" ] ; then
echo Can\'t parse package result: $pkgoutput
return
fi
"$pkgcmd" --show --showformat=' Package: ${Package}:${Architecture} ${Version}\n' $pkgname
return
fi
pkgcmd=`which pacman 2> /dev/null | head -n 1`
if [ $? -eq 0 -a -n "$pkgcmd" ]; then
pkgoutput=`"$pkgcmd" --query --owns "$1" 2> /dev/null`
if [ $? -ne 0 -o "x$pkgoutput" = "x" ] ; then
echo No package found for $1
return
fi
echo "$pkgoutput"
return
fi
pkgcmd=`which rpm 2> /dev/null | head -n 1`
if [ $? -eq 0 -a -n "$pkgcmd" ]; then
"$pkgcmd" -q -f "$1" 2> /dev/null
return
fi
}
GLVND_HELPER_BASE_PATH=/usr/lib/nvidia
#
# print_libglvnd_library() - Print information about a libglvnd library.
# $1 is the path to where the helper program and libraries are.
# $2 is the API to check
# $3 is the name of the library to look for
#
print_libglvnd_library()
{
echo Checking library: $3
__GLX_VENDOR_LIBRARY_NAME=installcheck
__EGL_VENDOR_LIBRARY_FILENAMES=$GLVND_HELPER_BASE_PATH/egl_dummy_vendor.json
export __GLX_VENDOR_LIBRARY_NAME
export __EGL_VENDOR_LIBRARY_FILENAMES
result=`LD_LIBRARY_PATH="$1${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $1/glvnd_check $2 $3`
code=$?
unset __GLX_VENDOR_LIBRARY_NAME
unset __EGL_VENDOR_LIBRARY_FILENAMES
case $code in
0)
echo Found compatible libglvnd library $3
;;
1)
echo Found non-libglvnd library $3
;;
2)
echo Found incompatible libglvnd library $3
;;
3)
echo Library $3 does not exist
return $code
;;
*)
echo Internal error when checking $3
echo "$result"
return 4
;;
esac
libpath=`echo "$result" | grep "^PATH " | cut -s "-d " -f2-`
echo Found library at: "$libpath"
info=`echo "$result" | grep "^LIBGLVND_ABI " | cut -s "-d " -f2,3`
if [ -n "$info" ] ; then
echo Libglvnd ABI version: $info
fi
info=`echo "$result" | grep "^CLIENT_STRING " | cut -s "-d " -f2-`
if [ -n "$info" ] ; then
echo Client version/vendor string: "$info"
fi
print_package_for_file $libpath
echo -----
return $code
}
#
# Start of script
#
# check that we are root (needed for `lspci -vxxxx` and potentially for
# accessing kernel log files)
if [ `id -u` -ne 0 ]; then
echo "ERROR: Please run $(basename $0) as root."