Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

add Dockerfile for tensorflow #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tensorflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile for tensorflow
--------------------------------------------------------

- [tea0water/tensorflow](tensorflow)
- [tea0water/kata-benchmark](kata-benchmark)
8 changes: 8 additions & 0 deletions tensorflow/kata-benchmark/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y --no-install-recommends fio apache2-utils iperf redis-tools sysbench && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY files/ /root/kata-benchmark/
10 changes: 10 additions & 0 deletions tensorflow/kata-benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Usage
----------

```
// build image tea0water/kata-benchmark
$ ./util.sh build

// run test container
$ ./util.sh run
```
1 change: 1 addition & 0 deletions tensorflow/kata-benchmark/files/cpu-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for i in `seq 1 5`; do echo "==========test num $i========"; sysbench cpu --events=20000 run; done
16 changes: 16 additions & 0 deletions tensorflow/kata-benchmark/files/data/10-mynet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"cniVersion": "0.2.0",
"name": "mynet",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "172.19.0.0/24",
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
}

9 changes: 9 additions & 0 deletions tensorflow/kata-benchmark/files/data/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[plugins]
[plugins.cri]
sandbox_image = "mirrorgooglecontainers/pause-amd64:3.1"
[plugins.cri.containerd]
[plugins.cri.containerd.default_runtime]
runtime_type = "io.containerd.kata.v2"
[plugins.cri.cni]
# conf_dir is the directory in which the admin places a CNI conf.
conf_dir = "/etc/cni/net.d"
4 changes: 4 additions & 0 deletions tensorflow/kata-benchmark/files/data/crictl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
runtime-endpoint: unix:///var/run/containerd/containerd.sock
image-endpoint: unix:///var/run/containerd/containerd.sock
timeout: 10
debug: true
18 changes: 18 additions & 0 deletions tensorflow/kata-benchmark/files/example-pod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"metadata": {
"name": "podsandbox",
"attempt": 1
},
"port_mappings": [
{
"protocol": 0,
"container_port": 80,
"host_port": 8080
},
{
"protocol": 0,
"container_port": 5001,
"host_port": 5001
}
]
}
16 changes: 16 additions & 0 deletions tensorflow/kata-benchmark/files/fio-rand-128k-read.fio
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; fio-rand-read.job for fiotest

[global]
name=fio-rand-read
filename=/root/kata-benchmark/mnt/fio-rand-read
rw=randread
bs=128K
direct=1
numjobs=8
time_based=1
runtime=900

[file1]
size=10G
ioengine=libaio
iodepth=16
16 changes: 16 additions & 0 deletions tensorflow/kata-benchmark/files/fio-rand-128k-write.fio
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; fio-rand-write.job for fiotest

[global]
name=fio-rand-write
filename=/root/kata-benchmark/mnt/fio-rand-write
rw=randwrite
bs=128K
direct=1
numjobs=8
time_based=1
runtime=900

[file1]
size=10G
ioengine=libaio
iodepth=16
16 changes: 16 additions & 0 deletions tensorflow/kata-benchmark/files/fio-rand-4k-read.fio
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; fio-rand-read.job for fiotest

[global]
name=fio-rand-read
filename=/root/kata-benchmark/mnt/fio-rand-read
rw=randread
bs=4K
numjobs=1
direct=1
time_based=1
runtime=900

[file1]
size=10G
ioengine=libaio
iodepth=16
16 changes: 16 additions & 0 deletions tensorflow/kata-benchmark/files/fio-rand-4k-write.fio
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; fio-rand-write.job for fiotest

[global]
name=fio-rand-write
filename=/root/kata-benchmark/mnt/fio-rand-write
rw=randwrite
bs=4K
direct=1
numjobs=8
time_based=1
runtime=900

[file1]
size=10G
ioengine=libaio
iodepth=16
12 changes: 12 additions & 0 deletions tensorflow/kata-benchmark/files/iperf-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"metadata": {
"name": "iperf"
},
"image":{
"image": "mlabbe/iperf"
},
"port_mappings": [{
"container_port":80,
"host_port": 8080
}]
}
1 change: 1 addition & 0 deletions tensorflow/kata-benchmark/files/mem-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for i in `seq 1 5`; do echo "==========test num $i========"; sysbench memory --memory-access-mode=rnd run; done
8 changes: 8 additions & 0 deletions tensorflow/kata-benchmark/files/nginx-container.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"metadata": {
"name": "nginx"
},
"image":{
"image": "fupanli/nginx-benchmark"
}
}
10 changes: 10 additions & 0 deletions tensorflow/kata-benchmark/files/redis-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"metadata": {
"name": "redis"
},
"image":{
"image": "docker.io/library/redis:latest"
},
"linux": {
}
}
178 changes: 178 additions & 0 deletions tensorflow/kata-benchmark/files/scripts/fio-benchmark-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/bash
ID=""
JOBS=1
RUNTIME="runc"
KVM=0
HOST=0
scriptDir=`dirname $0`
scriptDir=`realpath $scriptDir`
prjDir="$scriptDir/../"
if [ ! -d $prjDir/fioLogs ]; then
mkdir $prjDir/fioLogs
fi

VOLUME=$prjDir

cleanup(){
if [ "$ID" != "" ]; then
sudo docker stop $ID
fi
systemctl stop docker
}

usage(){
echo "Usage: $0 -j <num jobs> -r <runtime type> -k"
echo "runtime type can be kata, runsc or runc"
echo "runc will be the fefault choice"
echo "-k" is used to enable kvm for runsc.
echo "-v" is used to add volume
exit 0
}

if [ "X$1" == "X" ]; then
usage
fi

while getopts "j:r:v:kh" arg #选项后面的冒号表示该选项需要参数
do
case $arg in
j)
JOBS=$OPTARG
;;
r)
RUNTIME=$OPTARG
;;
v)
VOLUME=$OPTARG
;;
k)
KVM=1
;;
h)
HOST=1
;;
?) #当有不认识的选项的时候arg为?
echo "unkonw argument"
exit 1
;;
esac
done

if [ "$RUNTIME" != "kata-runtime" -a "$RUNTIME" != "runsc" -a "$RUNTIME" != "runc" ]; then
echo "Error: runtime type isn't supported"
usage
fi

if [ $KVM == 1 ]; then

cat >/etc/docker/daemon.json <<EOF
{
"default-runtime": "runc",
"runtimes": {
"kata-runtime": {
"path": "/usr/local/bin/kata-runtime"
},
"runsc": {
"path": "/usr/local/bin/runsc",
"runtimeArgs": [
"--platform=kvm"
]
}
}
}
EOF

else

cat >/etc/docker/daemon.json <<EOF
{
"default-runtime": "runc",
"runtimes": {
"kata-runtime": {
"path": "/usr/local/bin/kata-runtime"
},
"runsc": {
"path": "/usr/local/bin/runsc"
}
}
}
EOF

fi

echo "start docker daemon"
sudo systemctl start docker

if [ ! -d $prjDir/fioLogs/$RUNTIME ]; then
mkdir -p $prjDir/fioLogs/$RUNTIME
fi

cpu_mem=""
if [ $RUNTIME != "kata-runtime" ]; then
cpu_mem="--cpus 8 -m 8G"
fi

ID=`sudo docker run $cpu_mem -dt --rm --runtime $RUNTIME -v $VOLUME:/test ubuntu`

if [ "$ID" == "" ]; then
echo "Error: failed to start container"
cleanup
exit 1
fi

sed -i "s/^numjobs=.*$/numjobs=$JOBS/" $scriptDir/../fio-rand-4k-read.fio
sed -i "s/^numjobs=.*$/numjobs=$JOBS/" $scriptDir/../fio-rand-4k-write.fio
sed -i "s/^numjobs=.*$/numjobs=$JOBS/" $scriptDir/../fio-rand-128k-read.fio
sed -i "s/^numjobs=.*$/numjobs=$JOBS/" $scriptDir/../fio-rand-128k-write.fio

prefix=""
if [ $HOST == 0 ]; then
EXEC="sudo docker exec -ti $ID"
prefix="/test/"
else
EXEC="sudo"
RUNTIME="host"
prefix="$VOLUME"
fi

sed -i "s#^filename=.*\$#filename=${prefix}/fio-rand-read#" $scriptDir/../fio-rand-4k-read.fio
sed -i "s#^filename=.*\$#filename=${prefix}/fio-rand-read#" $scriptDir/../fio-rand-4k-write.fio
sed -i "s#^filename=.*\$#filename=${prefix}/fio-rand-read#" $scriptDir/../fio-rand-128k-read.fio
sed -i "s#^filename=.*\$#filename=${prefix}/fio-rand-read#" $scriptDir/../fio-rand-128k-write.fio

APPENDIX="rootfs"
PREFIX=`dirname $VOLUME`

if [ "$PREFIX" == "/dev" ]; then
APPENDIX="passthrough"
dir=`mktemp -d`
mount $VOLUME $dir
cp -r $prjDir/*.fio $dir/
mkdir -p $dir/fioLogs/$RUNTIME
umount $VOLUME
rm -rf $dir
else
cp -r $prjDir/*.fio $VOLUME/
fi

$EXEC apt-get update
$EXEC apt-get install fio -y
$EXEC mkdir -p ${prefix}/fioLogs/$RUNTIME
$EXEC fio --output=${prefix}/fioLogs/$RUNTIME/fio-4k-read-$APPENDIX.log ${prefix}/fio-rand-4k-read.fio
if [ $? != 0 ]; then
cleanup
exit 1
fi
$EXEC fio --output=${prefix}/fioLogs/$RUNTIME/fio-4k-write-$APPENDIX.log ${prefix}/fio-rand-4k-write.fio
if [ $? != 0 ]; then
cleanup
exit 1
fi

$EXEC fio --output=${prefix}/fioLogs/$RUNTIME/fio-128k-read-$APPENDIX.log ${prefix}/fio-rand-128k-read.fio
if [ $? != 0 ]; then
cleanup
exit 1
fi
$EXEC fio --output=${prefix}/fioLogs/$RUNTIME/fio-128k-write-$APPENDIX.log ${prefix}/fio-rand-128k-write.fio
cleanup
Loading