These days I have owned a new machine in my office, equiped with an Intel Core i7-7800 CPU, an NVidia GTX 1060 GPU and a 27-inch display screen. Because of Windows 10 as the default operating system, it had me install Ubuntu 16.04 alongside with Windows 10, followed a series of matters to build up the development environment. Inevitably, I came across some unusual troubles and took down this post to record the whole process.

Install Ubuntu 16.04

Download the system image, write it on an USB disk, boot your PC with the USB disk and follow the instructions…But wait, as your computer ship with UEFI, you should partition the driver manually, at least a main partition mount ‘/’, a 4GB swap partition (corresponding to your momery size), a non-negligible EFI system partition and an optional home partition mount ‘/home’. Remember to disable the secure boot in the boot setup when reboot after completing the installation.

Install NVidia drivers, CUDA 9.0 and cuDNN v7.1.4

To solve the conflict between nouveau, the default graphics driver in Ubuntu, and NVidia drivers, you should disable the kernel nouveau at first. Edit the configure file /etc/modprobe.d/blacklist.conf

sudo vi /etc/modeprobe.d/blacklist.conf

and insert following lines in the end:

blacklist nouveau
options nouveau modeset=0

Save the file and type the following command:

sudo update-initramfs -u
sudo reboot

Then check whether nouveau is disabled before continue. If there’s no result, nouveau has been successfully disabled.

lsmod | grep -i nouveau

Log out and press ctrl+alt+F1 in the login interface and log in on tty1. Kill the x-server.

sudo /etc/init.d/lightdm stop

If you use gdm rather than lightdm, just replace lightdm with gdm in the above command. Then you can install the NVidia drivers correctly!

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-396
sudo reboot

Make sure the secure boot is disabled again, or it will cause some unpredictable errors. Here I made a mistake: I plugin the display screen’s wire into the integrated graphics rather than the individual graphics, then it didn’t work!

Only with such successfully installed NVidia drivers can one continue to install CUDA and cuDNN. Just downloads the deb package file and follow the official documents. Note when you use the network repo you must type

sudo apt install cuda-9-0

in the last step, or else you would install CUDA 9.2 rather than CUDA 9.0. And it’s the same to install cuDNN.

Build MXNet from source

Typically one can install MXNet by using pip. However, the code repo has been updating quickly, causing the lost of many functions in the pip-installed library. Thus, build from source seems a better way. There’s no problem in the official instruction, other than the installation of opencv. It happened to me several times that the one library in the opencv can’t be found. One possible solution is building OpenCV from souce, though costs plenty of time.

I, unwiling to rebuild OpenCV, use cmake rather than the recommended make to build the project. Followings are what I did, after completing the prerequisites, including OpenCV:

git clone --recursive https://github.com/apache/incubator-mxnet
cd incubator-mxnet
mkdir build
cd build
cmake ..
make -j8
sudo make install
cd ../python
pip install -e . --user

You should check the CMakeLists.txt at first. Here I use the --user flag to install locally. The last line creates an egg-link from this path to the pip package directory. So you could use git tools to update MXNet library, and you just need to delete the egg link to remove MXNet.