Installing TensorFlow 2.0 in Anaconda Environment

Posted by Rahmad Sadli on December 27, 2019 in Deep Learning, Machine Learning, Object Detection, Python Programming
TensorFlow 2 in Anaconda

TensorFlow is still one of the popular Deep learning frameworks. It has been used in many different fields of applications including handwritten digit classification, image recognition, object detection, word embeddings, and natural language processing (NLP).

In September last year, 2019, Google finally announced the availability of the final release of TensorFlow 2.0. With eager execution by default and tight integration with Keras, now TensorFlow 2.0 makes the development of machine learning applications much easier than before.

We can now easily debug TensorFlow’s variables and print their values just like in the standard Python. That’s way, TensorFlow 2.0 is more friendly than the older version 1.x.

For those of you who don’t have prior experience with this topic, this post is special for you. Here, I’m going to show you how to install TensorFlow 2.0 in Anaconda.

What is Anaconda and why I recommend it?

Anaconda is a Python-based data processing built for data science. It comes with many useful built-in third-party libraries. Installing Anaconda meaning installing Python with some commonly used libraries such as Numpy, Pandas, Scrip, and Matplotlib.

For a Python developer or a data science researcher, using Anaconda has a lot of advantages, such as independently installing/updating packages without ruining the system. So, we no need to worry about the system library or anything like that. This can save time and energy for other things.

Anaconda can be used across different platforms, Windows, macOS, and Linux. If we want to use a different Python version or package libraries, just create a different environment and play around without any risk of crashing the system library.

Now, let’s install Anaconda first.

Installing Anaconda

Anaconda is available for Windows, Mac OS X, and Linux, you can find the installation file in the anaconda official site. I suggest you choose the Python version 3.7 64-bit installer if you have a 64-bit machine, otherwise choose the 32-bit installer, instead. If you need, you can easily install Python 2.7 versions later.

In case you have already installed Python on your computer, don’t worry, it won’t ruin anything. Instead, the default Python used by your programs will be the one that comes with Anaconda. Go ahead and choose the appropriate version, follow the instructions and install it.

I will let you explore it, but anyhow, if you have any problem, you can simply post a comment in the comment section and I will try to do my best for you.
(Note: For more details on how to use Anaconda, you can visit the Anaconda user guide here).

Now, we’re going to create our first environment, but be sure that you’ve installed Anaconda on your computer.

Creating an Environment

Open Anaconda prompt, and create a new environment called yolov3_tf2 ( I gave this name because it relates to my next article about the implementation of YOLOv3 in TensorFlow 2.0). You can name it whatever you want. Just type or copy the following command to your Anaconda prompt and hit Enter.

conda create -n yolov3_tf2 python=3.7

After that, you will be prompted something like this, just type ‘y‘ and then hit the Enter.
Note: you might be prompted a bit different to this, it doesn’t matter just hit Enter, Anaconda will do the best for you.

Installing Anaconda

Wait until all packages installed successfully, and then you can activate your new Anaconda environment.
Copy and paste this command to your Anaconda prompt and hit Enter.

conda activate yolov3_tf2
Activating Anaconda environment

Now, your Conda’s environment is ready to use. Let’s install TensorFlow 2.0.

Installing TensorFlow 2.0

When you are in the yolov3_tf2 environment, now you can install any package you want. To install TensorFlow 2.0, type this command and hit Enter.

GPU:

conda install -c conda-forge tensorflow-gpu=2.0

CPU:

conda install -c conda-forge tensorflow=2.0

Verify the Cuda toolkit and cudnn that will be installed, it must come with Cudatoolkit 10 and cudnn 7.6. If everything goes right, just type ‘y’ and hit Enter.

TensorFlow GPU

Your TensorFlow installation is now complete. To verify if it has been installed correctly, Type python in Anaconda command prompt and hit Enter. Ensure that the Python version is 3.7. Then, type import tensorflow as tf and press Enter. Finally, type tf.version and press Enter. If TensorFlow is installed correctly, you will not receive any errors. Otherwise, you will need to reinstall it.”

If the installation has been successful, you will get a result similar to the one shown in the figure below. Your TensorFlow version should be ‘2.0.0’

Verify TensorFlow installation

That’s it for this tutorial. Until next time. Be sure to check out my tutorial on YOLOv3 object detection as well.

Leave a Reply

Your email address will not be published. All fields are required

What others say

  1. Terrific post but I was wondering if you could write a litte more on this subject?
    I’d be very thankful if you could elaborate a little
    bit further. Many thanks!

  2. Thanks for any other great article. Where else may just anyone get that kind of info
    in such a perfect manner of writing? I’ve a presentation subsequent week, and I’m on the search for such info.

  3. Oh my goodness! Impressive article dude! Thank you so much, However I am experiencing difficulties with your RSS.

    I don’t know why I can’t subscribe to it. Is there anyone else having the same RSS issues?
    Anyone that knows the answer can you kindly respond?
    Thanx!!

  4. Oh my goodness! Impressive article dude! Thank you, However
    I am encountering problems with your RSS. I don’t know the reason why I can’t subscribe to it.
    Is there anybody else having similar RSS issues?
    Anyone who knows the answer will you kindly respond?
    Thanx!!

  5. I do trust all of the concepts you’ve presented in your post.
    They’re really convincing and will definitely work. Still, the posts are too short for novices.
    May just you please prolong them a bit from next time?
    Thank you for the post.

  6. Hi there I am so grateful I found your weblog, I really
    found you by error, while I was searching on Aol for something else,
    Anyhow I am here now and would just like to say thanks a lot for
    a fantastic post and a all round interesting
    blog (I also love the theme/design), I don’t have time to go through it all at the
    moment but I have bookmarked it and also added your RSS feeds, so when I
    have time I will be back to read more, Please do keep up the fantastic jo.

  7. It is actually a nice and helpful piece of information. I
    am satisfied that you simply shared this useful information with us.

    Please keep us up to date like this. Thank you for sharing.

  8. It is the best time to make some plans for the future and
    it’s time to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or advice.
    Maybe you can write next articles referring to this article.

    I wish to read even more things about it!