diff options
author | eitsupi <50911393+eitsupi@users.noreply.github.com> | 2022-10-11 01:33:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 01:33:01 +0300 |
commit | a8cb375d460840bbf8c91599d16fc87d9ee8b996 (patch) | |
tree | 73dd647775325582c17a452816457f5cec82004d /src/nvidia-cuda | |
parent | 065b5ec9e19d4f289a070c3d5337696fd2394dc0 (diff) |
Ensure remove apt-update cache at the beginning and end of the scripts (#210)
* remove apt lists
* bump versions
Diffstat (limited to 'src/nvidia-cuda')
-rw-r--r-- | src/nvidia-cuda/devcontainer-feature.json | 2 | ||||
-rw-r--r-- | src/nvidia-cuda/install.sh | 26 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/nvidia-cuda/devcontainer-feature.json b/src/nvidia-cuda/devcontainer-feature.json index 7ede271..6fa9aae 100644 --- a/src/nvidia-cuda/devcontainer-feature.json +++ b/src/nvidia-cuda/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "nvidia-cuda", - "version": "1.0.2", + "version": "1.0.3", "name": "NVIDIA CUDA", "description": "Installs shared libraries for NVIDIA CUDA.", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/nvidia-cuda", diff --git a/src/nvidia-cuda/install.sh b/src/nvidia-cuda/install.sh index f017ecb..9b41713 100644 --- a/src/nvidia-cuda/install.sh +++ b/src/nvidia-cuda/install.sh @@ -2,6 +2,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + INSTALL_CUDNN=${INSTALLCUDNN} INSTALL_NVTX=${INSTALLNVTX} CUDA_VERSION=${CUDAVERSION} @@ -12,9 +15,23 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi -# Install dependencies -apt-get update -yq -apt-get install -yq wget ca-certificates +apt_get_update() +{ + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +} + +check_packages wget ca-certificates # Add NVIDIA's package repository to apt so that we can download packages # Always use the ubuntu2004 repo because the other repos (e.g., debian11) are missing packages @@ -55,4 +72,7 @@ if [ "$INSTALL_NVTX" = "true" ]; then apt-get install -yq "$nvtx_pkg" fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" |