# How to check which cuda version my pytorch is using

**URL:** <https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622>\
**Category:** Uncategorized\
**Created:** [March 31, 2021, 3:57pm UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622 "2021-03-31T15:57:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaeJin\_Cho](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jaejin_cho/32/1042_2.png) [@JaeJin\_Cho](https://discuss.pytorch.org/u/JaeJin_Cho)\
**Post date:** [March 31, 2021, 3:57pm UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/1 "2021-03-31T15:57:46Z")

</div>

Hello!

I have multiple CUDA versions installed on the server, e.g., /opt/NVIDIA/cuda-9.1 and /opt/NVIDIA/cuda-10, and /usr/local/cuda is linked to the latter one. I believe I installed my pytorch with cuda 10.2 based on what I get from running torch.version.cuda.

How can I check which version of CUDA that the installed pytorch actually uses in running? I set my CUDA\_PATH=/opt/NVIDIA/cuda-9.1 but it still seems to run without any problem on a gpu.

Thanks,  
Jaejin Cho

---

<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:** [April 1, 2021, 6:36am UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/3 "2021-04-01T06:36:44Z")

</div>

You could check the linked CUDA version via `print(torch.version.cuda)`.

---

<div class="post-metadata">

**Author:** ![JaeJin\_Cho](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jaejin_cho/32/1042_2.png) [@JaeJin\_Cho](https://discuss.pytorch.org/u/JaeJin_Cho)\
**Post date:** [April 1, 2021, 1:42pm UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/5 "2021-04-01T13:42:43Z")

</div>

Thank you for the quick answer.

I actually used “torch.version.cuda” and checked it as in my original post (and it was 10.2). However, I was wondering why it still works with the setting “CUDA\_PATH=/opt/NVIDIA/cuda-9.1”. In other words, how it finds the correct cuda version to use (or which environment variable it uses to do so) in run-time?

---

<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:** [April 1, 2021, 4:15pm UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/6 "2021-04-01T16:15:05Z")

</div>

`CUDA_PATH` might be the wrong env var. I’m using `CUDA_HOME`, which works fine.

---

<div class="post-metadata">

**Author:** ![JaeJin\_Cho](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jaejin_cho/32/1042_2.png) [@JaeJin\_Cho](https://discuss.pytorch.org/u/JaeJin_Cho)\
**Post date:** [April 4, 2021, 1:17am UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/7 "2021-04-04T01:17:52Z")

</div>

Thank you for the answer!

Added this code in my script,

logging.warning(‘cuda version: {}’.format(torch.version.cuda))  
import os  
logging.warning(‘CUDA\_PATH: {}’.format(os.environ[“CUDA\_PATH”]))  
logging.warning(‘CUDA\_HOME: {}’.format(os.environ[“CUDA\_HOME”]))

Then, the outputs are like below:  
WARNING: cuda version: 10.2  
WARNING: CUDA\_PATH: /opt/NVIDIA/cuda-9.1  
WARNING: CUDA\_HOME: /opt/NVIDIA/cuda-9.1

It seems working fine but I am still curious what pytorch refers to for the correct CUDA version under the hood.

---

<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:** [April 4, 2021, 1:20am UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/8 "2021-04-04T01:20:33Z")

</div>

The `CUDA_HOME` env var is used during the build of PyTorch in order to compile the CUDA kernels, so you would need to rebuild it.

---

<div class="post-metadata">

**Author:** ![doem97](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/doem97/32/39380_2.png) [@doem97](https://discuss.pytorch.org/u/doem97)\
**Post date:** [September 10, 2023, 3:35pm UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/9 "2023-09-10T15:35:31Z")

</div>

@ptrblck I am a little confused by cuda version, torch version.

My CUDA\_HOME currently points to `cuda v11.1`

While my existing torch installation reads `torch.version.cuda=11.7`

Which cuda executive lib it is calling? I am confused because this wrong-version torch seems running quite fine.

---

<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:** [September 10, 2023, 6:30pm UTC](https://discuss.pytorch.org/t/how-to-check-which-cuda-version-my-pytorch-is-using/116622/10 "2023-09-10T18:30:53Z")

</div>

PyTorch ships with its own CUDA dependencies and your locally installed CUDA toolkit will be used if you build PyTorch from source or a custom CUDA extension.
