13

Recently,I need to install pytorch ,when I check out the website :

install pytorch website

It shows four different version 9.2,10.1,10.2,11.0 to choose ,And I have cuda version 10.0 and driver version 450 installed on my computer,I thought it would fail to enable gpu when using pytorch ,After I choose 10.1 and try torch.cuda.is_available() and it returns True

I have two questions:

  1. Why does everything turn out to be working even my cuda version is not the same as any of one I mentioned ?

  2. What's the difference between choosing cuda verison 9.2,10.1,10.2,11.0 ?

4
  • Which one did you install exactly?
    – Ivan
    Feb 1, 2021 at 7:34
  • @Ivan Sorry for not mentioning ,I choosed 10.1 to install pytorch1.7 Feb 1, 2021 at 8:03
  • Ok, and how did you check your CUDA version?
    – Ivan
    Feb 1, 2021 at 8:15
  • @Ivan Yeah,after typing "nvcc -V",it gives : Cuda compilation tools, release 10.0, V10.0.130 Feb 1, 2021 at 8:26

1 Answer 1

15

PyTorch doesn't use the system's CUDA installation when installed from a package manager (either conda or pip). Instead, it comes with a copy of the CUDA runtime and will work as long as your system is compatible with that version of PyTorch. By compatible I mean that the GPU supports the particular version of CUDA and the GPU's compute capability is one that the PyTorch binaries (for the selected version) are compiled with support for.

Therefore the version reported by nvcc (the version installed on the system) is basically irrelevant. The version you should be looking at is

import torch
# print the version of CUDA being used by pytorch
print(torch.version.cuda)

The only time the system's version of CUDA should matter is if you compiled PyTorch from source.

As for which version of CUDA to select. You will probably want the newest version of CUDA that your system is compatible with. This is because newer versions generally include performance improvements compared to older versions.

4
  • print(torch.cuda.version) returns : AttributeError: module 'torch.cuda' has no attribute 'version' Feb 2, 2021 at 12:20
  • @Pro_gram_mer Oops, that's a typo. It should be torch.version.cuda. I'll update the answer.
    – jodag
    Feb 2, 2021 at 13:04
  • @jodag Do you know what is the main different between CUDA 10.2 and CUDA 11.1 as computing platforms? I've been looking around in docs but to no avail. Jun 30, 2021 at 18:20
  • 1
    @OmarAlSuwaidi As far as pytorch is concerned the version of CUDA should not impact what features are available to you from the library. AFAIK all pytorch operations should give the same results on all versions of CUDA. There are 10.2 and 11.1 versions of pytorch because some GPUs don't support CUDA 10.2 and some don't support 11.1, depending on compute capability (cuda wikipedia page). Note that CUDA itself has different features between versions. That means some pytorch operations may be faster in the 11.1 version than the 10.2 version.
    – jodag
    Jun 30, 2021 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.