Skip to content

Commit

Permalink
Merge codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hailiang-wang committed May 12, 2017
2 parents e1f59e8 + 1265b59 commit e48be1a
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
@@ -0,0 +1,5 @@
data
save
logs
nohup.out
config.ini
51 changes: 51 additions & 0 deletions Dockerfile.gpu
@@ -0,0 +1,51 @@
FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04

MAINTAINER Hai Liang Wang <hailiang.hl.wang@gmail.com>

# Pick up some TF dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libfreetype6-dev \
libpng12-dev \
libzmq3-dev \
pkg-config \
python \
python-dev \
python3-dev \
rsync \
software-properties-common \
unzip \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py

RUN pip install virtualenv

# create virtualenv
RUN mkdir -p /virtualenv
WORKDIR /virtualenv
RUN virtualenv --no-site-packages -p /usr/bin/python3.5 py3.5
# RUN virtualenv --no-site-packages -p /usr/bin/python2.7 py2.7

# copy data
RUN mkdir -p /deepqa2
WORKDIR /deepqa2
COPY . .

# install python modules
RUN . /virtualenv/py3.5/bin/activate && \
pip --no-cache-dir install -r requirements.txt

# Install tensorflow
RUN export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc2-cp35-cp35m-linux_x86_64.whl && \
. /virtualenv/py3.5/bin/activate && \
pip install $TF_BINARY_URL


# ENTRYPOINT ["source", "/virtualenv/py3.5/bin/activate", "&&", "python"]
CMD []
28 changes: 23 additions & 5 deletions README.md
@@ -1,10 +1,14 @@
# deprecated
# Note, this repo is deprecated.

If you are interested in further enhancements and investigations, just watch *Next* repo.

[https://github.com/Samurais/Neural\_Conversation\_Models](https://github.com/Samurais/Neural_Conversation_Models)

# Approaching a Chatbot Service
[![Join the chat at https://gitter.im/chatbot-pilots/DeepQA](https://badges.gitter.im/chatbot-pilots/DeepQA.svg)](https://gitter.im/chatbot-pilots/DeepQA?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Docker Pulls](https://img.shields.io/docker/pulls/samurais/deepqa2.svg?maxAge=2592000)](https://hub.docker.com/r/samurais/deepqa2/) [![Docker Stars](https://img.shields.io/docker/stars/samurais/deepqa2.svg?maxAge=2592000)](https://hub.docker.com/r/samurais/deepqa2/) [![Docker Layers](https://images.microbadger.com/badges/image/samurais/deepqa2.svg)](https://microbadger.com/#/images/samurais/deepqa2)

![](http://7xkeqi.com1.z0.glb.clouddn.com/ai/Screen%20Shot%202017-04-04%20at%208.20.47%20PM.png)

[Part 1: Introduction](http://www.leiphone.com/news/201702/O9PGyImfH1Vq3fxV.html)

[Part 2: Bot Engine](http://www.leiphone.com/news/201702/oY07cF3HVIp7Yo1s.html)
Expand All @@ -13,9 +17,6 @@ If you are interested in further enhancements and investigations, just watch *Ne

> This repository is align with **Part 3: Bot Model**.
# DeepQA2
[![Join the chat at https://gitter.im/chatbot-pilots/DeepQA](https://badges.gitter.im/chatbot-pilots/DeepQA.svg)](https://gitter.im/chatbot-pilots/DeepQA?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Train and serve QA Model with TensorFlow

Tested with TensorFlow#0.11.0rc2, Python#3.5.
Expand All @@ -30,6 +31,12 @@ Inspired and inherited from [DeepQA](https://github.com/Conchylicultor/DeepQA/is
pip install -r requirements.txt
```

# Install TensorFlow
```
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc2-cp35-cp35m-linux_x86_64.whl
pip install —-upgrade $TF_BINARY_URL
```

# Pre-process data
Process data, build vocabulary, word embedding, conversations, etc.
```
Expand Down Expand Up @@ -69,4 +76,15 @@ response
"rc": 0,
"msg": "hello"
}
```
```

# Train with Docker
## Install
* [docker](https://docs.docker.com/engine/installation/linux/ubuntu/)
* [nvidia-docker](https://github.com/NVIDIA/nvidia-docker)
## Train
```
docker pull samurais/deepqa2:latest
cd DeepQA2
./scripts/train_with_docker.sh
```
1 change: 0 additions & 1 deletion requirements.txt
Expand Up @@ -10,6 +10,5 @@ munch==2.1.0
nltk==3.2.1
numpy==1.11.3
six==1.10.0
tensorflow==0.11.0rc2
terminado==0.6
tqdm==4.10.0
15 changes: 15 additions & 0 deletions scripts/build_docker_image.sh
@@ -0,0 +1,15 @@
#! /bin/bash
###########################################
#
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
rootDir=$baseDir/..
# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $rootDir
docker build -f Dockerfile.gpu -t samurais/deepqa2:latest .
# --force-rm=true
42 changes: 42 additions & 0 deletions scripts/train_with_docker.sh
@@ -0,0 +1,42 @@
#! /bin/bash
###########################################
# Start train with docker
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
rootDir=$baseDir/..

# functions
function printUsage(){
echo "Usage:"
echo "$0 -d # This would run the docker in detached mode."
echo "$0 -t # This would run the docker in not-attached mode."
}

function main() {
cd $rootDir
nvidia-docker run --name deepqa2 \
-v $rootDir/save:/deepqa2/save \
-v $rootDir/logs:/deepqa2/logs \
-v $rootDir/data:/deepqa2/data \
-v $rootDir/config.ini:/deepqa2/config.ini \
-v $rootDir/start_training_docker.sh:/deepqa2/start_training_docker.sh \
$* samurais/deepqa2:latest \
"./start_training_docker.sh"
}

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
if [ "$#" -eq "0" ]
then
printUsage
elif [ "$*" = "-t" ]
then
main -t -i --rm
elif [ "$*" = "-d" ]
then
main -d
else
printUsage
fi
14 changes: 14 additions & 0 deletions start_training_docker.sh
@@ -0,0 +1,14 @@
#! /bin/bash
###########################################
#
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir
. /virtualenv/py3.5/bin/activate
python deepqa2/train.py

0 comments on commit e48be1a

Please sign in to comment.