How to Run Google TensorFlow on Alibaba Cloud

Hosting TensorFlow using Docker on Alibaba Cloud

What Are We Going to Be Building?

  1. How to use Python and TensorFlow to train an image classifier
  2. How to classify images with your trained classifier
  1. A basic understanding of Linux commands
  2. Alibaba Cloud account

1. Install Docker on Ubuntu 16.04

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release-cs) stable"
sudo apt-get update
apt-cache policy docker-ce
Output of apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 17.03.1~ce-0~ubuntu-xenial
Version table:
17.03.1~ce-0~ubuntu-xenial 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
17.03.0~ce-0~ubuntu-xenial 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
sudo apt-get install -y docker-ce
sudo systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-05-01 06:53:52 CDT; 1 weeks 3 days ago
Docs: https://docs.docker.com
Main PID: 749 (docker)

2. Setup TensorFlow Docker Image on Alibaba Cloud

$ docker pull nikeshgogia/tensorflow:1.0
$ docker images
root@iZt4neefbpoojkuy4fdvqzZ:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nikeshgogia/tensorflow 1.0 ed0ee8133d06 26 minutes ago 1.62GB

3. Starting and Entering TensorFlow Container

docker run -it --publish 6006:6006 -p 80:5000 --volume ${HOME}/tf_files:/tf_files --workdir
/tf_files nikeshgogia/tensorflow:1.0 bash
root@17e62932b5b5:/tf_files#

4. Training and Testing Your Model

root@17e62932b5b5:/tf_files# ls -l
total 16
drwxr-xr-x 4 root root 4096 Nov 16 03:37 lights
drwxr-xr-x 2 root root 4096 Nov 16 03:37 testimages
drwxr-xr-x 6 root root 4096 Nov 16 03:37 tf
IMAGE_SIZE=224
ARCHITECTURE="mobilenet_0.50_${IMAGE_SIZE}"
python -m scripts.retrain \
--bottleneck_dir=/trained_files/bottlenecks \
--how_many_training_steps=500 \
--model_dir=/trained_files/models/ \
--summaries_dir=/trained_files/training_summaries/"${ARCHITECTURE}" \
--output_graph=/trained_files/retrained_graph.pb \
--output_labels=/trained_files/retrained_labels.txt \
--architecture="${ARCHITECTURE}" \
--image_dir=/tf_files/lights
python -m scripts.label_image \
--graph=/trained_files/retrained_graph.pb \
--image=/tf_files/testimages/l1.jpeg
light on 0.999999
light off 1.37755e-06

Conclusion

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Alibaba Cloud MVPs at the Apsara Conference 2019 — Leading, Sharing, and Changing

Capturing container traffic on Kubernetes

Text Wrap For Mac

GAMI V2: A SNEAK PEEK TO OUR EVOLUTION

Overview of Migrating Apps to the Cloud

The Agile methodology — Zomato Application

Python: GUI programming with Tkinter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

What is Apache Kafka?

Creating DAG in Apache Airflow

Install and configure Elastic Stack — II

Apache Kafka 101