Pytorch installation with GPU support

I’m trying to get pytorch working on my ubuntu 14.04 machine with my GTX 970.

It’s been stated that you don’t need to have previously installed CUDA to use pytorch so my first questions are: Why are there options to install for CUDA 7.5 and CUDA 8.0? How do I tell which is appropriate for my machine and what is the difference between the two options?

I selected the Ubuntu -> pip -> cuda 8.0 install and it seemed to complete without issue. However if I load python and run

import torch
torch.cuda.is_available()

I get False.

Other cuda operations fail as well.

Second question: How is this determined?

Is there something I need in my environment for my device to be detected?

It would be great if there were a post-install checklist to help diagnose these issues. If there is one and I’ve missed it, please let me know!

2 Likes

I think you don’t need to install CUDA to use the cpu part of pytorch even you install the cuda version of pytorch.

However, if you want to use gpu, then you need to install cuda.

You should select the CUDA install based on which CUDA version you have. You can do this via nvcc --version in a terminal; it’ll tell you what version you’re running.

PyTorch checks your ‘/usr/local/cuda’ directory for a CUDA installation, as well as the CUDA_HOME global variable (source code here). You don’t need to set the CUDA_HOME manually unless your CUDA installation is somewhere non-standard.

I have the same question as well. Since it was stated that installing pytorch binary is the only thing needed to run cuda vesion of pytorch. Refer to this answer: https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/3?u=houjing_huang

I think you do not need to install CUDA separately because it is included in the binary pytorch distribution, but:

  • you need to have to proper NVIDIA driver installed for your GPU (I think it will probably have to be the latest NVIDIA proprietary driver, not the the default open-source neveau driver)
  • your GPU must be supported by the CUDA version which is included in the python binary installation. If the GPU is an older model, it may be that an older CUDA version still supports it but a newer version not anymore

I think the pytorch pages could make all this a bit clearer, when I first looked at the installation instructions I thought the cuda version to specify is the one pytorch expects to be installed, when in reality it is the one included in the binary distribution.

1 Like