Skip to content

Commit

Permalink
upgrade tensorflow to 1.15 and build gpu docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
wb14123 committed May 5, 2022
1 parent 460cb8b commit 88c135e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
FROM python:3.6-buster
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04

WORKDIR /usr/src/app

ENV DISTRO ubuntu1804
ENV CPU_ARCH x86_64
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/$CPU_ARCH/3bf863cc.pub

RUN apt-get update && apt-get install -y python3 python3-pip

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN pip3 install --upgrade "pip < 21.0"
RUN pip3 install --no-cache-dir -r requirements.txt

COPY . .
RUN apt-get install -y locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

COPY . .

CMD [ "python", "./server.py" ]
CMD [ "python3", "./server.py" ]

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Flask==1.0.2
Flask-Cors==3.0.9
gevent==1.2.2
greenlet==0.4.13
numpy==1.14.2
tensorboard==1.8.0
tensorflow==1.8.0
numpy
tensorboard==1.15
tensorflow-gpu==1.15
22 changes: 14 additions & 8 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from gevent import monkey
monkey.patch_all()

Expand All @@ -8,6 +10,8 @@
from logging.handlers import RotatingFileHandler
import logging



app = Flask(__name__)
CORS(app)

Expand All @@ -31,21 +35,23 @@ def log_setup():

log_setup()

m = Model(
None, None, None, None, vocab_file,
num_units=1024, layers=4, dropout=0.2,
batch_size=32, learning_rate=0.0001,
output_dir=model_dir,
restore_model=True, init_train=False, init_infer=True)

SPLIT_CHARS = [',', '、', ',', '.', '。', '!', '!', '?', '?', ' ']
CENSOR_WORDS_DICT = "/data/censor_words.txt"

with open(CENSOR_WORDS_DICT) as censor_words_file:
with open(CENSOR_WORDS_DICT, encoding='utf-8') as censor_words_file:
censor_words = [word[:-1] for word in censor_words_file.readlines()]
logging.info("Loaded %s censor_words" % (len(censor_words)))


m = Model(
None, None, None, None, vocab_file,
num_units=1024, layers=4, dropout=0.2,
batch_size=32, learning_rate=0.0001,
output_dir=model_dir,
restore_model=True, init_train=False, init_infer=True)


def all_same(s):
if len(s) <= 1:
return True
Expand All @@ -55,7 +61,6 @@ def all_same(s):
return True



def manual_correct_result(in_str, outputs, scores):
is_all_same = all_same(in_str)
for i in range(len(outputs)):
Expand Down Expand Up @@ -116,5 +121,6 @@ def chat_couplet_v2(in_str):
return jsonify({'output': output, 'score': score})


logging.info("Starting server ...")
http_server = WSGIServer(('', 5000), app)
http_server.serve_forever()

0 comments on commit 88c135e

Please sign in to comment.