• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » How To Install TensorFlow on Ubuntu 18.04 Server (Nvidia GPU)

By Abhishek Ghosh September 12, 2018 7:34 am Updated on September 12, 2018

How To Install TensorFlow on Ubuntu 18.04 Server (Nvidia GPU)

Advertisement

Our previous guide was on installing PyTorch. Then, why TensorFlow needed a separate guide? Is not running few commands would install TensorFlow on that setup? There are practical differences when current version of Ubuntu server considered, some way would invite crush of server out of slightly buggy packages. With symlinking somehow works and most human forget what exactly done to someway fix.

We have discussed about GPU computing as minimally needed theoretical background. Also, in an earlier guide we have shown Nvidia CUDA tool installation on MacOS X. Here is Practical Guide On How To Install TensorFlow on Ubuntu 18.04 Server With Nvidia GPU. Installation demands server architecture which has Nvidia graphics card – there are such dedicated servers available for various purposes including gaming. Installing on localhost for intense and time consuming work not recommended for the sake of life of the device. The graphics card must support at least Nvidia compute 3.0 for more works than just TensorFlow.

How To Install TensorFlow on Ubuntu 18-04

 

Steps To Install TensorFlow on Ubuntu 18.04 Server

 

We are assuming a 64 bit version of OS with card like GeForce 740m. SSH to server. Update and upgrade :

Advertisement

---

Vim
1
2
apt update -y
apt upgrade -y

Run this big command to install the Python libraries :

Vim
1
sudo apt install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy python-six python3-six build-essential python-pip python3-pip python-virtualenv swig python-wheel python3-wheel libcurl3-dev libcupti-dev

Also run :

Vim
1
sudo apt install libcurl4-openssl-dev

We can see what graphics card hardware installed by running :

Vim
1
sudo lshw -C display | grep product

We need Nvidia driver installed. We can check whether and what graphics driver on SSH:

Vim
1
nvidia-smi

Here is Ubuntu’s PPA, browse it :

Vim
1
https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa

nvidia-graphics-drivers-396 is newest but probably not much tested. We can add nvidia-graphics-drivers-390 PPA and install that driver :

Vim
1
2
3
4
5
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt upgrade
ubuntu-drivers devices
sudo ubuntu-drivers autoinstall

If autoinstall somehow does not work then run :

Vim
1
sudo apt install nvidia-390

Now, again run the command :

Vim
1
nvidia-smi

You will get meaningful output. We should hold that version to stop getting upgraded :

Vim
1
sudo apt-mark hold nvidia-driver-390

Install Linux headers :

Vim
1
sudo apt install linux-headers-$(uname -r)

We need gcc, g++ etc for the next steps :

Vim
1
2
3
4
5
apt install gcc g++ gcc-6 g++-6 gcc-4.8 g++-4.8
# if gcc-4.8 package not found run
# sudo add-apt-repository ppa:ubuntu-toolchain-r/test
# sudo apt update
# sudo apt install gcc-4.8 g++-4.8

Now we have to install CUDA toolkit :

Vim
1
apt install nvidia-cuda-toolkit libcupti-dev

Reboot :

Vim
1
sudo reboot

Now we need to install CUDA toolkit itself :

Vim
1
https://developer.nvidia.com/cuda-toolkit

Run :

Vim
1
2
cd Downloads/
sudo sh cuda_9.0.176_384.81_linux.run --override --silent --toolkit

Next, you will need to install CUDNN, NCCL. For that, like older way for PyTorch you need to login using Nvdia account, that is easy. You will get link to something like cuDNN v7.1.x Library for Linux. You need to download that deb file and upload to server via FTP. The URL is :

Vim
1
2
https://developer.nvidia.com/rdp/cudnn-download
https://developer.nvidia.com/nccl

Find the directory where you have installed CUDA. It is copying the files over to /usr/local/cuda/. Move the above content into the directory where you install CUDA and run these operations (be careful about version numbered directory, below is example of format) :

Vim
1
2
3
4
tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Above will save space and avoid warning with apt. Open profile file like .bashrc :

Vim
1
nano ~/.bashrc

Add these :

Vim
1
2
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

Reload :

Vim
1
2
3
source ~/.bashrc
sudo ldconfig
echo $CUDA_HOME

Install Bazel :

Vim
1
2
3
4
5
6
7
8
sudo apt install curl
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
sudo apt update -y
sudo apt upgrade -y
sudo apt install bazel
sudo apt upgrade bazel
pip install keras

That is it. Check Nvidia version :

Vim
1
2
3
4
5
6
cd ~
git clone https://github.com/tensorflow/tensorflow
cd ~/tensorflow
# check current revision number from browser
git checkout r1.11
cd ~/tensorflow

Create configuration file by running :

Vim
1
./configure

You’ll get this kind of output :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: Y
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: N
Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: N
Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: N
Do you wish to build TensorFlow with Apache Kafka Platform support? [y/N]: N
Do you wish to build TensorFlow with XLA JIT support? [y/N]: N
Do you wish to build TensorFlow with GDR support? [y/N]: N
Do you wish to build TensorFlow with VERBS support? [y/N]: N
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
Do you wish to build TensorFlow with CUDA support? [y/N]: Y
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 9.0]: 9.0
Please specify the location where CUDA 9.1 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7.0]: 7.1
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda
Do you wish to build TensorFlow with TensorRT support? [y/N]: N
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 5.0] 3.0
Do you want to use clang as CUDA compiler? [y/N]: N
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: /usr/bin/gcc-4.8
Do you wish to build TensorFlow with MPI support? [y/N]: N
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: -march=native
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]:N

Build TensorFlow :

Vim
1
sudo bazel build --config=opt --config=cuda --action_env="/usr/local/cuda/lib64" //tensorflow/tools/pip_package:build_pip_package

Last steps :

Vim
1
2
3
bazel-bin/tensorflow/tools/pip_package/build_pip_package tensorflow_pkg
cd tensorflow_pkg/
sudo pip3 install tensorflow-<name_of_generated_file>.whl

Check if your build is working by changing into another directory and running python:

Vim
1
2
3
4
import tensorflow as tf
hello = tf.constant('Hello World!')
sess = tf.Session()
print(sess.run(hello))

You’ll get Hello World! output. TensorFlow has models :

Vim
1
https://github.com/tensorflow/models

You can run :

Vim
1
2
3
git clone https://github.com/tensorflow/models.git
cd models/tutorials/image/imagenet
python classify_image.py

That is about basic setup and testing.

Tagged With how to install nccl on ubuntu 18 04 , ubuntu18 04 install nccl , tensorflow cuda ubuntu server , tensorflow 1 12 ubuntu 18 04 , nccl ubuntu 18 04 location , install xserver on ubuntu 18 04 server for gpu cards , install xla jit ubuntu , install tensorflow ubuntu server , how to install NCCL on ubuntu 18 04 for tensorflow , will ubuntu 18 support nvida gpu

This Article Has Been Shared 837 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How To Install TensorFlow on Ubuntu 18.04 Server (Nvidia GPU)

  • IBM Analytics Demo Cloud : Free Hadoop, Ambari With SSH

    IBM Analytics Demo Cloud is intended to learn Hadoop, Ambari, BigSQL free of cost with SSH access & web console. Here is how to get started.

  • Create Data Science Environment on Cloud Server With Docker

    Here Are the Steps, Commands to Create Data Science Environment on Cloud Server For Data Analysis Starting With a Blank Server With SSH.

  • How to Be More Proactive With Your Data

    Some organizations will only use data scientists and analysts to handle their data initiatives, while others will give access to multiple people across various departments. Let us take a look at how companies can be more proactive with their data.

  • How to Install Apache DataFu (DataFu Pig, DataFu Hourglass)

    Here is Guide on How to Install Apache DataFu on Debian System. Apache DataFu is a collection of well-tested libraries for data mining and statistics.

  • Knowledge Discovery in Databases : Part III

    In Part I of Knowledge Discovery in Databases, we discussed about the database systems, fundamentals of statistics and Big Data and fundamentals of knowledge discovery in databases. In second part of Knowledge Discovery in Databases, we discussed the process of the Knowledge Discovery in Databases and Methods of the Knowledge Discovery in Databases. In This […]

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023
  • What is Vehicular Ad-Hoc Network? January 24, 2023
  • Difference Between Panel Light, COB Light, Track Light January 21, 2023

About This Article

Cite this article as: Abhishek Ghosh, "How To Install TensorFlow on Ubuntu 18.04 Server (Nvidia GPU)," in The Customize Windows, September 12, 2018, January 30, 2023, https://thecustomizewindows.com/2018/09/how-to-install-tensorflow-on-ubuntu-18-04-server-nvidia-gpu/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT