Skip to content

Instantly share code, notes, and snippets.

@h8rt3rmin8r
Created October 14, 2020 20:32
Show Gist options
  • Save h8rt3rmin8r/25042a1f96e7d6bc15ad2404787e82f8 to your computer and use it in GitHub Desktop.
Save h8rt3rmin8r/25042a1f96e7d6bc15ad2404787e82f8 to your computer and use it in GitHub Desktop.
List all installed packages related to Nvidia and CUDA (outputs are formatted as JSON)
#! /usr/bin/env bash
#
# [ nvidia-packages-list ]
#
# List all installed packages related to Nvidia and CUDA
# Created on 20201014 by h8rt3rmin8r (161803398@email.tg)
#
soft_check=$(which jq &>/dev/null; echo $?)
if [[ "${soft_check}" -ne 0 ]]; then
echo "ERROR: Missing required package: jq"
exit 1
fi
dpkg -l \
| grep -Ei '(cuda|nvidia)' \
| awk '{print "{\"package\":\""$2"\",\"version\":\""$3"\",\"arch\":\""$4"\",\"system\":\""$5"\"},"}' \
| tr -d '\n' \
| sed 's/,$/\]/;s/^/\[/' \
| jq '.' 2>/dev/null
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment