Blog post explaining it all Run Tensorflow scripts from Node.js server deployed on AWS as Docker container
Character generator using recurrent neural network (RNN). Also Node.js server used to provide HTTP API for training RNN and then generating samples from saved checkpoints.
Forked from hzy46/Char-RNN-TensorFlow
and is in separate directory (generator/
) now to avoid confusion. It has its own documentation
in generator/README.md
.
Trivial Node.js server used to store incoming training data and call python
scripts to train
and generate text. Read about it in server/README.md
Both server
and generator
are expected to run in Docker
and running image locally would replicate production environment.
You could also run server directly but then need to be sure that all
python dependencies are installed locally.
You will need to have MySQL database running with the schema provided in mysql_setup/
Via prepared script
$ ./runDockerImage.sh
Manually
- To
build
container image:docker build -t <some_name> .
- To
run
above image:
docker run --rm -ti \
-e "MYSQL_HOST=docker.for.mac.localhost" \
-e "MYSQL_USER=root" \
-e "MYSQL_PASSWORD=" \
-e "MYSQL_DATABASE=rnn_generator" \
-p 8080:8080 <some_name>
Tip: If you want to keep trained models and uploads between runs then map local volume/directory when starting Docker container:
docker run --rm -ti \
-v /change/location/models:/app/generator/model \
-v /change/location/uploads:/app/server/uploads \
-p 8080:8080 <some_name>
New virtualenv
- Create new environment in dir
venv
-$ virtualenv -p python3 venv
- Activate environment -
$ source venv/bin/activate
- Install dependencies -
(venv) $ pip install -r generator/requirements.txt
Existing virtualenv
- Activate environment -
$ source venv/bin/activate
- Use Node.js
v10
(venv) $ nvm use 10
run
server(venv) $ node server/server
This example does not have Tensorflow with GPU support. If you want to use GPU do one of the following:
- change Tensorflow dependency in generator/requirements.txt to the one that supports GPU, ie:
tensorflow-gpu==1.14
- change base Docker image to include Tensorflow with GPU:
FROM tensorflow/tensorflow:1.14.0-gpu-py3
Deployment to AWS was removed in commit https://github.com/ivarprudnikov/char-rnn-tensorflow/commit/040a93a46e674bb6be71d6cbe1b199142f98d19f
You are free to open issues if there is anything bothering you.