-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-docker.sh
64 lines (56 loc) · 1.41 KB
/
run-docker.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
#!/bin/bash
# Default values
# image="konstantinjdobler/tight-budget:main"
image="konstantinjdobler/tight-budget:hindsight"
command="bash"
gpus="none"
# Function to parse the command line arguments
parse_arguments() {
local in_command=false
while [[ $# -gt 0 ]]; do
case "$1" in
-g)
shift
gpus="$1"
;;
-i)
shift
image="$1"
;;
*)
if [ "$in_command" = false ]; then
command="$1"
else
command="${command} $1"
fi
in_command=true
;;
esac
shift
done
}
# Call the function to parse arguments
parse_arguments "$@"
# Rest of your script
echo "image: $image"
echo "command: $command"
echo "gpus: $gpus"
# Look for WANDB_API_KEY
if [ -z "$WANDB_API_KEY" ]; then
export WANDB_API_KEY=$(awk '/api.wandb.ai/{getline; getline; print $2}' ~/.netrc)
if [ -z "$WANDB_API_KEY" ]; then
echo "WANDB_API_KEY not found"
else
echo "WANDB_API_KEY found in ~/.netrc"
fi
else
echo "WANDB_API_KEY found in environment"
fi
# NOTE: --ipc=host for full RAM and CPU access or -m 300G --cpus 32 to control access to RAM and cpus
# -p 5678:5678 for remote debugging
# -p 5678:5678 \
docker run --rm -it --ipc=host \
-v "$(pwd)":/workspace -v /scratch/:/scratch/ -w /workspace \
--user $(id -u):$(id -g) \
--env XDG_CACHE_HOME --env WANDB_DATA_DIR --env WANDB_API_KEY --env NCCL_DEBUG \
--gpus=\"device=${gpus}\" $image $command