-
Notifications
You must be signed in to change notification settings - Fork 0
/
cudock
executable file
·83 lines (64 loc) · 2.11 KB
/
cudock
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
#! /bin/sh
set -e
CUDA_IMAGE_NAME="cuda"
CUDA_VERSIONS="6.5 7.0 7.5"
__image_last_version()
{
local image="$1"
echo $( docker images | awk '{print $1 ":" $2}' | grep "^$image:" | sort -t':' -rnk2 | head -1)
}
generate()
{
local cuda_version="$1"
local dir="$CUDA_IMAGE_NAME-$cuda_version"
mkdir -p $dir
cat <<-EOF > $dir/Dockerfile
FROM ubuntu:14.04
MAINTAINER nvidia.com
RUN apt-get update && apt-get install -y wget
RUN wget -q -O - http://developer.download.nvidia.com/compute/cuda/repos/GPGKEY | apt-key add - && \\
echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \\
apt-get update
ENV CUDA_VERSION ${cuda_version}
LABEL com.nvidia.cuda.version="${cuda_version}"
RUN apt-get install -y --no-install-recommends --force-yes "cuda-toolkit-${cuda_version}" gpu-deployment-kit
RUN echo "/usr/local/cuda/lib" >> /etc/ld.so.conf.d/cuda.conf && \\
echo "/usr/local/cuda/lib64" >> /etc/ld.so.conf.d/cuda.conf && \\
ldconfig
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \\
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
ENV PATH /usr/local/cuda/bin:\${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:\${LD_LIBRARY_PATH}
EOF
echo "'$dir' successfully generated"
}
build()
{
local cuda_version="$1"
local dir="$CUDA_IMAGE_NAME-$cuda_version"
command -v "docker" >/dev/null || { echo "docker: command not found"; exit 1; }
if [ -d $dir ]; then
docker build -t "$CUDA_IMAGE_NAME:$cuda_version" $dir
fi
local latest="$( __image_last_version $CUDA_IMAGE_NAME )"
docker tag -f $latest "$CUDA_IMAGE_NAME:latest"
}
cmd="$1"
case $cmd in
"generate")
shift 1 ;;
"build")
shift 1 ;;
*)
echo "usage: $0 (generate|build) [version...]"
exit 0 ;;
esac
for arg in "$@"; do
for version in $CUDA_VERSIONS; do
if [ $arg = $version ]; then
$cmd "$arg"
continue 2
fi
done
echo "Unsupported CUDA major.minor version $arg"
done