Build Tensorflow from Source with Swig and Bazel without Root

Sometimes we may need to install Tensorflow from source without root access to the server, such as a cluster environment. This is even more true when you need to configure Tensorflow with your own environment: e.g., different Cuda and CuDNN versions. This post describes how to compile Bazel, Swig from source, and use them to compile Tensorflow.

Continue reading “Build Tensorflow from Source with Swig and Bazel without Root”

Notes on Transitioning to TensorFlow 1.0

Tensorflow 1.0 is awesome, many nice features, including GridLSTM, LayerNormalization, CRF, etc. There is even a transitioning script that helps automatically converts your file from 0.x to 1.x. However, the official transitioning script does not include many changes that need to be made in my previous LSTM code. This post will list the changes that I discovered, and I hope it will make your life easier. If you have other problems, search the function name in the new API, you should find the corresponding new version. Note that sometimes the order of parameters may differ.

tf.nn.rnn_cell -> tf.contrib.rnn
tf.nn.seq2seq -> tf.contrib.legacy_seq2seq

virtualenv cannot find module in site-packages

My Tensorflow mysteriously failed at the server. Without root access, I have to compile it from the source, to configure the GPU device. The error is module not found. Tried to pip install the module multiple times, but it still does not work. I can see the package in my site-packages directory, changed access to executable, but still not working.

It turns out that, I have set the PYTHONPATH variable in my ~/.bashrc, and pip installed packages to that specified directory. When I was trying to import the package, it could not find from the virtualenv directories. After removed the PYTHONPATH from my ~/.bashrc, everything works like a charm.

Not able to connect to Google Compute Engine on port 22

Google has provided its infrastructure via Google Cloud Platform to developers for building applications, as an alternative to Amazon Web Service. The setup of a new instance is simple and intuitive, however, it is frustrating not being able to connect to the instance via ssh. After some research, I found out how to resolve the problem, and I hope it can help others who are having the same issue.

The Problem
Connection Failed: We are not able to connect to the VM on port 22.
I could not even telnet IP 22

The Solution
1. Activate Google Cloud Shell
2. Add a rule to the firewall to allow traffic from port 22:
gcloud compute firewall-rules create allowssh –allow tcp:22 –source-ranges