Adventures in Installing PyTorch in Ubuntu 18.04

I wanted to document installing PyTorch on Ubuntu 18.04 just in case it could be useful to myself or others in the future.  I tried to combine videos and forum posts together on this topic.

1. In Software & Updates, on the Ubuntu Software tab, check the “Proprietary drivers for devices” and “Software restricted by copyright or legal issues”.

2.  On the Additional Drivers tab, change the driver to "Using NVIDIA driver metapackage nvidia-driver-390 (proprietary, tested)"

2. Reboot to load drivers.
3. Check to make sure the driver was installed correctly with:
$ nvidia-smi

3. Install the NVidia Cuda Toolkit
$ sudo apt update
$ sudo apt install nvidia-cuda-toolkit


4. Check to make sure it is installed correclty with: $ nvcc –version

5. Download Anaconda which is used to install PyTorch.  The latest version can be found on the official site.
$ wget https://repo.anaconda.com/archive/Anaconda3-5.1.0-Linux-x86_64.sh


6. Make the script executable and run it.

$ chmod u+x Anaconda3-5.1.0-Linux-x86_64.sh
$ ./Anaconda3-5.1.0-Linux-x86_64.sh


7. Check to make sure it is installed with:
$ python --version
$ conda --version 



5. Use Anaconda to install PyTorch: $ conda install pytorch torchvision cuda91 -c pytorch 



6. Test it with:

$ ipython
import torch
t = torch.rand(5)
r = t.cuda()
r

Comments are Disabled