Table of Contents
TensorFlow 2.0.0-beta1 is available now and ready for testing. What if you want to try it but don't want to mess with doing an NVIDIA CUDA install on your system. The official TensorFlow install documentations has you do that, but it's really not necessary.
What I will present in this post will give you a simple way to setup TensorFlow 2.0.0-beta1 on Windows 10 or Linux. It's essentially the same in both OS's.
Note: TensorFlow 2 can be installed using the ideas presented below but you will need to start with the Anaconda tensorflow-gpu=1.13.1 package in order to get the correct version of CUDA and cuDNN [Anaconda tensorflow-gpu=14.0 is using CUDA 10.1 which will fail with TF2]
To start with a new env do,
conda create –name tf2-gpu
coda activate tf2-gpu
conda install tensorflow-gpu=1.13.1
pip install tensorflow-gpu==2.0
… That will add the correct support packages (CUDA) that TF2 needs and then the pip install of TF2 will supperceed the 1.13.1 package.
The basic idea
I'm using Anaconda Python which has largely become "the" standard Python distribution for data-science, ML/AI and scientific computing. It's not perfect but it's nicely done. Your opinion may differ and I understand reasons for that, but I still find it pretty easy to recommend Anaconda Python.
Installing TensorFlow with GPU support using Anaconda Python is as simple as creating an "env" for it and then a simple install command.
conda create --name tf-gpu conda activate tf-gpu conda install tensorflow-gpu
That gives you a full install including the needed CUDA and cuDNN libraries all nicely contained in that env.
I was looking at the install documentation for the TensorFlow 2.0.0-beta1 and saw that it was still being built with links to CUDA 10.0 and cuDNN 7.x. That is the same dependencies as TensorFlow-GPU 1.13.1 Which is the current (official) packaged version on Anaconda cloud. [Version 1.14 is now available in the CPU package and the GPU version will likely update to this soon too. I assume the CUDA dependencies will remain the same for the time being but please do check that!]
We will use the TensorFlow 1.13.1 env as a base for the install of TensorFlow 2.0.0-beta1 i.e. we'll do TensorFlow-gpu install with "conda" and then a "pip" install of TensorFlow 2.0.0-beta1. Easy!
Install Anaconda Python and tensorflow-gpu
I'm going to refer you to some recent posts for doing this.
For Windows 10 look at How to Install TensorFlow with GPU Support on Windows 10 (Without Installing CUDA) UPDATED!. That post is very detailed and should get you up and running with Anaconda Python and the current version of TensorFlow with CUDA GPU support. I recommend that Linux users take a look at this post too since it is up-to-date and has general information in it.
An older post that is still relevant for Linux users is, Install TensorFlow with GPU Support the Easy Way on Ubuntu 18.04 (without installing CUDA). This post is a over a year old now but still mostly OK. I have some updated notes in it. Really, it's pretty straight forward getting Anaconda Python installed on Linux and the information in the Windows 10 post is pertinent as well, read that even if you are using Linux.
This is pretty straight forward and those guides above will walk you thought it if needed. Download the Anaconda installer, run it, accepting defaults and add the optional "PATH" setup. Then look at the Windows 10 post mentioned above to see how to update everything, setup an "env", install TensorFlow-GPU 1.13.1 and setup things for Jupyter notebook. Then test that to make sure everything is working OK.
Clone your TensorFlow-GPU 1.13 (or .14) env and “pip” install TensorFlow-GPU 2.0.0-beta1
I am assuming you have have a working TensorFlow-GPU 1.13(or .14) working and installed in an env named "tf-gpu".
Clone the existing tf-cpu env and call it tf-gpu-2beta1,
conda create --name tf-gpu-2beta1 --clone tf-gpu
Next activate the new env and use "pip" in that conda environment to instal the new TensorFlow-GPU 2.0.0-beta1
conda activate tf-gpu-2beta1
pip install tensorflow-gpu==2.0.0-beta1
You now have a base with most of the dependencies including CUDA from the original TensorFlow-GPU install and pip will pull down the new TensorFlow 2.0.0-beta1 package along with any other dependencies that were not already present. The old TensorFlow will still be in the env but when you "import tensorflow" you get the newest version in the env, which will be 2.0.0-beta1.
That's it! You now have the first beta of TensorFlow 2.0 installed with CUDA support for your NVIDIA GPU.
To create a Jupyter kernel for that new env you ca do this,
make sure ipykernel and Jupyter are installed (assuming you still have tf-gpu-2beta1 activated)
conda install ipykernel jupyter
create the kernel for Jupyter notebooks
python -m ipykernel install --user --name tf-gpu-2beta1 --display-name "TensorFlow-GPU-2.0-beta1"
A quick test
First you can list the packages in your "activated" tf-gpu-2beta1 env,
Along with a lot of other packages you will see,
... cudatoolkit 10.0.130 0 cudnn 7.6.0 cuda10.0_0 ... tensorflow-gpu 2.0.0b1 pypi_0 pypi ...
A quick test from the command line (I'm using Powershell on Windows 10 right now to check this on my laptop as I write this post.)
With tf-gpu-2beta1 still activated the following will print out a constant "Hello tf.__version__" using eger execution which is default in TensorFlow 2.
python import tensorflow as tf print( tf.constant( 'Hellow from TensorFlow ' + tf.__version__ ) )
Here's what that Powershell session looks like including the output that shows my active NVIDA GTX1060 GPU on this laptop and the TensorFlow version.
PS>conda activate tf-gpu-2beta1 Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> print( tf.constant( 'Hellow from TensorFlow ' + tf.__version__ ) ) 2019-06-25 16:39:58.943121: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll 2019-06-25 16:39:59.805979: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties: name: GeForce GTX 1060 with Max-Q Design major: 6 minor: 1 memoryClockRate(GHz): 1.3415 pciBusID: 0000:01:00.0 2019-06-25 16:39:59.814565: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check. 2019-06-25 16:39:59.819875: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0 2019-06-25 16:39:59.824079: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2019-06-25 16:39:59.831704: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties: name: GeForce GTX 1060 with Max-Q Design major: 6 minor: 1 memoryClockRate(GHz): 1.3415 pciBusID: 0000:01:00.0 2019-06-25 16:39:59.838581: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check. 2019-06-25 16:39:59.844679: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0 2019-06-25 16:40:00.773606: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-06-25 16:40:00.779446: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0 2019-06-25 16:40:00.782123: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N 2019-06-25 16:40:00.786023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4712 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 with Max-Q Design, pci bus id: 0000:01:00.0, compute capability: 6.1) tf.Tensor(b'Hellow from TensorFlow 2.0.0-beta1', shape=(), dtype=string)
Have fun trying TensorFlow 2 beta1 with GPU support. This is a major update to TensorFlow and it looks like it will be great!
Happy Computing! –dbk @dbkinghorn
Puget Systems offers a range of powerful and reliable systems that are tailor-made for your unique workflow.
Why Choose Puget Systems?
Rather than getting a generic workstation, our systems are designed around your unique workflow and are optimized for the work you do every day.
By keeping inventory of our most popular parts, and maintaining a short supply line to parts we need, we are able to offer an industry leading ship time.
We make sure our representatives are as accessible as possible, by phone and email. At Puget Systems, you can actually talk to a real person!
Puget Systems Hardware Partners