xref: /aosp_15_r20/external/pytorch/.ci/docker/common/install_vision.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -ex
4
5install_ubuntu() {
6  apt-get update
7  apt-get install -y --no-install-recommends \
8          libopencv-dev
9
10  # Cleanup
11  apt-get autoclean && apt-get clean
12  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
13}
14
15install_centos() {
16  # Need EPEL for many packages we depend on.
17  # See http://fedoraproject.org/wiki/EPEL
18  yum --enablerepo=extras install -y epel-release
19
20  yum install -y \
21      opencv-devel
22
23  # Cleanup
24  yum clean all
25  rm -rf /var/cache/yum
26  rm -rf /var/lib/yum/yumdb
27  rm -rf /var/lib/yum/history
28}
29
30# Install base packages depending on the base OS
31ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
32case "$ID" in
33  ubuntu)
34    install_ubuntu
35    ;;
36  centos)
37    install_centos
38    ;;
39  *)
40    echo "Unable to determine OS..."
41    exit 1
42    ;;
43esac
44
45# Cache vision models used by the test
46source "$(dirname "${BASH_SOURCE[0]}")/cache_vision_models.sh"
47