Did you know that you can navigate the posts by swiping left and right?

CUDA 9.2 Ubuntu 18.04

08 Sep 2018 . Category . Comments #hardware #braintrust #research #nlp

Following up on a previous post, I realized that my CUDA 9.1 installation does not work with PyTorch.

Fortunately, both TensorFlow and PyTorch work with CUDA 9.2, but like before, using 9.2 with TensorFlow requires building it from source. Here are some notes.

This assumes an update from 9.1, meaning most dependencies are installed. For a fuller guide see here, but note this guide does not cover the driver issues below.

Remove all previous installs

sudo apt --purge remove cuda
sudo apt --purge remove *nvidia*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*

Download the CUDA local deb installers

https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.148-1_amd64

Install the debs

sudo dpkg -i cuda-repo-ubuntu1710-9-2-local_9.2.148-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1710-9-2-148-local-patch-1_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-9-2-148-local-patch-1/7fa2af80.pub
sudo apt-get update

Install everything but graphics driver

The drivers that come with CUDA 9.2 are not fully compatible with my 1080ti card. While exploring this, I found the overwrite option was necessary to even install those drivers, so I kept it here.

sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-toolkit-9-2 

Install the graphics driver

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

Open the software and update tool and install ‘nvidia-driver-396’ (beware similar but not identical name of the 9.2 driver)

REBOOT NOW

Fix the paths

echo 'export PATH=/usr/local/cuda-9.2/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc

Check it

source ~/.bashrc
sudo ldconfig
nvidia-smi

Download/install cuDNN

https://developer.nvidia.com/cudnn
tar -xf cudnn-9.2-linux-x64-v7.2.1.38.tgz 
sudo cp -R cuda/include/* /usr/local/cuda-9.2/include
sudo cp -R cuda/lib64/* /usr/local/cuda-9.2/lib64

Update bazel

echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel

Follow the regular steps to build

https://www.python36.com/how-to-install-tensorflow-gpu-with-cuda-9-2-for-python-on-ubuntu/2/