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.
- Shutdown and reboot. And enter the BIOS interface.
- Disable the Secure Boot.
- 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.
- 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
- Enter the boot menu (By pressing F11 or F12 when booting), and select the USB.
- 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.
- 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.
- Then press F10 to boot. Now it should be able to boot.
- Follow the instructions. After installation finishes, remove the USB and reboot.
- 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:
3.Refresh and reboot:
sudo update-initramfs -u
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:
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.
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
Type “nvcc -V” to see if it works.
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.
Follow the instruction of the official website. After installation, open a python console. Type
If it shows “True”, then, congratulations, it works!