Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit bc7385d

Browse files
committed
split into sh scripts
1 parent ec521ed commit bc7385d

10 files changed

+176
-88
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# .dockerignore
2+
.dockerfile
3+
.git
4+
.gitignore
5+
LICENSE
6+
README.md

LICENSE

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2024 Jeffrey Girard
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
MIT License
2+
3+
Copyright (c) 2024 Jeffrey Girard
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# wsl-cuda-whisper
2-
The audio.whisper R package allows users to easily use OpenAI's Whisper model (e.g., for automated transcription of audio files) from R. Significant speedups can be achieved on machines with CUDA-enabled graphics cards, but setting this up can be complicated. This docker image allows a user on Windows to easily install all the dependencies needed to run audio.whisper with CUDA support via Windows Subsystem for Linux (WSL2). It is built on top of the rocker/tidyverse image, which means it comes with RStudio Server installed.
3-
4-
Versions:
5-
- `jmgirard/wsl-cuda-whisper:vad` is a larger image that contains voice activity detection (VAD) via {audio.vadwebrtc} and {audio.vadsilero}. It also uses CUDA 11.8 as required by these packages.
6-
- `jmgirard/wsl-cuda-whisper:novad` is a more streamlined image that does not contain VAD and uses the newest CUDA 12.6 version.
7-
8-
Usage:
9-
1. Verify that your machine's graphics card supports CUDA: https://developer.nvidia.com/cuda-gpus
10-
2. On Windows, install the latest game-ready driver from NVIDIA: https://www.nvidia.com/Download/index.aspx#
11-
3. On Windows, install the latest version of Docker Desktop: https://www.docker.com/products/docker-desktop/
12-
4. Open Docker Desktop and click the Terminal button on the bottom of the screen
13-
5. In the Terminal, type `docker pull jmgirard/wsl-cuda-whisper` (hit Enter and wait, it may take a while)
14-
6. In the Terminal, type `docker run --gpus all --rm -it -e PASSWORD=pass -p 8787:8787 jmgirard/wsl-cuda-whisper`
15-
7. If you want access to the Windows filesystem, you can add `-v "C:\Users\jmgirard:/data"` and then access `/data` in R
16-
8. Once the Terminal has a line beginning with "TTY detected.", the container is ready
17-
9. In Docker Desktop, click the Containers tab on the left and click the "8787:8787" link
18-
10. Your browser should show a login page, enter "rstudio" as the username and "pass" for the password
19-
11. You should now be shown the RStudio page, so enter `library(audio.whisper)`
20-
12. Now you can download and load whisper models via, e.g., `model <- whisper("tiny", use_gpu = TRUE)`
21-
13. You can now use the `model` object and the `predict()` function with great speed
1+
# wsl-cuda-whisper
2+
The audio.whisper R package allows users to easily use OpenAI's Whisper model (e.g., for automated transcription of audio files) from R. Significant speedups can be achieved on machines with CUDA-enabled graphics cards, but setting this up can be complicated. This docker image allows a user on Windows to easily install all the dependencies needed to run audio.whisper with CUDA support via Windows Subsystem for Linux (WSL2). It is built on top of the rocker/tidyverse image, which means it comes with RStudio Server installed.
3+
4+
Versions:
5+
- `jmgirard/wsl-cuda-whisper:vad` is a larger image that contains voice activity detection (VAD) via {audio.vadwebrtc} and {audio.vadsilero}. It also uses CUDA 11.8 as required by these packages.
6+
- `jmgirard/wsl-cuda-whisper:novad` is a more streamlined image that does not contain VAD and uses the newest CUDA 12.6 version.
7+
8+
Usage:
9+
1. Verify that your machine's graphics card supports CUDA: https://developer.nvidia.com/cuda-gpus
10+
2. On Windows, install the latest game-ready driver from NVIDIA: https://www.nvidia.com/Download/index.aspx#
11+
3. On Windows, install the latest version of Docker Desktop: https://www.docker.com/products/docker-desktop/
12+
4. Open Docker Desktop and click the Terminal button on the bottom of the screen
13+
5. In the Terminal, type `docker pull jmgirard/wsl-cuda-whisper` (hit Enter and wait, it may take a while)
14+
6. In the Terminal, type `docker run --gpus all --rm -it -e PASSWORD=pass -p 8787:8787 jmgirard/wsl-cuda-whisper`
15+
7. If you want access to the Windows filesystem, you can add `-v "C:\Users\jmgirard:/data"` and then access `/data` in R
16+
8. Once the Terminal has a line beginning with "TTY detected.", the container is ready
17+
9. In Docker Desktop, click the Containers tab on the left and click the "8787:8787" link
18+
10. Your browser should show a login page, enter "rstudio" as the username and "pass" for the password
19+
11. You should now be shown the RStudio page, so enter `library(audio.whisper)`
20+
12. Now you can download and load whisper models via, e.g., `model <- whisper("tiny", use_gpu = TRUE)`
21+
13. You can now use the `model` object and the `predict()` function with great speed

install_cuda_11.8.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# install_cuda_11.8.sh
3+
4+
set -e
5+
6+
# A function to install apt packages only if they are not installed
7+
function apt_install() {
8+
if ! dpkg -s "$@" >/dev/null 2>&1; then
9+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
10+
apt-get update
11+
fi
12+
apt-get install -y --no-install-recommends "$@"
13+
fi
14+
}
15+
16+
# Install apt dependencies
17+
apt_install \
18+
build-essential \
19+
ca-certificates \
20+
curl \
21+
ffmpeg \
22+
gnupg \
23+
software-properties-common \
24+
wget
25+
26+
# Set up the NVIDIA CUDA repository for WSL Ubuntu
27+
wget -nv https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
28+
mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
29+
wget -nv https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
30+
dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
31+
cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
32+
33+
# Install CUDA Toolkit 11.8 for WSL Ubuntu
34+
apt-get update
35+
apt-get install -y cuda-toolkit-11-8
36+
37+
# Clean up
38+
rm -rf /var/lib/apt/lists/* /cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb /tmp/*

install_cuda_latest.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# install_cuda_latest.sh
3+
4+
set -e
5+
6+
# A function to install apt packages only if they are not installed
7+
function apt_install() {
8+
if ! dpkg -s "$@" >/dev/null 2>&1; then
9+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
10+
apt-get update
11+
fi
12+
apt-get install -y --no-install-recommends "$@"
13+
fi
14+
}
15+
16+
# Install apt dependencies
17+
apt_install \
18+
build-essential \
19+
ca-certificates \
20+
curl \
21+
ffmpeg \
22+
gnupg \
23+
software-properties-common \
24+
wget
25+
26+
# Set up the NVIDIA CUDA repository for WSL Ubuntu
27+
wget -nv https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
28+
dpkg -i cuda-keyring_1.1-1_all.deb
29+
30+
# Install CUDA Toolkit
31+
apt-get update
32+
apt_install cuda-toolkit
33+
34+
# Clean up
35+
rm -rf /var/lib/apt/lists/* cuda-keyring_1.1-1_all.deb /tmp/*

install_vad.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# install_vad.sh
3+
4+
set -e
5+
6+
## Build ARGs
7+
NCPUS=$(nproc || echo 1)
8+
9+
# Install R packages
10+
install2.r --error --skipinstalled -n "$NCPUS" \
11+
abseil \
12+
audio \
13+
remotes \
14+
torch
15+
16+
# Install torch (requires CUDA 11.8)
17+
R --no-save --no-restore -e "torch::install_torch()"
18+
19+
# Install VAD packages
20+
R --no-save --no-restore -e "remotes::install_github('bnosac/audio.vadwebrtc')"
21+
R --no-save --no-restore -e "remotes::install_github('bnosac/audio.vadsilero')"
22+
23+
# Clean up
24+
rm -rf /tmp/*

novad.Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG R_VERSION=4.4.1
2+
3+
FROM rocker/tidyverse:${R_VERSION}
4+
5+
COPY install_cuda_latest.sh /rocker_scripts/install_cuda_latest.sh
6+
7+
RUN /rocker_scripts/install_cuda_latest.sh
8+
9+
ENV PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
10+
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64
11+
ENV CUDA_PATH=/usr/local/cuda
12+
ENV WHISPER_CUBLAS=1
13+
14+
RUN install2.r --error --skipinstalled remotes
15+
16+
CMD ["bash", "-c", "R --no-save --no-restore -e 'remotes::install_github(\"bnosac/audio.whisper\")' && exec /init"]

novad/Dockerfile

-20
This file was deleted.

vad.Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG R_VERSION=4.4.1
2+
3+
FROM rocker/tidyverse:${R_VERSION}
4+
5+
COPY install_cuda_11.8.sh /rocker_scripts/install_cuda_11.8.sh
6+
COPY install_vad.sh /rocker_scripts/install_vad.sh
7+
8+
RUN /rocker_scripts/install_cuda_11.8.sh && /rocker_scripts/install_vad.sh
9+
10+
ENV PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
11+
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64
12+
ENV CUDA_PATH=/usr/local/cuda
13+
ENV WHISPER_CUBLAS=1
14+
15+
CMD ["bash", "-c", "R --no-save --no-restore -e 'remotes::install_github(\"bnosac/audio.whisper\")' && exec /init"]

vad/Dockerfile

-26
This file was deleted.

0 commit comments

Comments
 (0)