Tutorials for installing Ubuntu 18.04 dual system and NVIDIA DRIVER-CUDA-Pytorch GPU toolchain.

Tutorials for installing Ubuntu 18.04 dual system and NVIDIA DRIVER-CUDA-Pytorch GPU toolchain.

Last week I helped Zhenyi install the Ubuntu 18.04 dual system, and install NVIDIA driver, CUDA-10.0, CUDNN, Pytorch-gpu. Although there are many tutorials on the Internet, only very few works. So I think it is better to make a record.

BIOS setting

  1. Shutdown and reboot. And enter the BIOS interface.
  2. Disable the Secure Boot.
  3. If the mode is RAID, change it to ACHI. Or the Ubuntu installer cannot detect the Windows on the drive. You cannot change it directly, or you will fail to boot. Please Google it for details.
  4. Save and exit. Then reboot.

Making a USB stick.

That is simple. You can google it. I prefer to use rufus to make the USB stick.

Boot and installation

  1. Enter the boot menu (By pressing F11 or F12 when booting), and select the USB.
  2. Because of the open-source graphics card driver nouveau is not very compatible with laptops’ dual graphics cards, especially those which have GTX 10**. If you boot directly, the installer will stuck. So you need to add some boot parameters manually.
  3. First, move to the “Install Ubuntu” option. Press key “E”. Then you will see an interface with the boot arguments. Add acpi_osi=linux nomodeset after quiet splash, before the —  (if any). You will see a menu. Then you should be very careful.
  4. Then press F10 to boot. Now it should be able to boot.
  5. Follow the instructions. After installation finishes, remove the USB and reboot.
  6. Remember to add the parameters as step 1 when booting.

Disable the opensource driver.

1.Open the blacklist file:
sudo gedit /etc/modprobe.d/blacklist.conf

2.Adding following lines at the end of the file:


blacklist vga16fb

blacklist nouveau

blacklist rivafb

blacklist rivatv

blacklist nvidiafb

3.Refresh and reboot:
sudo update-initramfs -u

sudo reboot

Now let’s install the Nvidia Driver.

There are many ways to install the Nvidia driver. But the safest way is to use apt, or the GUI. I prefer apt.

Remove the nvidia drivers, if any:

sudo apt-get purge nvidia*

Adding PPA source:

sudo add-apt-repository ppa:graphics-drivers

sudo apt-get update

View the driver list:

ubuntu-drivers devices

Install one version:

sudo apt-get install nvidia-driver-<version>

After the installation, reboot, then open a terminal and type in “nvidia-smi“. If it works well, then the driver is installed successfully.

Install CUDA.

First download CUDA installer from the official website. Remember to download the runfile, instead of the .deb file.

When installing the .run file, there will be several options. In the second option, which asks you whether to install a driver, choose NO. Or it may break the desktop environment. Other options, just use the default one.

Open a terminal, type

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

Then

source ~/.bashrc

Type “nvcc -V” to see if it works.

Install CUDNN

Download the related version. Use “tar -xf <tar file>” to untar it. Get into the folder. Type the following.

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
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

Run “cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2 ” to see the version of CUDNN.

Install Pytorch

Follow the instruction of the official website. After installation, open a python console. Type

import torch

torch.cuda.is_available()

If it shows “True”, then, congratulations, it works!

yunhao
Posted on:
Post author

Leave a Reply

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