First push
This commit is contained in:
commit
00ca459ba4
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# ai-suite-rocm-local
|
||||||
|
|
||||||
|
This is a simple project to make hosting multiple AI tools easily on Linux with AMD GPUs using ROCM locally (without docker).
|
||||||
|
|
||||||
|
To use you have to clone the repo run the install script for the service you want to use.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.broillet.ch/mathieu/ai-suite-rocm-local.git
|
||||||
|
cd ai-suite-rocm-local/<service name>/
|
||||||
|
./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can run whichever service you want using their respectives run.sh scripts.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./run.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*This has been tested on Fedora 40 with kernel 6.9.6 with an AMD RX 6800 XT.*
|
||||||
|
|
2
background-removal-dis-rocm/.gitignore
vendored
Normal file
2
background-removal-dis-rocm/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
venv/
|
||||||
|
webui/
|
38
background-removal-dis-rocm/install.sh
Executable file
38
background-removal-dis-rocm/install.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source ../utils.sh
|
||||||
|
python_exec="$(pwd)/venv/bin/python3.10"
|
||||||
|
|
||||||
|
# Function to install StableDiffusion
|
||||||
|
install_background_remover() {
|
||||||
|
echo "Cloning webui..."
|
||||||
|
git clone ssh://git@git.broillet.ch:222/Clone/dis-background-removal.git webui
|
||||||
|
|
||||||
|
echo "Installing requirements..."
|
||||||
|
$python_exec -m pip install -r webui/requirements.txt
|
||||||
|
|
||||||
|
echo "Cloning DIS repo"
|
||||||
|
git clone ssh://git@git.broillet.ch:222/Clone/DIS.git tmp-dis
|
||||||
|
mv tmp-dis/IS-Net/* webui/
|
||||||
|
sudo rm -R tmp-dis
|
||||||
|
|
||||||
|
echo "Finalizing..."
|
||||||
|
mkdir webui/saved_models -p
|
||||||
|
mv webui/isnet.pth webui/saved_models
|
||||||
|
sudo rm -R webui/.git
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
prepare_env
|
||||||
|
|
||||||
|
# Set it up
|
||||||
|
install_background_remover
|
||||||
|
|
||||||
|
clean
|
||||||
|
|
||||||
|
echo "BackgroundRemover installation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run main function
|
||||||
|
main
|
19
background-removal-dis-rocm/run.sh
Executable file
19
background-removal-dis-rocm/run.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source ../utils.sh
|
||||||
|
python_exec="$(pwd)/venv/bin/python3.10"
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
# Create virtual environment
|
||||||
|
use_venv
|
||||||
|
|
||||||
|
# Prints ROCM info with available GPUs
|
||||||
|
rocm-smi
|
||||||
|
|
||||||
|
# Start BG-remover
|
||||||
|
cd webui/
|
||||||
|
TORCH_BLAS_PREFER_HIPBLASLT=0 $python_exec app.py
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
1
bitsandbytes-rocm-build/.gitignore
vendored
Normal file
1
bitsandbytes-rocm-build/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
build_output/
|
32
bitsandbytes-rocm-build/Dockerfile
Normal file
32
bitsandbytes-rocm-build/Dockerfile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
FROM rocm/dev-ubuntu-22.04:6.1.2
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONIOENCODING=UTF-8 \
|
||||||
|
ROCM_ARCH="gfx1030"
|
||||||
|
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
RUN apt-get update -y
|
||||||
|
RUN apt-get install -y wget git cron cmake make
|
||||||
|
|
||||||
|
# Install python3
|
||||||
|
RUN apt-get install -y python3 python3-dev
|
||||||
|
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3
|
||||||
|
RUN pip3 install --upgrade pip wheel setuptools
|
||||||
|
# Install pytorch for rocm
|
||||||
|
RUN pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.1
|
||||||
|
|
||||||
|
# ROCM bitsandbytes
|
||||||
|
RUN apt-get install -y hipblas hipblaslt hiprand hipsparse hipcub rocthrust-dev
|
||||||
|
## Clone repo and install python requirements
|
||||||
|
RUN git clone --recurse https://github.com/ROCm/bitsandbytes
|
||||||
|
WORKDIR /tmp/bitsandbytes
|
||||||
|
RUN git checkout rocm_enabled
|
||||||
|
RUN pip3 install -r requirements-dev.txt
|
||||||
|
## Build
|
||||||
|
RUN cmake -DCOMPUTE_BACKEND=hip -S . -DBNB_ROCM_ARCH=${ROCM_ARCH}
|
||||||
|
RUN make
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
RUN apt-get clean && pip3 cache purge
|
1
bitsandbytes-rocm-build/build.sh
Normal file
1
bitsandbytes-rocm-build/build.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
docker build . -t 'bitsandbytes-rocm-build:6.1.2' -f Dockerfile
|
31
bitsandbytes-rocm-build/extract_build.sh
Executable file
31
bitsandbytes-rocm-build/extract_build.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set variables
|
||||||
|
IMAGE_NAME="bitsandbytes-rocm-build:6.1.2"
|
||||||
|
CONTAINER_NAME="bitsandbytes-rocm-build"
|
||||||
|
FILE_IN_CONTAINER="/tmp/bitsandbytes"
|
||||||
|
FILE_ON_HOST="./build_output/"
|
||||||
|
|
||||||
|
# Run the Docker container
|
||||||
|
docker run -d --name $CONTAINER_NAME $IMAGE_NAME
|
||||||
|
|
||||||
|
# Check if the container is running
|
||||||
|
if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
|
||||||
|
echo "Container $CONTAINER_NAME is running."
|
||||||
|
|
||||||
|
# Copy the file from the container to the host
|
||||||
|
docker cp $CONTAINER_NAME:$FILE_IN_CONTAINER $FILE_ON_HOST
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "File copied successfully to $FILE_ON_HOST"
|
||||||
|
else
|
||||||
|
echo "Failed to copy file."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Failed to start container $CONTAINER_NAME."
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker stop $CONTAINER_NAME
|
||||||
|
docker rm $CONTAINER_NAME
|
||||||
|
|
||||||
|
echo "Now you can install bitsandbytes locally using \"pip install .\" in the build_output/bitsandbytes folder"
|
2
stablediffusion-rocm/.gitignore
vendored
Normal file
2
stablediffusion-rocm/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
venv/
|
||||||
|
webui/
|
30
stablediffusion-rocm/install.sh
Executable file
30
stablediffusion-rocm/install.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source ../utils.sh
|
||||||
|
python_exec=venv/bin/python3.10
|
||||||
|
|
||||||
|
# Function to install StableDiffusion
|
||||||
|
install_stablediffusion() {
|
||||||
|
if [ -d "webui" ]; then
|
||||||
|
echo "StableDiffusion repository already exists. Skipping clone."
|
||||||
|
else
|
||||||
|
echo "Cloning StableDiffusion repository..."
|
||||||
|
git clone -b dev https://github.com/AUTOMATIC1111/stable-diffusion-webui webui
|
||||||
|
fi
|
||||||
|
echo "Running StableDiffusion setup..."
|
||||||
|
$python_exec webui/launch.py --skip-torch-cuda-test --exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
prepare_env
|
||||||
|
|
||||||
|
# Install StableDiffusion
|
||||||
|
install_stablediffusion
|
||||||
|
|
||||||
|
clean
|
||||||
|
|
||||||
|
echo "StableDiffusion installation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run main function
|
||||||
|
main
|
18
stablediffusion-rocm/run.sh
Executable file
18
stablediffusion-rocm/run.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source ../utils.sh
|
||||||
|
python_exec=venv/bin/python3.10
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
# Create virtual environment
|
||||||
|
use_venv
|
||||||
|
|
||||||
|
# Prints ROCM info with available GPUs
|
||||||
|
rocm-smi
|
||||||
|
|
||||||
|
# Start SD
|
||||||
|
TORCH_BLAS_PREFER_HIPBLASLT=0 $python_exec webui/launch.py --listen --enable-insecure-extension-access --opt-split-attention
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
71
utils.sh
Normal file
71
utils.sh
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to check if PyTorch is installed
|
||||||
|
check_pytorch_installed() {
|
||||||
|
python -c "import torch" >/dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to create virtual environment
|
||||||
|
create_venv() {
|
||||||
|
if [ -d "venv" ]; then
|
||||||
|
echo "Virtual environment already exists. Skipping creation."
|
||||||
|
source venv/bin/activate
|
||||||
|
else
|
||||||
|
echo "Creating virtual environment..."
|
||||||
|
python3.10 -m venv --system-site-packages venv
|
||||||
|
source venv/bin/activate
|
||||||
|
python3.10 -m pip install --upgrade pip
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
use_venv() {
|
||||||
|
echo "Connecting to virtual environment..."
|
||||||
|
source venv/bin/activate
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install build-essential or equivalent
|
||||||
|
install_build_essentials() {
|
||||||
|
echo "Checking for build essentials..."
|
||||||
|
if [ -f /etc/debian_version ]; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential python3.10-dev
|
||||||
|
elif [ -f /etc/fedora-release ]; then
|
||||||
|
if dnf list installed @development-tools &>/dev/null; then
|
||||||
|
echo "Development Tools are already installed."
|
||||||
|
else
|
||||||
|
echo "Installing Development Tools..."
|
||||||
|
sudo dnf groupinstall -y "Development Tools"
|
||||||
|
sudo dnf install python3.10-devel
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Unsupported operating system. Please install build-essential or equivalent manually."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install PyTorch in the virtual environment
|
||||||
|
install_pytorch() {
|
||||||
|
# Check if PyTorch is installed
|
||||||
|
if check_pytorch_installed; then
|
||||||
|
echo "PyTorch is already installed."
|
||||||
|
else
|
||||||
|
echo "Installing PyTorch..."
|
||||||
|
python3.10 -m pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_env(){
|
||||||
|
# Create virtual environment
|
||||||
|
create_venv
|
||||||
|
|
||||||
|
# Install build essentials
|
||||||
|
install_build_essentials
|
||||||
|
|
||||||
|
# Install PyTorch in the virtual environment
|
||||||
|
install_pytorch
|
||||||
|
}
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
python3.10 -m pip cache purge
|
||||||
|
}
|
2
xtts-rocm/.gitignore
vendored
Normal file
2
xtts-rocm/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
venv/
|
||||||
|
webui/
|
39
xtts-rocm/install.sh
Executable file
39
xtts-rocm/install.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source ../utils.sh
|
||||||
|
python_exec=venv/bin/python3.10
|
||||||
|
|
||||||
|
# Function to install StableDiffusion
|
||||||
|
install_xtts() {
|
||||||
|
if [ -d "webui" ]; then
|
||||||
|
echo "XTTS repository already exists. Skipping clone."
|
||||||
|
else
|
||||||
|
echo "Cloning XTTS repository..."
|
||||||
|
git clone https://github.com/daswer123/xtts-webui webui
|
||||||
|
grep -v 'torch' requirements.txt > requirements_without_torch.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
$python_exec -m pip install -r webui/requirements_without_torch.txt
|
||||||
|
|
||||||
|
# Disable gpu for faster-whipser as ROCM isn't supported yet
|
||||||
|
sed -i 's/device = "cuda" if torch.cuda.is_available() else "cpu"/device = "cpu"/' webui/scripts/utils/formatter.py
|
||||||
|
sed -i 's/asr_model = WhisperModel(whisper_model, device=device, compute_type="float16")/asr_model = WhisperModel(whisper_model, device=device, compute_type="int8")/' webui/scripts/utils/formatter.py
|
||||||
|
|
||||||
|
# Deepspeed and ninja (not working)
|
||||||
|
$python_exec -m pip install deepspeed ninja
|
||||||
|
# apt-get install -y ninja-build
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
prepare_env
|
||||||
|
|
||||||
|
# Install XTTS
|
||||||
|
install_xtts
|
||||||
|
|
||||||
|
clean
|
||||||
|
|
||||||
|
echo "XTTS installation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run main function
|
||||||
|
main
|
17
xtts-rocm/run.sh
Executable file
17
xtts-rocm/run.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source ../utils.sh
|
||||||
|
python_exec=venv/bin/python3.10
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
# Create virtual environment
|
||||||
|
use_venv
|
||||||
|
|
||||||
|
# Prints ROCM info with available GPUs
|
||||||
|
rocm-smi
|
||||||
|
|
||||||
|
# Start XTTS
|
||||||
|
$python_exec webui/app.py --host 0.0.0.0 -v v2.0.3
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
Loading…
Reference in New Issue
Block a user