-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprebuilt_container_run.sh
90 lines (81 loc) · 3.54 KB
/
prebuilt_container_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# prebuilt_container_run.sh - Launches a prebuilt image of textymcspeechy-piper
# Path to script that sets which custom pronunciation rules will be applied when the container is brought up
AUTOMATIC_ESPEAK_RULE_SCRIPT="tts_dojo/ESPEAK_RULES/automated_espeak_rules.sh"
fail=0
# Check that docker is installed
if command -v docker &> /dev/null; then
:
else
echo "WARNING -- Required package Docker is not installed."
echo "install instructions can be found here:"
echo "https://docs.docker.com/engine/install/"
echo
echo
fail=1
fi
# Check that NVIDIA container toolkit is installed
if dpkg -l | grep -q nvidia-container-toolkit; then
:
else
echo "WARNING! -- Required package NVIDIA Container Toolkit is not installed."
echo "install instructions can be found here:"
echo "https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html"
echo
echo
fail=1
fi
if [[ $fail -eq 1 ]]; then
echo "Unable to proceed without required tools."
echo
echo "Press <Enter> to exit"
echo
exit 1
fi
# Set default values if not provided
TMS_USER_ID=${TMS_USER_ID:-1000}
TMS_GROUP_ID=${TMS_GROUP_ID:-1000}
TMS_VOLUME_PATH="./tts_dojo"
CONTAINER_NAME="textymcspeechy-piper"
IMAGE_NAME="domesticatedviking/textymcspeechy-piper"
# Print info
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Starting Docker container: $CONTAINER_NAME"
echo " Using image: $IMAGE_NAME"
echo " Running as user: UID=$TMS_USER_ID, GID=$TMS_GROUP_ID"
echo " Mounting volume: $TMS_VOLUME_PATH:/app/tts_dojo"
echo " Ports: Exposing 6006 for TensorBoard"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Check if the Docker image is present
if ! docker image inspect $IMAGE_NAME > /dev/null 2>&1; then
echo "Docker image $IMAGE_NAME not found locally. Pulling image..."
docker pull $IMAGE_NAME
if [ $? -ne 0 ]; then
echo "Failed to pull Docker image $IMAGE_NAME."
exit 1
fi
fi
# Run the docker container with CUDA support
docker run --rm -d \
--name $CONTAINER_NAME \
--hostname $CONTAINER_NAME \
--volume $TMS_VOLUME_PATH:/app/tts_dojo \
--runtime nvidia \
--env PUID=$TMS_USER_ID \
--env PGID=$TMS_GROUP_ID \
--env NVIDIA_VISIBLE_DEVICES=all \
--env NVIDIA_DRIVER_CAPABILITIES=compute,utility \
--user "$TMS_USER_ID:$TMS_GROUP_ID" \
--tty \
-p 6006:6006 \
$IMAGE_NAME
# Check if the container is running
if [ $? -eq 0 ]; then
echo "Container $CONTAINER_NAME started successfully."
# Apply any custom pronunciation rules configured to run automatically
$AUTOMATIC_ESPEAK_RULE_SCRIPT
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
else
echo "Failed to start the container."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
fi