-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun_dev.sh
More file actions
69 lines (60 loc) · 2.07 KB
/
run_dev.sh
File metadata and controls
69 lines (60 loc) · 2.07 KB
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
#!/bin/bash
set -e
# ----------------- Configuration -----------------
# Default paths for data and checkpoints.
# You can override these with command-line arguments.
#
# Example usage:
# ./run_dev.sh --data-dir /path/to/your/data --checkpoints-dir /path/to/your/checkpoints
DATA_DIR="/data/codonfm"
CHECKPOINTS_DIR="/data/codonfm/checkpoints"
# Parse command-line arguments for paths
while [[ "$#" -gt 0 ]]; do
case $1 in
--data-dir) DATA_DIR="$2"; shift ;;
--checkpoints-dir) CHECKPOINTS_DIR="$2"; shift ;;
-h|--help)
echo "Usage: $0 [--data-dir <path>] [--checkpoints-dir <path>]"
exit 0
;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
IMAGE_NAME="codon-fm-dev"
CONTAINER_NAME="codon-fm-dev-container"
echo "Building the development docker image..."
# Build the development image using the 'development' stage in the Dockerfile
docker build -t ${IMAGE_NAME} \
--target development \
--build-arg USERNAME=$(whoami) \
--build-arg USER_UID=$(id -u) \
--build-arg USER_GID=$(id -g) \
-f Dockerfile .
# Check if a container with the same name is already running and stop it
if [ "$(docker ps -q -f name=${CONTAINER_NAME})" ]; then
echo "Stopping and removing existing container..."
docker stop ${CONTAINER_NAME}
docker rm ${CONTAINER_NAME}
fi
echo "Launching the development container with the following mounts:"
echo " - Host: $(pwd) -> Container: /workspace"
echo " - Host: ${DATA_DIR} -> Container: /data"
echo " - Host: ${CHECKPOINTS_DIR} -> Container: /data/checkpoints"
echo " - Host: ~/.ssh -> Container: /home/$(whoami)/.ssh (read-only)"
# Launch the container with GPU support, mounting volumes, and exposing port 8888
docker run -it --rm \
--gpus all \
--ipc=host \
--net=host \
--hostname localhost \
-v $(pwd):/workspace \
-v "${DATA_DIR}":/data \
-v "${CHECKPOINTS_DIR}":/data/checkpoints \
-v /etc/group:/etc/group:ro \
-v /run/sshd:/run/sshd \
-v ~/.ssh:/home/$(whoami)/.ssh:ro \
-p 8888:8888 \
--name ${CONTAINER_NAME} \
${IMAGE_NAME} \
bash