forked from gabrielgarza/Mask_RCNN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-gpu.sh
45 lines (37 loc) · 1.35 KB
/
configure-gpu.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
#!/bin/bash
# Script taken from:
# https://docs.aws.amazon.com/batch/latest/userguide/batch-gpu-ami.html
# Install Docker
sudo yum update -y
sudo yum install -y docker
# Install ecs-init, start docker, and install nvidia-docker 2
sudo yum install -y ecs-init
sudo service docker start
DOCKER_VERSION=$(docker -v | awk '{ print $3 }' | cut -f1 -d"-")
DISTRIBUTION=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.repo | \
sudo tee /etc/yum.repos.d/nvidia-docker.repo
PACKAGES=$(sudo yum search -y --showduplicates nvidia-docker2 nvidia-container-runtime | grep $DOCKER_VERSION | awk '{ print $1 }')
sudo yum install -y $PACKAGES
sudo pkill -SIGHUP dockerd
# Run test container to verify installation
sudo docker run --privileged --runtime=nvidia --rm nvidia/cuda nvidia-smi
# Update Docker daemon.json to user nvidia-container-runtime by default
sudo tee /etc/docker/daemon.json <<EOF
{
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
},
"default-runtime": "nvidia"
}
EOF
sudo service docker restart
# Then run
# sudo docker run nvidia/cuda:latest nvidia-smi
# sudo docker rm $(sudo docker ps -aq)
# sudo docker rmi $(sudo docker images -q)
# sudo stop ecs
# sudo rm -rf /var/lib/ecs/data/ecs_agent_data.json