-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_single_server_lim_disk.sh
executable file
·75 lines (62 loc) · 1.65 KB
/
start_single_server_lim_disk.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
#!/bin/bash
# Function to check if fzf is installed
check_fzf_installed() {
if ! command -v fzf &> /dev/null
then
echo "fzf could not be found."
echo "Please install fzf before running this script."
echo "For Ubuntu/Debian: sudo apt-get install fzf"
echo "For macOS: brew install fzf"
exit 1
fi
}
# Check if fzf is installed
check_fzf_installed
# Display available Docker images
images=$(docker images --format '{{.Repository}}:{{.Tag}}')
image_name=$(echo "$images" | fzf --prompt="Select Docker image: " --height=10 --reverse)
# Check if selection is made
if [ -n "$image_name" ]; then
echo "You selected: $image_name"
else
echo "No image selected."
exit
fi
# Prompt user for container name
echo -n "Container Name : "
read container_name
# Prompt user for port number
echo -n "Port : "
read port_number
# Prompt user for CPU quota
# max_cpus=$(nproc)
# echo -n "CPUs quota (up to $max_cpus) : "
# read cpus_quota
# Prompt user for memory quota
echo -n "Memory quota (GB) : "
read memory_quota
# Prompt user for storage qutoa
echo -n "Storage quota (GB) : "
read storage_quota
docker run \
-itd \
--restart always \
--storage-opt size="${storage_quota}g" \
--memory="${memory_quota}g" \
--name $container_name \
-p $port_number:22 \
-v /mnt:/mnt \
--device /dev/kvm \
--gpus all \
--privileged \
--shm-size="${memory_quota}g" \
$image_name
# other options #
# -v [host_path]:[mounting_point_in_the_container]
# --gpus all / '"device=1"'
# enable kvm
# --device /dev/kvm \
# --security-opt seccomp=unconfined \
# --cap-add SYS_ADMIN \
# --cpus=$cpus_quota \
# --shm-size for pytorch DDP