-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from Wordcab/319-add-modified-faster-whisper-…
…library 319 add modified faster whisper library
- Loading branch information
Showing
41 changed files
with
6,521 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Contributing to faster-whisper | ||
|
||
Contributions are welcome! Here are some pointers to help you install the library for development and validate your changes before submitting a pull request. | ||
|
||
## Install the library for development | ||
|
||
We recommend installing the module in editable mode with the `dev` extra requirements: | ||
|
||
```bash | ||
git clone https://github.com/SYSTRAN/faster-whisper.git | ||
cd faster-whisper/ | ||
pip install -e .[dev] | ||
``` | ||
|
||
## Validate the changes before creating a pull request | ||
|
||
1. Make sure the existing tests are still passing (and consider adding new tests as well!): | ||
|
||
```bash | ||
pytest tests/ | ||
``` | ||
|
||
2. Reformat and validate the code with the following tools: | ||
|
||
```bash | ||
black . | ||
isort . | ||
flake8 . | ||
``` | ||
|
||
These steps are also run automatically in the CI when you open the pull request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 SYSTRAN | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include faster_whisper/assets/silero_vad.onnx | ||
include requirements.txt | ||
include requirements.conversion.txt | ||
include faster_whisper/assets/pyannote_vad_model.bin |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import argparse | ||
import time | ||
|
||
from typing import Callable | ||
|
||
import py3nvml.py3nvml as nvml | ||
|
||
from memory_profiler import memory_usage | ||
from utils import MyThread, get_logger, inference | ||
|
||
logger = get_logger("faster-whisper") | ||
parser = argparse.ArgumentParser(description="Memory benchmark") | ||
parser.add_argument( | ||
"--gpu_memory", action="store_true", help="Measure GPU memory usage" | ||
) | ||
parser.add_argument("--device-index", type=int, default=0, help="GPU device index") | ||
parser.add_argument( | ||
"--interval", | ||
type=float, | ||
default=0.5, | ||
help="Interval at which measurements are collected", | ||
) | ||
args = parser.parse_args() | ||
device_idx = args.device_index | ||
interval = args.interval | ||
|
||
|
||
def measure_memory(func: Callable[[], None]): | ||
if args.gpu_memory: | ||
logger.info( | ||
"Measuring maximum GPU memory usage on GPU device." | ||
" Make sure to not have additional processes running on the same GPU." | ||
) | ||
# init nvml | ||
nvml.nvmlInit() | ||
handle = nvml.nvmlDeviceGetHandleByIndex(device_idx) | ||
gpu_name = nvml.nvmlDeviceGetName(handle) | ||
gpu_memory_limit = nvml.nvmlDeviceGetMemoryInfo(handle).total >> 20 | ||
gpu_power_limit = nvml.nvmlDeviceGetPowerManagementLimit(handle) / 1000.0 | ||
info = {"gpu_memory_usage": [], "gpu_power_usage": []} | ||
|
||
def _get_gpu_info(): | ||
while True: | ||
info["gpu_memory_usage"].append( | ||
nvml.nvmlDeviceGetMemoryInfo(handle).used >> 20 | ||
) | ||
info["gpu_power_usage"].append( | ||
nvml.nvmlDeviceGetPowerUsage(handle) / 1000 | ||
) | ||
time.sleep(interval) | ||
|
||
if stop: | ||
break | ||
|
||
return info | ||
|
||
stop = False | ||
thread = MyThread(_get_gpu_info, params=()) | ||
thread.start() | ||
func() | ||
stop = True | ||
thread.join() | ||
result = thread.get_result() | ||
|
||
# shutdown nvml | ||
nvml.nvmlShutdown() | ||
max_memory_usage = max(result["gpu_memory_usage"]) | ||
max_power_usage = max(result["gpu_power_usage"]) | ||
print("GPU name: %s" % gpu_name) | ||
print("GPU device index: %s" % device_idx) | ||
print( | ||
"Maximum GPU memory usage: %dMiB / %dMiB (%.2f%%)" | ||
% ( | ||
max_memory_usage, | ||
gpu_memory_limit, | ||
(max_memory_usage / gpu_memory_limit) * 100, | ||
) | ||
) | ||
print( | ||
"Maximum GPU power usage: %dW / %dW (%.2f%%)" | ||
% ( | ||
max_power_usage, | ||
gpu_power_limit, | ||
(max_power_usage / gpu_power_limit) * 100, | ||
) | ||
) | ||
else: | ||
logger.info("Measuring maximum increase of memory usage.") | ||
max_usage = memory_usage(func, max_usage=True, interval=interval) | ||
print("Maximum increase of RAM memory usage: %d MiB" % max_usage) | ||
|
||
|
||
if __name__ == "__main__": | ||
measure_memory(inference) |
Oops, something went wrong.