Torch.cuda.is_available() returns false in Win 11

Xian: <p>Hello there. I am brand new in Pytorch, and I have been encountering some issues with setting up PyTorch, which confuse me a lot. My PyTorch is still not running. I will demonstrate this in a newly created conda environment: In a brand new conda environment with Python==3.9.19, I install run:</p>
<pre><code class="lang-auto">conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
</code></pre>
<p>to install the corresponding packages. However, when I check it out:</p>
<pre><code class="lang-auto">import torch
torch.cuda.is_available()
</code></pre>
<p>the output result:</p>
<pre><code class="lang-auto">False
</code></pre>
<p>and then I try to download files in <a href="https://download.pytorch.org/whl/torch_stable.html" rel="noopener nofollow ugc">download.pytorch.org/whl/torch_stable.html</a>, and use</p>
<pre><code class="lang-auto">pip install torch-2.2.0+cu118-cp39-cp39-win_amd64.whl
pip install torchaudio-2.2.0+cu118-cp39-cp39-win_amd64.whl
pip install torchvision-0.17.0+cu118-cp39-cp39-win_amd64.whl
</code></pre>
<p>but still, <code>torch.cuda.is_available()</code> was <code>False</code>.<br>
check it out:</p>
<pre><code class="lang-auto">import torch
print("Torch version:", torch.__version__)
print("torch.CUDA version:", torch.version.cuda)
print("CUDA available:", torch.cuda.is_available())
if torch.cuda.is_available():
    print("CUDA device:", torch.cuda.get_device_name(torch.cuda.current_device()))
</code></pre>
<p>would output:</p>
<pre><code class="lang-auto">Torch version: 2.2.0+cu118
torch.CUDA version: 11.8
CUDA available: False
</code></pre>
<p>I want to say one thing is that it output <code>True</code> on Wednesday, but I am sorry I didn’t save the config, and after conda install some packages, it became False. At least the torch.CUDA can run in my computer.<br>
So now I also tried torch2.2.0-cuda12.1, and torch2.4.0-cuda12.4, but failed. I have confirmed that I can run *.cu files on the GPU. Here are some configuration details:</p>
<pre><code class="lang-auto">(cuda118) PS C:\Users\GenLi\desktop&gt; nvidia-smi
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 551.61                 Driver Version: 551.61         CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| 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  NVIDIA GeForce RTX 4060 Ti   WDDM  |   00000000:05:00.0 Off |                  N/A |
|  0%   40C    P8              3W /  165W |       0MiB /  16380MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
...
</code></pre>
<p>Multiple Versions of CUDA (change version by editing %CUDA_PATH%):</p>
<pre><code class="lang-auto">(cuda118) PS C:\Users\GenLi\desktop&gt; nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:41:10_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

(cuda118) PS C:\Users\GenLi\desktop&gt; nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Wed_Feb__8_05:53:42_Coordinated_Universal_Time_2023
Cuda compilation tools, release 12.1, V12.1.66
Build cuda_12.1.r12.1/compiler.32415258_0

(cuda118) PS C:\Users\GenLi\desktop&gt; nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Tue_Feb_27_16:28:36_Pacific_Standard_Time_2024
Cuda compilation tools, release 12.4, V12.4.99
Build cuda_12.4.r12.4/compiler.33961263_0
</code></pre>
<p>Packages</p>
<pre><code class="lang-auto">(cuda118) PS C:\Users\GenLi\desktop&gt; pip list
Package            Version
------------------ ------------
certifi            2024.7.4
charset-normalizer 3.3.2
filelock           3.15.4
fsspec             2024.6.1
idna               3.7
Jinja2             3.1.4
MarkupSafe         2.1.5
mpmath             1.3.0
networkx           3.2.1
numpy              1.26.4
pillow             10.4.0
pip                24.2
requests           2.32.3
setuptools         72.1.0
sympy              1.13.1
torch              2.2.0+cu118
torchaudio         2.2.0+cu118
torchvision        0.17.0+cu118
typing_extensions  4.12.2
urllib3            2.2.2
wheel              0.43.0
</code></pre>
<p>I have consulted a lot of materials but they do not seem to work. Perhaps there are something I didn’t notice. please let me know if any additional information is needed. I would be very grateful if someone could help me. <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"> <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"> <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"></p>

ptrblck: <aside class="quote no-group" data-username="Xian" data-post="1" data-topic="207516">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/xian/48/62070_2.png" class="avatar"> Xian:</div>
<blockquote>
<p>Multiple Versions of CUDA (change version by editing %CUDA_PATH%):</p>
</blockquote>
</aside>
<p>The PyTorch binaries ship with their own CUDA dependencies so remove your locally installed CUDA toolkit from the PATH and check if PyTorch is able to access the GPU. If not, try to create a new virtual conda environment or narrow down what exactly changed between now and last week, which seems to have caused the issues.</p>

Xian: <p>I removed local CUDA, create a new venv and use pytorch-cuda but still, return False.</p>
<pre><code class="lang-auto">(base) PS C:\Users\GenLi\desktop&gt; conda activate cuda124
(cuda124) PS C:\Users\GenLi\desktop&gt; conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
...

done
(cuda124) PS C:\Users\GenLi\desktop&gt; conda list
# packages in environment at C:\Users\GenLi\anaconda3\envs\cuda124:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
brotli-python             1.1.0           py310h00ffb61_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
bzip2                     1.0.8                h2466b09_7    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ca-certificates           2024.7.4             h56e8100_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
certifi                   2024.7.4           pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
cffi                      1.16.0          py310h8d17308_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
charset-normalizer        3.3.2              pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
cuda-cccl                 12.6.37                       0    nvidia
cuda-cccl_win-64          12.6.37                       0    nvidia
cuda-cudart               12.4.127                      0    nvidia
cuda-cudart-dev           12.4.127                      0    nvidia
cuda-cupti                12.4.127                      0    nvidia
cuda-libraries            12.4.0                        0    nvidia
cuda-libraries-dev        12.4.0                        0    nvidia
cuda-nvrtc                12.4.127                      0    nvidia
cuda-nvrtc-dev            12.4.127                      0    nvidia
cuda-nvtx                 12.4.127                      0    nvidia
cuda-opencl               12.6.37                       0    nvidia
cuda-opencl-dev           12.6.37                       0    nvidia
cuda-profiler-api         12.6.37                       0    nvidia
cuda-runtime              12.4.0                        0    nvidia
cuda-version              12.6                          3    nvidia
filelock                  3.15.4             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
freetype                  2.12.1               hdaf720e_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
h2                        4.1.0              pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
hpack                     4.0.0              pyh9f0ad1d_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
hyperframe                6.0.1              pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
idna                      3.7                pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
intel-openmp              2024.2.0           h57928b3_980    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
jinja2                    3.1.4              pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
lcms2                     2.16                 h67d730c_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
lerc                      4.0.0                h63175ca_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libblas                   3.9.0           1_h8933c1f_netlib    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libcblas                  3.9.0           5_hd5c7e75_netlib    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libcublas                 12.4.2.65                     0    nvidia
libcublas-dev             12.4.2.65                     0    nvidia
libcufft                  11.2.0.44                     0    nvidia
libcufft-dev              11.2.0.44                     0    nvidia
libcurand                 10.3.7.37                     0    nvidia
libcurand-dev             10.3.7.37                     0    nvidia
libcusolver               11.6.0.99                     0    nvidia
libcusolver-dev           11.6.0.99                     0    nvidia
libcusparse               12.3.0.142                    0    nvidia
libcusparse-dev           12.3.0.142                    0    nvidia
libdeflate                1.21                 h2466b09_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libffi                    3.4.2                h8ffe710_5    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libhwloc                  2.11.1          default_h8125262_1000    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libiconv                  1.17                 hcfcfb64_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libjpeg-turbo             3.0.0                hcfcfb64_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
liblapack                 3.9.0           5_hd5c7e75_netlib    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libnpp                    12.2.5.2                      0    nvidia
libnpp-dev                12.2.5.2                      0    nvidia
libnvfatbin               12.6.20                       0    nvidia
libnvfatbin-dev           12.6.20                       0    nvidia
libnvjitlink              12.4.99                       0    nvidia
libnvjitlink-dev          12.4.99                       0    nvidia
libnvjpeg                 12.3.1.89                     0    nvidia
libnvjpeg-dev             12.3.1.89                     0    nvidia
libpng                    1.6.43               h19919ed_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libsqlite                 3.46.0               h2466b09_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libtiff                   4.6.0                hb151862_4    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libuv                     1.48.0               hcfcfb64_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libwebp-base              1.4.0                hcfcfb64_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libxcb                    1.16                 hcd874cb_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libxml2                   2.12.7               h0f24e4e_4    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libzlib                   1.3.1                h2466b09_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
m2w64-gcc-libs            5.3.0                         7    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
m2w64-gcc-libs-core       5.3.0                         7    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
m2w64-gmp                 6.1.0                         2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
markupsafe                2.1.5           py310h8d17308_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
mkl                       2023.1.0         h6a75c08_48682    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
mpmath                    1.3.0              pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
msys2-conda-epoch         20160418                      1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
networkx                  3.3                pyhd8ed1ab_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
numpy                     2.0.1           py310h1ec8c79_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
openjpeg                  2.5.2                h3d672ee_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
openssl                   3.3.1                h2466b09_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pillow                    10.4.0          py310h3e38d90_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pip                       24.2               pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pthread-stubs             0.4               hcd874cb_1001    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pthreads-win32            2.9.1                hfa6e2cd_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pycparser                 2.22               pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pysocks                   1.7.1              pyh0701188_6    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python                    3.10.4          hcf16a7b_0_cpython    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python_abi                3.10                    4_cp310    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pytorch                   2.4.0           py3.10_cuda12.4_cudnn9_0    pytorch
pytorch-cuda              12.4                 h3fd98bf_6    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pyyaml                    6.0.1           py310h8d17308_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
requests                  2.32.3             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
setuptools                72.1.0             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
sqlite                    3.46.0               h2466b09_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
sympy                     1.13.0             pyh04b8f61_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
tbb                       2021.12.0            hc790b64_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
tk                        8.6.13               h5226925_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
torchaudio                2.4.0                    pypi_0    pypi
torchvision               0.19.0                   pypi_0    pypi
typing_extensions         4.12.2             pyha770c72_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
tzdata                    2024a                h0c530f3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ucrt                      10.0.22621.0         h57928b3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
urllib3                   2.2.2              pyhd8ed1ab_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vc                        14.3                h8a93ad2_20    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vc14_runtime              14.40.33810         ha82c5b3_20    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vs2015_runtime            14.40.33810         h3bf8584_20    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
wheel                     0.44.0             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
win_inet_pton             1.1.0              pyhd8ed1ab_6    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xorg-libxau               1.0.11               hcd874cb_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xz                        5.2.6                h8d14728_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
yaml                      0.2.5                h8ffe710_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
zstandard                 0.23.0          py310he5e10e1_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
zstd                      1.5.6                h0ea2cb4_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
(cuda124) PS C:\Users\GenLi\desktop&gt; python torch_cuda_test.py
Torch version: 2.4.0
torch.CUDA version: 12.4
CUDA available: False
</code></pre>
<p>And, how can I know</p>
<aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="207516">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>narrow down what exactly changed between now and last week, which seems to have caused the issues.</p>
</blockquote>
</aside>
<p>thanks.</p>