|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Installs dependencies for building and running closed-set models |
| 4 | +# Usage: ./setup.sh [--no-models] [--no-closed-set] [--no-cuda]" |
| 5 | +# |
| 6 | +# This installs a minimal set of dependencies that *should* work, but YMMV. |
| 7 | +# Note: CUDA is hard-coded to install the 24.04 keyring and repos. |
| 8 | +# |
| 9 | +# Options: |
| 10 | +# --no-models: Do not download model weights |
| 11 | +# --no-closed-set: Do not install closed-set dependencies |
| 12 | +# --no-cuda: Do not install the CUDA keyring (if you already have CUDA set up) |
| 13 | +# -h/--help: Show brief usage information |
| 14 | + |
| 15 | +function download_model() { |
| 16 | + if [[ ! -e $HOME/.semantic_inference/$1 ]]; then |
| 17 | + echo "Downloading '$1'..." |
| 18 | + pipx run gdown -q --fuzzy "$2" --output "$HOME"/.semantic_inference/"$1" |
| 19 | + fi |
| 20 | +} |
| 21 | + |
| 22 | +MODELS=true # Download models |
| 23 | +CLOSED_SET=true # Install closed-set deps |
| 24 | +CUDA=true # Install cuda key |
| 25 | +while [[ $# -gt 0 ]]; do |
| 26 | + case $1 in |
| 27 | + --no-models) |
| 28 | + MODELS=false |
| 29 | + ;; |
| 30 | + --no-closed-set) |
| 31 | + CLOSED_SET=false |
| 32 | + ;; |
| 33 | + --no-cuda) |
| 34 | + CUDA=false |
| 35 | + ;; |
| 36 | + --help|-h) |
| 37 | + echo "Usage: ./setup.sh [--no-models] [--no-closed-set] [--no-cuda]" |
| 38 | + exit 0 |
| 39 | + esac |
| 40 | + shift |
| 41 | +done |
| 42 | + |
| 43 | +if [ "$CLOSED_SET" = true ]; then |
| 44 | + if [ "$CUDA" = true ]; then |
| 45 | + # TODO(nathan) grab actual release info to pick correct platform |
| 46 | + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring_1.1-1_all.deb |
| 47 | + sudo dpkg -i /tmp/cuda-keyring_1.1-1_all.deb |
| 48 | + fi |
| 49 | + |
| 50 | + sudo apt update |
| 51 | + version_info=$(apt-cache policy libnvinfer-dev) |
| 52 | + regex=" +Candidate: +[0-9.\-]+\+cuda([0-9]+)\.([0-9]+)" |
| 53 | + if [[ $version_info =~ $regex ]]; then |
| 54 | + version="${BASH_REMATCH[1]}" |
| 55 | + minor_version="${BASH_REMATCH[2]}" |
| 56 | + else |
| 57 | + echo "Could not find CUDA version!" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + |
| 61 | + sudo apt install libnvinfer-dev libnvonnxparsers-dev libnvinfer-plugin-dev "cuda-nvcc-${version}-${minor_version}" -y |
| 62 | +fi |
| 63 | + |
| 64 | +if [ "$MODELS" = true ]; then |
| 65 | + mkdir -p "$HOME"/.semantic_inference/ |
| 66 | + download_model ade20k-efficientvit_seg_l2.onnx https://drive.google.com/file/d/1XRcsyLSvqqhqNIaOI_vmqpUpmBT6gk9-/view?usp=drive_link |
| 67 | + download_model ade20k-hrnetv2-c1.onnx https://drive.google.com/file/d/1vwTKs5g-xrY_2z_V3_TFnmqF0QYd24OM/view?usp=drive_link |
| 68 | + download_model ade20k-mobilenetv2dilated-c1_deepsup.onnx https://drive.google.com/file/d/1siTG4Pce9o6iRKtKYZDEPWsru4LwNclo/view?usp=drive_link |
| 69 | +fi |
0 commit comments