Monthly Archives: May 2018

Inverse Square Hack

I just wanted to pay homage to one of the most brilliant programming optimizations.  This Inverse Square write up should be required reading to show how much thought can go into a single line of code.  In my life I probably will never write a line of code that is as beautiful in it’s intimate knowledge of math and low level computer expertise.

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

6. Make the script executable and run it.

$ chmod u+x
$ ./

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()