Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jayant91089/0cdac8edf6ab7b0d87858b96280e5fbc to your computer and use it in GitHub Desktop.
Save jayant91089/0cdac8edf6ab7b0d87858b96280e5fbc to your computer and use it in GitHub Desktop.
Installing tensorflow on cpu machine with user access only.

Recently tried this in a CPU-only situation with UBUNTU 14.04 LTS (Trusty). Omitted the GPU parts of the script and had to modify it a bit to get it working. Below is the version that worked for me:

Set up java (dependency for Bazel) Download jdk 8, for most recent version, go here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

mkdir jdk
cd jdk

Following wget gives 'ERROR: 403 Forbidden', so just go to the oracle page to get the tarball.

wget https://s3-us-west-2.amazonaws.com/minjoon/jdk/jdk-8u74-linux-x64.gz 
tar -zxvf jdk-8u74-linux-x64.gz
cd ..

Set up environment variables:

echo export JAVA_HOME="$HOME/jdk/jdk1.8.0_74" >> ~/.bashrc
echo export PATH="$JAVA_HOME/bin:$PATH" >> ~/.bashrc
source ~/.bashrc

Install Bazel. I had to change the version of bazel to 0.4.2 ( 0.2.0 used in seminjon's script, but it was giving trouble later). I recommend you substitute the latest version number of bazel below, at the time of your installation.

wget https://github.com/bazelbuild/bazel/releases/download/0.4.2/bazel-0.4.2-installer-linux-x86_64.sh
chmod +x bazel-0.4.2-installer-linux-x86_64.sh
./bazel-0.4.2-installer-linux-x86_64.sh --user

Custom Python install

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar -zxvf Python-2.7.11.tgz
cd Python-2.7.11
./configure --prefix $HOME
make
make install
cd ..

Custom Python3 install

wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar -zxvf Python-3.5.1.tgz
cd Python-3.5.1
./configure --prefix $HOME
make
make install
cd ..
pip3 install wheel  # for tensorflow wheel installation
echo export PATH="$HOME/bin:$PATH" >> ~/.bashrc
source ~/.bashrc

Install pip

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

Install wheel pip install wheel

Numpy install pip install numpy

Swig install (download the file and extract, and then cd to the folder)

wget https://s3-us-west-2.amazonaws.com/minjoon/swig/swig-3.0.8.tar.gz
tar -zxvf swig-3.0.8.tar.gz
cd swig-3.0.8/
./configure --prefix $HOME
make
make install
cd ..

If you want to use prebuilt pip package, # pip3.4 install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.7.1-cp34-none-linux_x86_64.whl Download TensorFlow source code mkdir workspace cd workspace git clone --recurse-submodules https://github.com/tensorflow/tensorflow cd tensorflow ./configure

Install! No need to deal with tensorflow/tensorflow#706 (issue is closed now, messing with _py_wrap_cc_impl() gives error). So with local Swig, just use first instead of second line below

# bazel build -c opt --genrule_strategy=standalone --spawn_strategy=standalone //tensorflow/tools/pip_package:build_pip_package
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip install /tmp/tensorflow_pkg/NEWLY_CREATED_WHL_FILE 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment