Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF 1.12.0, CPU/GPU, CUDA 9.0, CuDNN 7.4, Python 3.5, Ubuntu 16.04, Skylake, -AVX, +SSE4 #99

Open
2 tasks done
bzamecnik opened this issue Feb 18, 2019 · 6 comments
Open
2 tasks done

Comments

@bzamecnik
Copy link

bzamecnik commented Feb 18, 2019

Recent build with and without GPU, without AVX for Ubuntu 16.04.

CPU/GPU AVX/AVX2/FMA SSE4.1/SSE4.2 link md5
GPU no yes download 5d9fb5aee87456d5c0f1915b16844769
CPU no yes download df616627cfcbe47d77df7f8628611b9e
GPU no no download 61e1081971626bccc047ea773a0f2eed

Compiled on Intel Pentium G4400 (Skylake) without AVX/FMA instructions.

  • TensorFlow 1.12.0 GPU
  • Ubuntu 16.04 (libc6-2.23)
  • Python 3.5
  • CUDA 9.0
  • CuDNN 7.4
  • NCCL 1.3
  • Bazel 0.19.2
  • compute capabilities 5.2 (Maxwell), 6.1 (Pascal)

Successfully tested with Keras 2.2.4 on GTX 980 Ti.

Instructions

Install the Bazel build tool:

* For TF 1.12 use Bazel 0.19.1 (recommended 0.15.0)
open https://docs.bazel.build/versions/master/install-ubuntu.html
# use binary installer (recommended)
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
# download from https://github.com/bazelbuild/bazel/releases (~ 160 MB)
BAZEL_VERSION=0.19.2
BAZEL_INSTALLER=bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/${BAZEL_INSTALLER}
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/${BAZEL_INSTALLER}.sha256
shasum -a 256 -c -b ${BAZEL_INSTALLER}.sha256 
# bazel-0.19.2-installer-linux-x86_64.sh: OK
chmod +x ${BAZEL_INSTALLER}
./${BAZEL_INSTALLER} --user
# set in ~/.bashrc
export PATH="$PATH:$HOME/bin"
 source /home/bza/.bazel/bin/bazel-complete.bash
# check it
bazel version

Build:

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow/
git checkout v1.12.0
# install deps
# Python 3.5 on Ubuntu 16.04
sudo apt install python3-dev python3-pip
# NVIDIA - given the ML deb repo
sudo apt remove libcudnn6 libcudnn6-dev
sudo apt install libcudnn7 libcudnn7-dev
/usr/lib/x86_64-linux-gnu/
# python virtual env + dependencies
mkvirtualenv tf-build
pip install -U pip six numpy wheel mock
pip install -U keras_applications==1.0.6 --no-deps
pip install -U keras_preprocessing==1.0.5 --no-deps
# not in the guide, but missing in the tests
pip install -U scipy scikit-learn portpicker
./configure
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/lib/x86_64-linux-gnu
# Do you wish to build TensorFlow with CUDA support? [y/N]: y
# Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 9.0]:
# Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 
# Do you wish to build TensorFlow with TensorRT support? [y/N]: n
# Please specify the NCCL version you want to use. If NCCL 2.2 is not installed, then you can use version 1.3 that can be fetched automatically but it may have worse performance with multiple GPUs. [Default is 2.2]: 1.3
# Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
# Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 5.2]: 5.2,6.1

# without this export it was not working
export TF_NEED_CUDA="1"
bazel build -c opt \
            --config=cuda \
            //tensorflow/tools/pip_package:build_pip_package

# INFO: Elapsed time: 16706.700s, Critical Path: 190.08s, Remote (0.00% of the time): # [queue: 0.00%, setup: 0.00%, process: 0.00%]
# INFO: 14075 processes: 14075 local.
# INFO: Build completed successfully, 16607 total actions
# real    278m28.498s (4:38 h)
# Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
mv /tmp/tensorflow_pkg/tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl ~

pip install --no-cache-dir ~/tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl

Test it:

cd
git clone https://github.com/keras-team/keras.git
cd keras/examples
python mnist_cnn.py

Troubleshooting

Default GCC flag is -march=native, so on my CPU (without AVX) AVX will be disabled. If cross-compiling on another CPU with AVX, we can disable it explicitly:

bazel build --config=opt \
            --config=cuda \
            --copt=-no-mavx \
            --copt=-no-mavx2 \
            --copt=-no-mfma \
            //tensorflow/tools/pip_package:build_pip_package

Another build (with explicitly enabled SSE4 and with -D_GLIBCXX_USE_CXX11_ABI=0):

time bazel build -c opt \
            --config=cuda \
            --copt=-mno-avx \
            --copt=-mno-avx2 \
            --copt=-mno-fma \
            --copt=-msse4.1 \
            --copt=-msse4.2 \
            --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
            //tensorflow/tools/pip_package:build_pip_package

Another build was without CUDA:

unset TF_TF_NEED_CUDA
bazel clean
./configure
# ... build as above

Compute capabilities:

  • 5.2 - Maxwell 9xx series (including GeForce GTX 980 Ti)
  • 6.1 - Pascal 10xx series

TODO:

@bzamecnik bzamecnik changed the title TF 1.12.0, GPU, CUDA 9.0, CuDNN 7.4, Python 3.5, Ubuntu 16.04, Skylake, no AVX TF 1.12.0, CPU/GPU, CUDA 9.0, CuDNN 7.4, Python 3.5, Ubuntu 16.04, Skylake, -AVX, +SSE4 Feb 19, 2019
@fightthepower
Copy link

Dude many thanks. I have searched all the web for this wheel for my old computer. Thanks for taking your time and building one.

@nateraw
Copy link

nateraw commented Apr 17, 2019

THANK YOU

Been trying for a year to get a newer version than tensorflow v1.5 working. This is the first thing that has worked. 🎉

@bzamecnik
Copy link
Author

Should I build also 1.13?

@nateraw
Copy link

nateraw commented Apr 17, 2019

@bzamecnik As of right now, I'm too afraid to update CUDA to work with 1.13 (like I said, it took me way to long to get this working), so I likely will not be able to test for you. I'm sure others in the community would love that contribution, though.

@atoultaro
Copy link

I really really appreciate this build. Now my old Xeon desktop can finally use tensorflow with version > 1.5. What a leap to 1.12! Thanks!!

@fightthepower
Copy link

@bzamecnik Hey tensorflow 2 has released can you please make a wheel for this version cpu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants