h8rt3rmin8r

nvidia-packages-list.sh

Oct 14th, 2020 (edited)
295
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/env bash
  2. #
  3. # [ nvidia-packages-list ]
  4. #
  5. #    List all installed packages related to Nvidia and CUDA
  6. #    Created on 20201014 by h8rt3rmin8r (161803398@email.tg)
  7. #
  8.  
  9. soft_check=$(which jq &>/dev/null; echo $?)
  10.  
  11. if [[ "${soft_check}" -ne 0 ]]; then
  12.     echo "ERROR: Missing required package: jq"
  13.  
  14.     exit 1
  15. fi
  16.  
  17. dpkg -l \
  18.     | grep -Ei '(cuda|nvidia)' \
  19.     | awk '{print "{\"package\":\""$2"\",\"version\":\""$3"\",\"arch\":\""$4"\",\"system\":\""$5"\"},"}' \
  20.     | tr -d '\n' \
  21.     | sed 's/,$/\]/;s/^/\[/' \
  22.     | jq '.' 2>/dev/null
  23.  
  24. exit $?
  25.  
RAW Paste Data