lukalabs / cakechat

CakeChat: Emotional Generative Dialog System
Apache License 2.0
1.7k stars 935 forks source link

Installing on Google Cloud Platform #69

Closed sheldonrampton closed 5 years ago

sheldonrampton commented 5 years ago

I was able to successfully install cakechat on my laptop (Mac OSX), but I ran into error messages when I tried installing it on Google Cloud Platform. Could you help with this or update your README to include instructions for running it there?

nicolas-ivanov commented 5 years ago

@sheldonrampton, unfortunately, we are unable to provide such an update since we do not work with Google Cloud Platform at the moment.

sheldonrampton commented 5 years ago

OK, thanks for the prompt response. I asked Google support for some advice, and they may have given me what I need to get it working. If I get it figured out, I'll post instructions here.

sheldonrampton commented 5 years ago

Here's what I've figured out so far. # 1, it's easier to get this running if I use Google Cloud Platform's "Compute Engine" service instead of its "App Engine" service which what I was trying to use initially.

Google Cloud Platform has two options for setting up server-based applications: App Engine and Compute Engine. App Engine is often the easiest way to go because it handles a lot of server setup, configuration and deployment. However, Compute Engine is more flexible and basically lets you provision a Google-hosted virtual machine running whatever operating system and software you want, but you have to do more of the setup and configuration manually. After looking at the issues I was happening using App Engine, the Google support person advised, "Due to the complexity of this software and the capability to use a GPU, I recommend you try to deploy cakechat using a Compute Engine VM instance. I think that is a better option because it offers more flexibility when you are developing complex services. Also, the use of GPUs is not possible on App Engine."

Here are the steps I went through using Compute Engin:

Provision a Compute Engine VM instance

To create the VM with a GPU, I first had to upgrade from my free Google Cloud Platform account and then define a quota that allowed me to provision VMs with GPUs. To set the quota, I went to the "Identity and Access Management" (IAM) section: IAM & admin >> Quotas where I selected Compute Engine API >> GPUs (all regions) and set the quota to 5 instead of 0. I received a message in the web interface that said the quota change request would be reviewed, and when I came back to my computer 12 hours later, I had the quota of 5 GPUs and was able to proceed with creating the VM. I created it with the following specifications:

I then was able to SSH into the VM and proceed with installing git, Python 3 and other requirements.

Install git and clone cakechat

sudo apt-get update
sudo apt-get install git
git clone https://github.com/lukalabs/cakechat.git

Install python 3

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
curl -O https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
tar -xf Python-3.7.4.tar.xz
cd Python-3.7.4
./configure --enable-optimizations
make
sudo make altinstall
python3.7 --version
cd ../

Install pip

sudo apt install python3-pip
pip3 --version

Install cakechat requirements and run cakechat server

cd cakechat
pip3 install -r requirements.txt -r requirements-local.txt
python3 bin/cakechat_server.py

This produced a bunch of output, including the following:

Using TensorFlow backend.
2019-09-06 02:47:34.680241: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not co
mpiled to use: AVX2 FMA
...
* Serving Flask app "cakechat.api.v1.server" (lazy loading)
* Environment: production
  WARNING: Do not use the development server in a production environment.
  Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)

I then opened a second SSH session with the VM and ran the test:

python3 tools/test_api.py -f localhost -p 8080 -c "hi!" -c "hi, how are you?

This produced responses like the following:

" -c "good!" -e "joy"
Using TensorFlow backend.
{'response': 'Good to know!'}
nicolas-ivanov commented 5 years ago

@sheldonrampton thanks a lot for the detailed instruction! Seems like you got it working.