#!/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 set +ex . ~/.bashrc set -ex if ! conda env list | grep -q '^whisper' ; then conda create -y --name whisper python=3.9 fi 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/rocm${rocm_version}/ 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 if ! grep '^export HIP_VISIBLE_DEVICES=0' ~/.bashrc ; then echo 'export HIP_VISIBLE_DEVICES=0' >> ~/.bashrc fi