Skip to content

Commit 34fa832

Browse files
committed
added 2nd docker-compose-gpu.yml for gpu training, so inference now works on CPU
1 parent a4d5369 commit 34fa832

11 files changed

Lines changed: 253 additions & 23 deletions

docker-compose-gpu.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
version: '2.3'
2+
3+
services:
4+
michaniki_client:
5+
build:
6+
context: ./src
7+
dockerfile: Dockerfile-gpu
8+
runtime: nvidia
9+
ports:
10+
- "3031:3031"
11+
environment:
12+
- PORT=3031
13+
- FLAS_APP=app/__init__.py
14+
- FLASK_DEBUG=1
15+
- REDIS_URL="redis://redis"
16+
- REDIS_PORT=6379
17+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
18+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
19+
20+
volumes:
21+
- ./src:/opt/src
22+
23+
command: ./entryPoint.sh
24+
depends_on:
25+
- redis
26+
networks:
27+
- michaniki
28+
29+
inference_server:
30+
build:
31+
context: ./src
32+
dockerfile: Dockerfile-gpu
33+
runtime: nvidia
34+
environment:
35+
- REDIS_URL="redis://redis"
36+
- REDIS_PORT=6379
37+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
38+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
39+
40+
command: ['python', 'app/models/InceptionV3/inception_inference_server.py']
41+
volumes:
42+
- ./src:/opt/src
43+
44+
networks:
45+
- michaniki
46+
depends_on:
47+
- michaniki_client
48+
- redis
49+
50+
sentiment_inference_server:
51+
build:
52+
context: ./src
53+
dockerfile: Dockerfile-sentiment
54+
runtime: nvidia
55+
environment:
56+
- REDIS_URL="redis://redis"
57+
- REDIS_PORT=6379
58+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
59+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
60+
command: ['python', 'app/models/SentimentV1/sentiment_infer_server.py']
61+
volumes:
62+
- ./src:/opt/src
63+
networks:
64+
- michaniki
65+
depends_on:
66+
- michaniki_client
67+
- redis
68+
69+
celery_worker:
70+
build:
71+
context: ./src
72+
dockerfile: Dockerfile-gpu
73+
runtime: nvidia
74+
command: ['celery', '-A', 'app.celeryapp:michaniki_celery_app', 'worker', '-l', 'info']
75+
volumes:
76+
- ./src:/opt/src
77+
networks:
78+
- michaniki
79+
depends_on:
80+
- michaniki_client
81+
environment:
82+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
83+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
84+
- DB_HOST=db
85+
- DB_USERNAME=root
86+
- DB_PASSWORD=michaniki
87+
- DB_NAME=michanikidb
88+
- BROKER_URL=redis://redis:6379/0
89+
90+
91+
redis:
92+
image: redis:4.0.5-alpine
93+
command: ["redis-server", "--appendonly", "yes"]
94+
hostname: redis
95+
networks:
96+
- michaniki
97+
98+
networks:
99+
michaniki:

docker-compose.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: '2.3'
33
services:
44
michaniki_client:
55
build: ./src
6-
runtime: nvidia
76
ports:
87
- "3031:3031"
98
environment:
@@ -26,7 +25,6 @@ services:
2625

2726
inference_server:
2827
build: ./src
29-
runtime: nvidia
3028
environment:
3129
- REDIS_URL="redis://redis"
3230
- REDIS_PORT=6379
@@ -47,7 +45,6 @@ services:
4745
build:
4846
context: ./src
4947
dockerfile: Dockerfile-sentiment
50-
runtime: nvidia
5148
environment:
5249
- REDIS_URL="redis://redis"
5350
- REDIS_PORT=6379
@@ -64,7 +61,6 @@ services:
6461

6562
celery_worker:
6663
build: ./src
67-
runtime: nvidia
6864
command: ['celery', '-A', 'app.celeryapp:michaniki_celery_app', 'worker', '-l', 'info']
6965
volumes:
7066
- ./src:/opt/src

src/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM tensorflow/tensorflow:latest-gpu
1+
FROM continuumio/miniconda:4.4.10
22

33
# utils
44
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
55

6-
#RUN conda install gxx_linux-64
6+
RUN conda install gxx_linux-64
77

8-
#RUN apt-get install -y --force-yes default-libmysqlclient-dev mysql-client build-essential
8+
RUN apt-get install -y --force-yes default-libmysqlclient-dev mysql-client build-essential
99

1010
# Grab requirements.txt.
1111
COPY requirements.txt /tmp/requirements.txt

src/Dockerfile-gpu

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM tensorflow/tensorflow:1.12.0-gpu
2+
3+
# utils
4+
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
5+
6+
#RUN conda install gxx_linux-64
7+
8+
#RUN apt-get install -y --force-yes default-libmysqlclient-dev mysql-client build-essential
9+
10+
# Grab requirements.txt.
11+
COPY requirements-gpu.txt /tmp/requirements-gpu.txt
12+
13+
# Install dependencies
14+
RUN pip install -qr /tmp/requirements-gpu.txt
15+
16+
# create a user for web server
17+
RUN adduser --disabled-password --gecos "" foo
18+
19+
COPY ./ /opt/src
20+
21+
WORKDIR /opt/src

src/app/apis/SentimentV1/API_helpers_nlp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ def save_classes_label_dict(label_dict, file_path_name):
2727

2828
logging.info("* Helper: Classes Label Json Saved")
2929

30-
def download_a_dir_from_s3(bucket_name, bucket_prefix, local_path):
30+
def download_a_dir_from_s3(bucket_name, local_path):
3131
"""
3232
download the folder from S3
3333
3434
local: /src/tmp/model_data/
3535
3636
Will not download if the local folder already exists
3737
"""
38-
logging.info("* Helper: Loading Text from S3 {} {}".format(bucket_name,bucket_prefix))
38+
logging.info("* Helper: Loading Text from S3 {} ".format(bucket_name))
3939
path = os.path.join(bucket_name,'data')
4040
output_path = os.path.join(local_path, bucket_name)
4141
save_path = os.path.join(local_path, path)
@@ -72,7 +72,7 @@ def download_test_file_from_s3(bucket_name, bucket_prefix, local_path):
7272
7373
Will not download if the local folder already exists
7474
"""
75-
logging.info("* Helper: Loading Text from S3 {} {}".format(bucket_name,bucket_prefix))
75+
logging.info("* Helper: Loading Text from S3 {} ".format(bucket_name))
7676
path = os.path.join(bucket_name,'data')
7777
output_path = os.path.join(local_path, bucket_name)
7878
save_path = os.path.join(local_path, path)

src/app/apis/SentimentV1/sentimentV1.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def run_train_bert():
8484
Finetune BERT uncased small language model
8585
"""
8686
s3_bucket_name = request.form.get('train_bucket_name')
87-
model_name = request.form.get('model_name')
87+
#model_name = request.form.get('model_name')
88+
model_name = s3_bucket_name
8889
local_data_path = os.path.join('./tmp')
89-
s3_bucket_prefix = ''
9090
batch_size = 32
9191
nb_epoch = 3
9292

@@ -96,7 +96,6 @@ def run_train_bert():
9696
async_train_bert.apply_async((model_name,
9797
local_data_path,
9898
s3_bucket_name,
99-
s3_bucket_prefix,
10099
nb_epoch,
101100
batch_size,
102101
this_id), task_id=this_id)
@@ -111,9 +110,9 @@ def run_test_bert():
111110
Test sentences using BERT fine tuned model
112111
"""
113112
s3_bucket_name = request.form.get('test_bucket_name')
114-
model_name = request.form.get('model_name')
113+
#model_name = request.form.get('model_name')
114+
model_name = s3_bucket_name
115115
local_data_path = os.path.join('./tmp')
116-
s3_bucket_prefix = ''
117116
batch_size = 32
118117
nb_epoch = 3
119118

@@ -123,7 +122,6 @@ def run_test_bert():
123122
async_test_bert.apply_async((model_name,
124123
local_data_path,
125124
s3_bucket_name,
126-
s3_bucket_prefix,
127125
nb_epoch,
128126
batch_size,
129127
this_id), task_id=this_id)

src/app/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
2+
<script type=text/javascript>
3+
$(function() {
4+
$('a#test').bind('click', function() {
5+
$.getJSON('/background_process_test',
6+
function(data) {
7+
//do nothing
8+
});
9+
return false;
10+
});
11+
});
12+
</script>
13+
14+
15+
//button
16+
<div class='container'>
17+
<h3>Test</h3>
18+
<form>
19+
<a href=# id=test><button class='btn btn-default'>Test</button></a>
20+
</form>
21+
22+
</div>

src/app/tasks_nlp.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@
2828
def async_train_bert(model_name,
2929
local_data_path,
3030
s3_bucket_name,
31-
s3_bucket_prefix,
3231
nb_epoch,
3332
batch_size,
3433
id):
3534
"""
3635
train a model using BERT pre-trained model
3736
"""
3837
text_data_path = API_helpers_nlp.download_a_dir_from_s3(s3_bucket_name,
39-
s3_bucket_prefix,
40-
local_path = TEMP_FOLDER)
38+
local_path = TEMP_FOLDER)
4139

4240
logging.info('*Text Data Path:%s',text_data_path)
4341
try:
@@ -55,15 +53,13 @@ def async_train_bert(model_name,
5553
def async_test_bert(model_name,
5654
local_data_path,
5755
s3_bucket_name,
58-
s3_bucket_prefix,
5956
nb_epoch,
6057
batch_size,
6158
id):
6259
"""
6360
train a model using BERT pre-trained model
6461
"""
6562
text_data_path = API_helpers_nlp.download_test_file_from_s3(s3_bucket_name,
66-
s3_bucket_prefix,
6763
local_path = TEMP_FOLDER)
6864

6965
logging.info('*Text Data Path:%s',text_data_path)

src/requirements-gpu.txt

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
absl-py==0.2.2
2+
appnope==0.1.0
3+
asn1crypto==0.24.0
4+
astor==0.6.2
5+
aws==0.2.5
6+
awscli==1.15.38
7+
backports-abc==0.5
8+
backports.functools-lru-cache==1.5
9+
backports.shutil-get-terminal-size==1.0.0
10+
backports.weakref==1.0.post1
11+
bcdoc==0.12.2
12+
bcrypt==3.1.4
13+
bleach==1.5.0
14+
boto==2.48.0
15+
boto3==1.7.38
16+
botocore==1.10.38
17+
certifi==2018.4.16
18+
celery==4.2.0
19+
cffi==1.11.5
20+
chardet==3.0.4
21+
click==6.7
22+
colorama==0.2.5
23+
cryptography==2.2.2
24+
cycler==0.10.0
25+
decorator==4.3.0
26+
Django==1.11.15
27+
docutils==0.14
28+
enum34==1.1.6
29+
envparse==0.2.0
30+
fabric==2.1.3
31+
Flask==1.0.2
32+
funcsigs==1.0.2
33+
futures==3.2.0
34+
gast==0.2.0
35+
grpcio==1.12.1
36+
h5py==2.8.0
37+
html5lib==0.9999999
38+
idna==2.7
39+
image==1.5.24
40+
invoke==1.0.0
41+
ipaddress==1.0.22
42+
ipykernel==4.8.2
43+
ipython==5.7.0
44+
ipython-genutils==0.2.0
45+
itsdangerous==0.24
46+
Jinja2==2.10
47+
jmespath==0.9.3
48+
jupyter-client==5.2.3
49+
jupyter-core==4.4.0
50+
Keras==2.0.0
51+
Keras-Applications==1.0.2
52+
Keras-Preprocessing==1.0.1
53+
kiwisolver==1.0.1
54+
Markdown==2.6.11
55+
MarkupSafe==1.0
56+
matplotlib==2.2.2
57+
mock==2.0.0
58+
numpy==1.14.4
59+
paramiko==2.4.2
60+
pathlib2==2.3.2
61+
pbr==4.0.4
62+
pexpect==4.6.0
63+
pickleshare==0.7.4
64+
Pillow==5.1.0
65+
prettytable==0.7.2
66+
prompt-toolkit==1.0.15
67+
protobuf==3.6.0
68+
ptyprocess==0.5.2
69+
pyasn1==0.4.3
70+
pycparser==2.18
71+
Pygments==2.2.0
72+
PyNaCl==1.2.1
73+
pyparsing==2.2.0
74+
python-dateutil==2.7.3
75+
pytz==2018.4
76+
PyYAML==3.12
77+
pyzmq==17.0.0
78+
redis==2.10.6
79+
requests==2.19.0
80+
rq==0.11.0
81+
rsa==3.1.2
82+
s3transfer==0.1.13
83+
scandir==1.7
84+
scipy==1.1.0
85+
simplegeneric==0.8.1
86+
singledispatch==3.4.0.3
87+
six==1.11.0
88+
subprocess32==3.5.1
89+
tensorboard==1.8.0
90+
tensorflow-gpu==1.11.0
91+
termcolor==1.1.0
92+
tornado==5.0.2
93+
tqdm==4.26.0
94+
traitlets==4.3.2
95+
urllib3==1.23
96+
uWSGI==2.0.17
97+
wcwidth==0.1.7
98+
Werkzeug==0.14.1

0 commit comments

Comments
 (0)