Project, Research

Neural Networking for Dummies 15: Installing tensorflow-gpu on Ubuntu (FOR REAL THIS TIME)

It’s been just over a month since this journey first began, and boy has it been a wild ride. Since so much has happened, I want to quickly recap before I continue on, just to fully appreciate what it has taken to get to this point.

I spent my first three parts of this journey exploring (and failing) mining data from Facebook so I could pull and analyze captions on cat photos in public groups to train my neural network

Fine Facebook, I didn’t want any of your data anyway

I decided to change directions and attempt training a network to talk like David Rose instead, so my next three posts were dedicated to installing the necessary software on Windows (spoiler alert: this did not go well).

If anyone ever reads this blog I hope they take away one thing:
Stop reading this and go watch Schitts Creek

My next three posts chronicled my nightmare of installing the Linux OS Ubuntu so I could install tensorflow on that instead of Windows. This is where things really started falling apart.

I installed a second SSD to separate the Windows OS and Ubuntu, but I kept getting weird glitches and eventually my PC refused to boot. In order to revive it I had to reorganize the storage part of the basement so I had the room necessary to disassemble, clean, and troubleshoot it.

This project has been such a cf

Now that my PC is back in action, it is FINALLY TIME to try installing tensorflow-gpu on Ubuntu 18.04! SO HERE WE GO!

I <3 Liz Lemon

First thing I had to do was check and see if I had the right NVIDIA driver installed by running the command “nvidia-smi”. Unfortunately, I couldn’t run that command, but the terminal suggested that I could install it by running “sudo apt install nvidia-utils-390”.

So far so good?

After that I ran the command again, but received the following error:

I went to Ubuntu’s “Software & Updates” and went to the “Additional Drivers” tab. NVIDIA’s driver was not the one in use, so I selected it and hit apply. Hopefully now I can finally be done with the first step.

Making progress!

Time for step 2: downloading CUDA Toolkit 9.0, I chose the Linux x86_64 by looking up how to check that in command line (uname -m). I also filled out Ubuntu 17.04 runfile per the instructions in the guide.

Pretty straight forward aside from the Architecture part

After it downloaded, I located the file and right clicked on it to open the terminal and entered the following:

sudo chmod +x
./ --override

After I hit enter on the second line, it seemed to stall and the lower-left corner of the terminal said “–More–(0%). I figured out that I had to hold the space bar to scan through the entire terms and conditions and then type “accept” for it to continue with the install.

After that I heeded these very important instructions from the walkthrough of selecting “yes” to install unsupported configuration, no to install NVIDIA graphics driver, yes to install the toolkit, and then kept accepting the default installation options after.

Now we need to do Post CUDA installation steps. I was following the instructions, but kept running into a“permission denied” error. I found out what you really need to enter is the following:

. ~/.bashrc
nano ~/.bashrc

Scroll to the bottom of the file and copy and paste in these two lines:

export PATH=/usr/local/cuda-9.0/bin${PATH:+${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}
I’m doing it! 🙂

I then hit Ctrl+X and selected “Y” to save and hit enter to overwrite the original file. This wasn’t specified in the instructions, but I remembered these commands from fiddling around with an old retropie raspberry pi project years ago.

Aaaaaaaand of course I would start running into problems -_-

After closer inspection, I found that the second line of code was missing its second “}” at the end of the statement. So I went back into the file and edited it to be the following:

export PATH=/usr/local/cuda-9.0/bin${PATH:+${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}}

Now running the source command did not give me an error. Huzzah!


Next I downloaded CUDNN 7.0 and opened the terminal in my downloads folder and ran the following commands to move the contents where they needed to go:

tar -zxvf cudnn-9.0-linux-x64-v7.tgz
sudo cp -P cuda/lib64/* /usr/local/cuda-9.0/lib64/
sudo cp  cuda/include/* /usr/local/cuda-9.0/include/
sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h

After that I installed something called “libcupti” by issuing the following command in the terminal: sudo apt-gen install libcupti-dev

But that hasn’t stopped me so far

After that I installed Anaconda by downloading it (I went with Linux 3.7 Python version) and then ran the following command in the terminal (once again launched from the downloads folder): bash

At the end of the installation I selected “yes” to be able to use the conda command and then opened a new terminal and filled out the following commands to create a virtual environment for tensorflow.

source ~/.bashrc
conda list
conda create --name tf
source activate tf
easy_install -U pip

And BOOM! Another problem, “easy_install” command was not found. Apparently it was removed from the python setup tools and now I need to figure out how to continue. A suggestion on the board was to run the following: sudo apt-get install python-setuptools

So close, and yes so far

Since that didn’t work, I figured I’d just try to run the pip3 tensorflow install command line and see if it would work. It didn’t (not surprised) because it did not recognize pip3 command, BUT the terminal gave the suggestion to run the line “sudo apt install python3-pip” to enable it.

After that I ran my final command: pip3 install –upgrade tensorflow-gpu



Now to go “celebrate” by running week 2 day 2 of couch to 5k because my future wife is a healthy beautiful creature who enjoys when I exercise with her.

Isn’t she the most gorgeous woman? <3 I cannot believe I get to marry her! 😀

I now need to get my bearings to find out how to install the rest of the neural network training software, but getting tensorflow up and running has been one heck of a struggle and I am really excited to never have to deal with that nightmare again. So with that, I’ll leave off with more cat pics and return to this project another day!

Leave a Reply