diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2024-03-10 11:10:01 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2024-03-10 11:10:01 -0400 |
| commit | 32b4aaab4c2f89803e5ce6c83045f6a16ca6ff85 (patch) | |
| tree | 9dc98e80dba475aebb2b56eba74ee8d12194649f /ai/whisper.sh | |
| parent | 674c1bfd4ba541fa88958915cd882959a7fa9aab (diff) | |
| download | dotfiles-32b4aaab4c2f89803e5ce6c83045f6a16ca6ff85.tar.gz dotfiles-32b4aaab4c2f89803e5ce6c83045f6a16ca6ff85.tar.xz | |
Add a script to setup whisper
Diffstat (limited to 'ai/whisper.sh')
| -rw-r--r-- | ai/whisper.sh | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/ai/whisper.sh b/ai/whisper.sh new file mode 100644 index 0000000..3a2234c --- /dev/null +++ b/ai/whisper.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Install whisper on Fedora targeting ROCm devices under its own user account. +set -e +un=whisper + +printR() { + printf '\033[1;31m%s\033[0m\n' "$@" +} + +setupNote() { + printR "The user $un was created for whisper" + printR "To switch to that user and run whsiper commands run:" + printR "sudo su - $un" +} + +if [ "$(id -un)" != "$un" ] ; then + if [ "$(id -un)" != "root" ] ; then + echo "Re run this as root/with sudo to create the user" + exit 1 + fi + + set -x + if ! grep '^'"$un" /etc/passwd ; then + sudo adduser "$un" + fi + for group in video render ; do + sudo gpasswd -a "$un" "$group" + done + set +x + + cp "$0" /home/"$un"/whisper.sh + su - "$un" /home/"$un"/whisper.sh + + trap setupNote EXIT + + exit 0; +fi + +set -ex +miniconda=1 +miniconda_sha256='b978856ec3c826eb495b60e3fffe621f670c101150ebcbdeede4f961f22dc438' +rocm_version="5.7" # rpm -qa | grep -i rocm # or so + +if [ -d ~/miniconda3 ] ; then miniconda=0 ; fi + +if [ $miniconda -eq 1 ] ; then +miniconda_out=/tmp/miniconda3.sh +trap "rm -f \"$miniconda_out\"" EXIT INT + +wget -O "$miniconda_out" \ + https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh + +if ! sha256sum "$miniconda_out" | grep -q "$miniconda_sha256" ; then + echo "Bad checksum for miniconda installer, perhaps a network issue or out of date checksum?" + exit 1 +fi + +bash "$miniconda_out" -b -u -p ~/miniconda3 +~/miniconda3/bin/conda init bash +fi + + +if ! conda env list | grep -q '^whisper' ; then + conda create -y --name whisper python=3.9 +fi + +set +ex +. ~/.bashrc +set -ex + +conda activate whisper +# https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/3rd-party/pytorch-install.html +conda install -y pytorch==2.0.0 torchaudio==2.0.0 -c pytorch +pip install -U openai-whisper +pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm5.7/ +pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git + +if ! grep '^conda activate whisper' ~/.bashrc ; then + echo conda activate whisper >> ~/.bashrc +fi |
