Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IPXE Support #322

Open
wants to merge 6 commits into
base: intel-gpu
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci-shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ on:
push:
branches:
- master
- intel-gpu
pull_request:
branches:
- master
- intel-gpu

jobs:
test-shell-script:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ on:
push:
branches:
- master
- intel-gpu
pull_request:
branches:
- master
- intel-gpu

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ outputs/
modules/__pycache__/
models/
modules/yt_tmp.wav
configs/default_parameters.yaml
configs/default_parameters.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ If you wish to try this on Colab, you can do it in [here](https://colab.research
# Installation and Running
### Prerequisite
To run this WebUI, you need to have `git`, `python` version 3.8 ~ 3.10, `FFmpeg`. <br>
And if you're not using an Nvida GPU, or using a different `CUDA` version than 12.4, edit the [`requirements.txt`](https://github.com/jhj0517/Whisper-WebUI/blob/master/requirements.txt) to match your environment.
And if you're using an Intel GPU, view the [`requirements-ipxe.txt`](https://github.com/jhj0517/Whisper-WebUI/blob/master/requirements.txt) to match your environment.

Please follow the links below to install the necessary software:
- git : [https://git-scm.com/downloads](https://git-scm.com/downloads)
- python : [https://www.python.org/downloads/](https://www.python.org/downloads/) **( If your python version is too new, torch will not install properly.)**
- FFmpeg : [https://ffmpeg.org/download.html](https://ffmpeg.org/download.html)
- CUDA : [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads)


After installing FFmpeg, **make sure to add the `FFmpeg/bin` folder to your system PATH!**

Expand Down
12 changes: 11 additions & 1 deletion modules/diarize/diarizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import os
import torch
try:
import intel_extension_for_pytorch as ipex
if torch.xpu.is_available():
xpu_available = True
except:
pass
from typing import List, Union, BinaryIO, Optional
import numpy as np
import time
Expand Down Expand Up @@ -120,6 +126,8 @@ def get_device():
return "cuda"
elif torch.backends.mps.is_available():
return "mps"
elif torch.xpu.is_available():
return "xpu"
else:
return "cpu"

Expand All @@ -130,4 +138,6 @@ def get_available_device():
devices.append("cuda")
elif torch.backends.mps.is_available():
devices.append("mps")
return devices
elif torch.xpu.is_available():
devices.append("xpu")
return devices
15 changes: 13 additions & 2 deletions modules/translation/translation_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import os
import torch
try:
import intel_extension_for_pytorch as ipex
if torch.xpu.is_available():
xpu_available = True
except:
pass
import gradio as gr
from abc import ABC, abstractmethod
from typing import List
Expand Down Expand Up @@ -134,22 +140,27 @@ def translate_file(self,
except Exception as e:
print(f"Error: {str(e)}")
finally:
self.release_cuda_memory()
self.release_gpu_memory()

@staticmethod
def get_device():
if torch.cuda.is_available():
return "cuda"
elif torch.backends.mps.is_available():
return "mps"
elif torch.xpu.is_available():
return "xpu"
else:
return "cpu"

@staticmethod
def release_cuda_memory():
def release_gpu_memory():
if torch.cuda.is_available():
torch.cuda.empty_cache()
torch.cuda.reset_max_memory_allocated()
elif torch.xpu.is_available():
torch.xpu.empty_cache()
torch.xpu.reset_peak_memory_stats()

@staticmethod
def remove_input_files(file_paths: List[str]):
Expand Down
19 changes: 15 additions & 4 deletions modules/whisper/whisper_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import os
import torch
try:
import intel_extension_for_pytorch as ipex
if torch.xpu.is_available():
xpu_available = True
except:
pass
import whisper
import gradio as gr
import torchaudio
Expand Down Expand Up @@ -250,7 +256,7 @@ def transcribe_file(self,
except Exception as e:
print(f"Error transcribing file: {e}")
finally:
self.release_cuda_memory()
self.release_gpu_memory()

def transcribe_mic(self,
mic_audio: str,
Expand Down Expand Up @@ -305,7 +311,7 @@ def transcribe_mic(self,
except Exception as e:
print(f"Error transcribing file: {e}")
finally:
self.release_cuda_memory()
self.release_gpu_memory()

def transcribe_youtube(self,
youtube_link: str,
Expand Down Expand Up @@ -369,7 +375,7 @@ def transcribe_youtube(self,
except Exception as e:
print(f"Error transcribing file: {e}")
finally:
self.release_cuda_memory()
self.release_gpu_memory()

@staticmethod
def generate_and_write_file(file_name: str,
Expand Down Expand Up @@ -459,6 +465,8 @@ def get_device():
# Device `SparseMPS` is not supported for now. See : https://github.com/pytorch/pytorch/issues/87886
return "cpu"
return "mps"
elif torch.xpu.is_available():
return "xpu"
else:
return "cpu"

Expand All @@ -480,11 +488,14 @@ def is_sparse_api_supported():
return False

@staticmethod
def release_cuda_memory():
def release_gpu_memory():
"""Release memory"""
if torch.cuda.is_available():
torch.cuda.empty_cache()
torch.cuda.reset_max_memory_allocated()
elif torch.xpu.is_available():
torch.xpu.empty_cache()
torch.xpu.reset_peak_memory_stats()

@staticmethod
def remove_input_files(file_paths: List[str]):
Expand Down
11 changes: 11 additions & 0 deletions requirements-ipex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#torch @ https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.1.10%2Bxpu/torch-2.1.0a0+cxx11.abi-cp310-cp310-win_amd64.whl
#torchvision @ https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.1.10%2Bxpu/torchvision-0.16.0a0+cxx11.abi-cp310-cp310-win_amd64.whl
#torchaudio @ https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.1.10%2Bxpu/torchaudio-2.1.0a0+cxx11.abi-cp310-cp310-win_amd64.whl
#intel_extension_for_pytorch @ https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.1.10%2Bxpu/intel_extension_for_pytorch-2.1.10+xpu-cp310-cp310-win_amd64.whl

git+https://github.com/jhj0517/jhj0517-whisper.git
faster-whisper==1.0.3
transformers==4.42.3
gradio==4.29.0
pytubefix
pyannote.audio==3.1.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# If you're using it, update url to your CUDA version (CUDA 12.1 is minimum requirement):
# For CUDA 12.1, use : https://download.pytorch.org/whl/cu121
# For CUDA 12.4, use : https://download.pytorch.org/whl/cu124
--extra-index-url https://download.pytorch.org/whl/cu121
#--extra-index-url https://download.pytorch.org/whl/cu121


torch==2.3.1
Expand Down
7 changes: 7 additions & 0 deletions start-webui-ipex.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off

call venv\scripts\activate
python app.py --whisper_type whisper

echo "launching the app"
pause
Loading