feat: split building process by several scripts

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Aisuko 2023-06-18 12:46:51 +00:00 committed by GitHub
parent d3d3187e51
commit 4117509927
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 179 additions and 28 deletions

50
scripts/cu-blas.sh Normal file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./cu-blas.sh [KEYRING_VERSION] [CUDA_MAJOR_VERSION] [CUDA_MINOR_VERSION]
set -e
BUILD_TYPE=${1:-"none"}
KEYRING_VERSION=${2:-"1.0-1"}
CUDA_MAJOR_VERSION=${3:-"11"}
CUDA_MINOR_VERSION=${4:-"7"}
export DEBIAN_FRONTEND=noninteractive
# Install software-properties-common
if [ "${BUILD_TYPE}" = "cublas" ] && ! dpkg -s software-properties-common > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends software-properties-common
fi
# Install cuda-keyring
CUDA_KEYRING_SCRIPT="$(cat <<EOF
set -e
# Wrapper function to only use sudo if not already root
sudoIf()
{
if [ "\$(id -u)" -ne 0 ]; then
sudo "\$@"
else
"\$@"
fi
}
sudoIf apt-add-repository contrib
echo "Downloading Cuda-Keyring ${KEYRING_VERSION}..."
curl -sSL -o /tmp/cuda-keyring_${KEYRING_VERSION}_all.deb "https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_${KEYRING_VERSION}_all.deb"
dpkg -i cuda-keyring_${KEYRING_VERSION}_all.deb
sudoIf apt-get update
sudoIf apt-get -y install --no-install-recommends cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION}
EOF
)"
if [ "${BUILD_TYPE}" = "cublas" ] > /dev/null 2>&1; then
"${SCHEME_INSTALL_SCRIPT}"
else
echo "Cuda keyring already installed. Skipping."
fi
echo "Done!"

46
scripts/debian.sh Normal file
View file

@ -0,0 +1,46 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./debian.sh [upgrade packages flag]
set -e
UPGRADE_PACKAGES=${1:-"true"}
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
# Function to call apt-get if needed
apt_get_update_if_needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
}
# Get to latest versions of all packages
if [ "${UPGRADE_PACKAGES}" = "true" ]; then
apt_get_update_if_needed
apt-get -y upgrade --no-install-recommends
apt-get autoremove -y
fi
# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
apt_get_update_if_needed
package_list="apt-utils \
ca-certificates \
cmake \
patch \
curl"
echo "Packages to verify are installed: ${package_list}"
apt-get -y install --no-install-recommends ${package_list} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )
PACKAGES_ALREADY_INSTALLED="true"
fi
echo "Done!"

20
scripts/ffmpeg.sh Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./ffmpeg.sh [upgrade packages flag]
set -e
FFMPEG=${1:-"false"}
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
# Install ffmpeg
if [ "${FFMPEG}" = "true" ] && ! dpkg -s ffmpeg > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends ffmpeg
fi
echo "Done!"

18
scripts/open-blas.sh Normal file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./open-blash.sh
set -e
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
# Install software-properties-common
if ! dpkg -s libopenblas-dev > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends libopenblas-dev
fi
echo "Done!"

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./stable-diffusion.sh
set -e
if ! dpkg -s libopencv-dev > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends libopencv-dev
ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
fi
echo "Done!"