# Pytorch finds cuda despite nvcc not found?

**URL:** <https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754>\
**Category:** Uncategorized\
**Created:** [November 23, 2022, 11:17pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754 "2022-11-23T23:17:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![noctildon](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/noctildon/32/55114_2.png) [@noctildon](https://discuss.pytorch.org/u/noctildon)\
**Post date:** [November 23, 2022, 11:17pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/1 "2022-11-23T23:17:57Z")

</div>

Pytorch sees cuda and runs well on GPU, but nvcc appears to be not found

```python
import torch
torch.cuda.is_available() # True
torch.cuda.device_count() #1
torch.cuda.current_device() # 0
torch.cuda.get_device_name(0) # NVIDIA GeForce RTX 3090

```

```bash
$ nvidia-smi     
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
| 68% 72C P2 341W / 420W | 9876MiB / 24576MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 234092 C python3 9871MiB |
+-----------------------------------------------------------------------------+

```

```bash
$nvcc --version
Command 'nvcc' not found, but can be installed with:
sudo apt install nvidia-cuda-toolkit

```

Once I run `$sudo apt install nvidia-cuda-toolkit`, nvidia-smi gets removed and pytorch can’t recongize GPU. To install nvidia-smi, I run `$sudo apt install nvidia-utils-515-server`, but meanwhile nvcc get uninstalled. This looks like a chicken egg problem.

```bash
$sudo updatedb; locate nvcc
/etc/nvcc.profile
~/.local/lib/python3.10/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/run_nvcc.cmak
...

```

OS: Ubuntu server 22.04

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [November 24, 2022, 12:13am UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/2 "2022-11-24T00:13:44Z")

</div>

The PyTorch binaries ship with their own CUDA runtime (as well as cuDNN, NCCL etc.) and don’t need a locally installed CUDA toolkit to execute code but only a properly installed NVIDIA driver.  
Your local CUDA toolkit (with the compiler) will be used if you build PyTorch from source or a custom CUDA extension.  
Based on your described issue, I guess your CUDA toolkit installation uninstalled the NVIDIA driver as well and/or broke it, so try a new full install and make sure CUDA applications work again.

---

<div class="post-metadata">

**Author:** ![SandeepMenonIntSum](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sandeepmenonintsum/32/59010_2.png) [@SandeepMenonIntSum](https://discuss.pytorch.org/u/SandeepMenonIntSum)\
**Post date:** [May 24, 2023, 6:28pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/3 "2023-05-24T18:28:13Z")

</div>

I started off by installed the new pytorch and I can see in the `torch.version.cuda` that it is using cuda 11.7 version. But nvcc command is not found. Also when I try to install other packages which requires CUDA\_HOME to be set I get error saying (OSError: CUDA\_HOME environment variable is not set. Please set it to your CUDA install root).  
How should I get around this?  
Should I install the nvidia-cuda-toolkit?  
When I downloaded the cuda toolkit 11.7 and tried to install I get the message

```auto
Existing package manager installation of the driver found. It is strongly  
│ recommended that you remove this before continuing.                     
│ Abort                                                                      
│ Continue                                                                   

```

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [May 24, 2023, 7:13pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/4 "2023-05-24T19:13:08Z")

</div>

The PyTorch binaries ship with their required CUDA runtime dependencies, not a full CUDA toolkit with a compiler. If you want to build PyTorch from source or a custom CUDA extension you would need to install the full CUDA toolkit locally.

---

<div class="post-metadata">

**Author:** ![SandeepMenonIntSum](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sandeepmenonintsum/32/59010_2.png) [@SandeepMenonIntSum](https://discuss.pytorch.org/u/SandeepMenonIntSum)\
**Post date:** [May 24, 2023, 8:18pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/5 "2023-05-24T20:18:07Z")

</div>

I am not building Pytorch from source. Just some other repositories that require CUDA.  
When I try to install the full CUDA toolkit I get this message from the installer

```auto
Existing package manager installation of the driver found. It is strongly  
│ recommended that you remove this before continuing.                     
│ Abort                                                                      
│ Continue     

```

Should I uninstall the cuda runtime by pytorch along with pytorch and then install the full toolkit and then pytorch again? Or is there a way to keep things intact and just install the remaining ones of the cudatoolkit.

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [May 24, 2023, 11:12pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/6 "2023-05-24T23:12:35Z")

</div>

No, you don’t need to uninstall any PyTorch binaries or their dependencies and the warning is raised because of your already locally installed CUDA toolkit and driver.

---

<div class="post-metadata">

**Author:** ![SandeepMenonIntSum](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sandeepmenonintsum/32/59010_2.png) [@SandeepMenonIntSum](https://discuss.pytorch.org/u/SandeepMenonIntSum)\
**Post date:** [May 25, 2023, 1:08am UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/7 "2023-05-25T01:08:32Z")

</div>

When I try to install using

```bash
sudo sh cuda_11.7.0_515.43.04_linux.run

```

I downloaded the correct versions from nvidia.  
I get

```auto
[INFO]: Driver installation detected by command: apt list --installed | grep -e nvidia-driver-[0-9][0-9][0-9] -e nvidia-[0-9][0-9][0-9]
[INFO]: Cleaning up window
[INFO]: Complete
[INFO]: Checking compiler version...
[INFO]: gcc location: /usr/bin/gcc

[INFO]: gcc version: gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

[INFO]: Initializing menu
[INFO]: Setup complete
[INFO]: Components to install:
[INFO]: Driver
[INFO]: 515.43.04
[INFO]: Executing NVIDIA-Linux-x86_64-515.43.04.run --ui=none --no-questions --accept-license --disable-nouveau --no-cc-version-check --install-libglvnd 2>&1
[INFO]: Finished with code: 256
[ERROR]: Install of driver component failed.
[ERROR]: Install of 515.43.04 failed, quitting

```

---

<div class="post-metadata">

**Author:** ![skyler14](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/skyler14/32/64453_2.png) [@skyler14](https://discuss.pytorch.org/u/skyler14)\
**Post date:** [October 7, 2023, 9:59pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/8 "2023-10-07T21:59:13Z")

</div>

is there a way to get an nvcc installed and running for the cuda bound to the pytorch you guys ship (in conda here specifically). Some libraries I’m using I think rely on nvcc to check for cuda support so that would help

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [October 7, 2023, 11:25pm UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/9 "2023-10-07T23:25:18Z")

</div>

You could install the matching CUDA toolkit from the NVIDIA website or could try to use the `conda` package.  
Also, checking for `nvcc` for CUDA support is wrong as these packages check for a build toolchain. Which packages have these checks without using `nvcc`?

---

<div class="post-metadata">

**Author:** ![skyler14](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/skyler14/32/64453_2.png) [@skyler14](https://discuss.pytorch.org/u/skyler14)\
**Post date:** [October 8, 2023, 1:35am UTC](https://discuss.pytorch.org/t/pytorch-finds-cuda-despite-nvcc-not-found/166754/10 "2023-10-08T01:35:45Z")

</div>

There’s a pretty novice developed packaged for performant poisson blending called fpie. Upon further inspection I suspect this might be doing the nvcc check more at the C++ layer since it seems like the python is just an abstraction on top so there might be bigger problems tbh.
