0

How can I find where CUDA 11.x for PyTorch-GPU 1.13 get installed on Windows 10 on my computer?

What I tried: I installed the NVIDIA CUDA drivers and toolkit for Windows from the NVIDIA website. I can verify this by typing: !nvidia-smi in Jupyter Lab, which gives me the following output. This indicates that the CUDA tools are installed, but not being used by my PyTorch package. I need to find out what version of CUDA drivers are installed so I can install the correct PyTorch-GPU package.

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 513.63       Driver Version: 513.63       CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Quadro P2000       WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   46C    P8    N/A /  N/A |      0MiB /  4096MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

I find many Ubuntu questions and answers for locating CUDA to add it to my PATH, but nothing specific for Windows 10.

For example: Pytorch CUDA installation fails, Pytorch CUDA installation using conda, pytorch-says-that-cuda-is-not-available

What are the equivalent Python commands on Windows 10 to locate the CUDA 11.x toolkits and driver version that my PyTorch-GPU package must use? And then how to fix the problem if PyTorch is out of sync?

Rich Lysakowski PhD
  • 2,702
  • 31
  • 44
  • Are you really asking how to find files on a Windows 10 system? – talonmies Nov 13 '22 at 23:57
  • No, not at all. This is about PyTorch not Windows "how to find files". On Linux finding any file anywhere may be trivial. I need to find hidden CUDA drivers for the NVIDIA CUDA installer that provided no uninstaller or obvious package in Program Files. There are many BAD dead-end or incomplete CUDA answers. I will revise my question so it is more complete and accurate. – Rich Lysakowski PhD Nov 14 '22 at 03:36

2 Answers2

1

I am answering my own question here... PyTorch-GPU must be compiled against specific CUDA binary drivers.

I finally found this hint Why torch.cuda.is_available() returns False even after installing pytorch with cuda? which identifies the issue.

import torch torch.zeros(1).cuda()

The return value clearly identifies the problem.

AssertionError                            Traceback (most recent call last)
Cell In [222], line 2
      1 import torch
----> 2 torch.zeros(1).cuda()

File C:\ProgramData\Anaconda3\envs\tf210_gpu\lib\site-packages\torch\cuda\__init__.py:221, in _lazy_init()
    217     raise RuntimeError(
    218         "Cannot re-initialize CUDA in forked subprocess. To use CUDA with "
    219         "multiprocessing, you must use the 'spawn' start method")
    220 if not hasattr(torch._C, '_cuda_getDeviceCount'):
--> 221     raise AssertionError("Torch not compiled with CUDA enabled")
    222 if _cudart is None:
    223     raise AssertionError(
    224         "libcudart functions unavailable. It looks like you have a broken build?")

AssertionError: Torch not compiled with CUDA enabled

The problem is: "Torch not compiled with CUDA enabled"

Now I have to see if I can just re-install PyTorch-GPU to replace the current PyTorch-CPU version with one that is compiled against my CUDA CUDA-GPU v11.6 driver, without rebuilding the entire conda environment. I would rather not rebuild the conda environment from scratch unless it is really necessary.

Rich Lysakowski PhD
  • 2,702
  • 31
  • 44
  • This is wrong. There is no requirement for compilation with "corresponding CUDA binary drivers". You can use whatever GPU driver you want, as long as it has, at minimum, support for the CUDA runtime libraries or driver API version you are using. That is what `nvidia-smi` tells us (it is a driver side utility). For Pytorch, you must have the exact matching version of the CUDA runtime libraries which the Pytorch you install was built against. And it must include binary support for the GPU architecture your device requires. – talonmies Nov 14 '22 at 02:07
  • And I fail to see how this in any way answers your question about how to find the location of the CUDA installation on a Windows 10 system – talonmies Nov 14 '22 at 02:08
  • @talonmies ... Thank you for clarification. I have revised my question and answer based on your feedback. – Rich Lysakowski PhD Nov 14 '22 at 02:14
  • Yeah they have this web page that builds the correct install command for you. https://pytorch.org/get-started/locally/ . Here is an example for cuda 11.8: pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 – Jason Cheng May 26 '23 at 05:17
1

Hey I had the same problem and your troubleshooting helped me solve the problem. I think the problem can occur in any os since the issue is some problem with the package names or pip.

My copy of pytorch got installed through a requirements file from a random project. Do not install it this way if you want GPU support. Pytorch doesn't even use your install of Cuda. It come with it's own copy of Cuda which is why you need a special install command for it. Kinda wasteful and unobvious to do it this way but c'est la vie.

First, you MUST uninstall any copy of pytorch, torchvision, and torchaudio you have previously installed. If you don't uninstall first, it won't work (I tried). You can get the correct command @ https://pytorch.org/get-started/locally/ . Install using whatever command they give you.

Jason Cheng
  • 180
  • 2
  • 12