2.6x Performance Boost using Ubuntu 18.04.1 LTS Desktop with Anaconda

Ubuntu 18.04.1 LTS Desktop

Ubuntu 18.04.1 LTS Desktop

Here is the latest installment on my setup guides for PyTorch, this time on Linux Ubuntu 18.04.1 LTS Desktop. tl;dr, I got WAY better performance using Linux compared to Windows 10. I don’t know if it’s a direct comparison, but I was able to get a consistent 45-50% utilization on the GPUs (using the nvidia-smi command) compared to an inconsistent 20-30% on Windows 10 (using Task Manager, sometimes the GPU utilization for GPU 2 would go to zero). When I re-trained my code for the PyTorch Final Lab Challenge, it finished in 92 minutes compared to 240 minutes. That’s around a 2.6x improvement! Windows 10 has a lot of work to do on their scheduler if they ever hope to catch up to Linux.

Danger, Will Robinson!

A disclaimer upfront, this is not for the faint of heart. You can run into a lot of problems with installation packages, dependencies and file permission issues if you’re not familiar with Linux. I’ll discuss what I ran into and hopefully it will help you to streamline your install. If you are attempting to Dual Boot, be VERY CAREFUL as you can easily muck up your boot manager. Make sure you have boot disks and rescue disks for your existing operation system and backup EVERYTHING. Before I start, I’ll detail my hardware that I used as a baseline reference.

  1. Motherboard: MSI Z170A Gaming M7
  2. CPU: Intel i7 6700K
  3. Memory: 16GB DDR3200 CAS15
  4. GPU: 2x GeForce 1080 TI 11GB

Also make sure you have an extra hard drive that you can install to. This just makes it a lot simpler rather than re-partitioning an existing hard drive. If you want to go the re-partitioning route, I would search google for a specific guide to do so. A wired network connection is also preferred as a wireless driver may not be available to start. I had to compile my own driver for my wireless USB dongle after the fact thanks to some guides out there.

Step 1: Make a USB Install Boot Disk


You will need a USB key with at least 4GBs of space to copy the Ubuntu 18.04.1 LTS Desktop files to. Download the iso from Ubuntu’s website here:


If you are using Windows, you can use Rufus to create a USB boot disk. It’s fairly self explanatory. Select the USB drive and the .iso file you just downloaded and name the volume if you want to.

If you are using MacOS, you can use Etcher and follow the tutorial from Ubuntu.

Step 2: Boot and Install Ubuntu

Now that you have created a USB boot disk, place it into a USB port and restart your computer. If needed, enter into your BIOS and change the boot priority to make sure USB is first before your Hard Disk. Consult your motherboard manual on how to do this. In the example below, the USB Key is not in first priority (Boot Option #1) and needs to be changed to the top of the list. Another option is to access your boot menu on startup (usually some key like F11) and select to boot from the USB.

BIOS Boot Config
BIOS Boot Config

Once you are able to boot into USB, start the Ubuntu installation. Linux has come a long way and Ubuntu has refined the installation experience so its fairly quick and easy. If you run into any issues you can follow this install guide from Ubuntu here:


Once finished, you can remove the USB stick so after reboot it will boot off of the hard drive instead.  A menu should pop up and you can select Ubuntu. If you miss it, don’t worry, it will automatically select Ubuntu after some time if nothing is selected.

Step 3: Install CUDA 10.0 (Optional)

CUDA 10.0 Linux .deb Package
CUDA 10.0 Linux .deb Package

This part I had some trouble with. I initially tried to install the .run file directly from NVIDIA but that was a huge mistake. I kept running into an error message saying “The distribution-provided pre-install script failed!“. Instead I downloaded the .deb package that automatically installs all the files and dependencies for you.

First lets download the CUDA 10 Toolkit from here:


Then use the terminal to go to the Downloads folder and run the following commands to install the package (you might need to run the fetch keys command first, if you encounter an error message):

sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

This step is only required if you need access to low level CUDA kernels or the CUDA compiler. For development, Anaconda will install everything that you need in its’ own self contained environment.

Step 4: Install Anaconda

Anaconda Linux Python 3.7
Anaconda Linux Python 3.7

Download the installation file and follow the guide:

64-Bit (x86) Installer (652.5 MB)
How to install ANACONDA

Exit the terminal after you are done to finish the installation.

NOTE: You may run into some permission issues later on if the anaconda3 directory belongs to root instead of your username. You can check this by typing the following:

cd /home/yourusername
ls -l

It will show you a list of files and folders. The area of focus is the line for the folder anaconda3.

drwxr-xr-x 27 root root 864 Jan 12 19:27 anaconda3

To modify the permissions and change it from root to your username, use this command:

chown -R username:username anaconda3
ls -l

This should now show your username instead of root as the owner.

Step 5: Install PyTorch

PyTorch Download Page
PyTorch Download Page

Open the terminal and run the following commands to install PyTorch 1.0 (Stable).

conda update --all
conda install pytorch torchvision cuda100 -c pytorch

Step 6: Add shortcuts to your taskbar

Desktop Shortcuts
Desktop Shortcuts

You can use the command “anaconda-navigator” in the terminal to load anaconda, but the easier way is to make a shortcut saved to your taskbar so it’s only one click away. You can do this for the Anaconda Navigator and Spyder.

  1. Create a .sh file in the “home/username/bin” directory to run a script that will execute “anaconda-navigator”.
  2. Create an anaconda.desktop file in the “home/username” directory to link to the script and the icon image.
  3. Create a spyder.desktop file in the “home/username” directory to link to link to Spyder and the icon image. 
  4. Open terminal, go to the “home/username” directory.
  5.  Type “sudo desktop-file-install anaconda.desktop” and “sudo desktop-file-install spyder.desktop“.
  6. After 10-20 seconds, it will show up in your App Launcher. From there you can add it to favorites and it will be snapped to your taskbar on the left hand side. 

Luckily I have created these files already. You can download them here and save them to the proper directories. Then run the commands and you should be set. Feel free to open them with a text editor to check the code. 


That’s it! Thanks for reading. If you have any issues feel free to leave comments and I’ll update the article as needed.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.