Torch.cuda.is_available() returns False

I had this same problem when I built my own server. I followed these instructions (kind of, I mostly used it to see the dependencies required). Using sudo apt-get install nvidia-390 never worked for me, and I wound up reinstalling ubuntu fresh about 4 times before figuring out the correct sequence. In my experience it’s better to just install the CUDA toolkit which takes care of everything. Here’s where to find what distro you need. If I recall correctly, I believe I did the following (assuming ubuntu 16.04 and an x86 architecture):

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

Hopefully this works, I don’t know what kind of gpus are used in a p2 instance but this is what worked for my 1080ti.