Torch.cuda.is_available() -> False

Valerio_Romano_Cadur: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7" title="screen2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_690x105.jpeg" alt="screen2" data-base62-sha1="kpurikBPF2wDvMO91SxFv0iun7F" width="690" height="105" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_690x105.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_1035x157.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_1380x210.jpeg 2x" data-dominant-color="141414"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">screen2</span><span class="informations">1753×268 44.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I am experiencing an issue with PyTorch Cuda, I am just a beginner but I really need to exploit my GPU computing power. I installed PyTorch Cuda, Cuda Toolkits and tried everything I found on the Internet. I am opening a thread for the first time because I am not sure what to do, tried to reinstall Anaconda, PyTorch, Visual Studio, whatever did not solve my problem. I hope you can help me.</p>
<p>I saw that you helped many to solve the same issue so I tagged you hope not to bother.<br>
<a class="mention" href="/u/ptrblck">@ptrblck</a><br>
Best,</p>
<p>Valerio</p>

Valerio_Romano_Cadur: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7" title="screen2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_690x105.jpeg" alt="screen2" data-base62-sha1="kpurikBPF2wDvMO91SxFv0iun7F" width="690" height="105" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_690x105.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_1035x157.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f0d24fe7be08a2c118cc20d7409b87cae7b49a7_2_1380x210.jpeg 2x" data-dominant-color="141414"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">screen2</span><span class="informations">1753×268 44.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

Valerio_Romano_Cadur: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/0/40ae515becbb99da604ddfb3cdc56da206aa7f19.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/40ae515becbb99da604ddfb3cdc56da206aa7f19" title="screen3"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/0/40ae515becbb99da604ddfb3cdc56da206aa7f19_2_690x137.jpeg" alt="screen3" data-base62-sha1="9ec2083K3erYx6SxqMVpGDNjTf3" width="690" height="137" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/0/40ae515becbb99da604ddfb3cdc56da206aa7f19_2_690x137.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/4/0/40ae515becbb99da604ddfb3cdc56da206aa7f19.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/4/0/40ae515becbb99da604ddfb3cdc56da206aa7f19.jpeg 2x" data-dominant-color="1E1E1E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">screen3</span><span class="informations">1015×202 37.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

Valerio_Romano_Cadur: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/b/fbe86c9545ca3c52e3f6c58fbca89a344226cbc2.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/fbe86c9545ca3c52e3f6c58fbca89a344226cbc2" title="screen4"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/b/fbe86c9545ca3c52e3f6c58fbca89a344226cbc2_2_429x500.jpeg" alt="screen4" data-base62-sha1="zWtOjx6XSMfQ5WOrqTPw68mLNDA" width="429" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/b/fbe86c9545ca3c52e3f6c58fbca89a344226cbc2_2_429x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/f/b/fbe86c9545ca3c52e3f6c58fbca89a344226cbc2_2_643x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/f/b/fbe86c9545ca3c52e3f6c58fbca89a344226cbc2_2_858x1000.jpeg 2x" data-dominant-color="161516"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">screen4</span><span class="informations">1132×1317 176 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>The PyTorch binaries ship with their own CUDA runtime and other CUDA libs. Your locally installed CUDA toolkit will be used if you build PyTorch from source or a custom CUDA extension.</p>
<p>Could you post the output of <code>python -m torch.utils.collect_env</code> here by wrapping it into three backticks ``` instead of posting screenshots, please?</p>

Valerio_Romano_Cadur: <pre><code class="lang-auto">Collecting environment information...
Traceback (most recent call last):
  File "C:\Users\Valerio Cadura\anaconda3\envs\algo\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Valerio Cadura\anaconda3\envs\algo\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\utils\collect_env.py", line 602, in &lt;module&gt;
    main()
  File "C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\utils\collect_env.py", line 585, in main
    output = get_pretty_env_info()
  File "C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\utils\collect_env.py", line 580, in get_pretty_env_info
    return pretty_str(get_env_info())
  File "C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\utils\collect_env.py", line 422, in get_env_info
    pip_version, pip_list_output = get_pip_packages(run_lambda)
  File "C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\utils\collect_env.py", line 394, in get_pip_packages
    out = run_with_pip(sys.executable + ' -mpip')
  File "C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\utils\collect_env.py", line 382, in run_with_pip
    for line in out.splitlines()
AttributeError: 'NoneType' object has no attribute 'splitlines'

(algo) C:\Users\Valerio Cadura&gt;``` 
Thanks for your time and availability.</code></pre>

ptrblck: <p>Could you download the file manually and execute it:</p>
<pre><code class="lang-auto">wget https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py
python collect_env.py
</code></pre>

Valerio_Romano_Cadur: <aside class="quote no-group quote-modified" data-username="ptrblck" data-post="5" data-topic="177751">
<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>
<pre><code class="lang-auto"></code></pre>
</blockquote>
</aside>
<pre><code class="lang-auto">--2023-04-19 18:42:32--  https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21550 (21K) [text/plain]
Saving to: 'collect_env.py'

collect_env.py                100%[=================================================&gt;]  21,04K  --.-KB/s    in 0,004s

2023-04-19 18:42:32 (4,62 MB/s) - 'collect_env.py' saved [21550/21550]


(algo) C:\Users\Valerio Cadura\Desktop\ANCFIS&gt;python collect_env.py
Collecting environment information...
PyTorch version: 2.0.0+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 Home
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.10 | packaged by Anaconda, Inc. | (main, Mar 21 2023, 18:39:17) [MSC v.1916 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19045-SP0
Is CUDA available: False
CUDA runtime version: 12.1.66
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060 Laptop GPU
Nvidia driver version: 531.61
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin\cudnn_ops_train64_8.dll
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture=9
CurrentClockSpeed=3301
DeviceID=CPU0
Family=107
L2CacheSize=4096
L2CacheSpeed=
Manufacturer=AuthenticAMD
MaxClockSpeed=3301
Name=AMD Ryzen 9 5900HS with Radeon Graphics
ProcessorType=3
Revision=20480

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] torch==2.0.0
[pip3] torchaudio==2.0.1+cu118
[pip3] torchvision==0.15.1+cu118
[conda] Could not collect

(algo) C:\Users\Valerio Cadura\Desktop\ANCFIS&gt;```

I took some time because I had to figure out I did not have wget, but thanks again. 
Looking forward.
Valerio Romano</code></pre>

ptrblck: <p>Thanks for the update.<br>
Based on the output you have installed the CPU-only binary:</p>
<pre><code class="lang-auto">PyTorch version: 2.0.0+cpu
</code></pre>
<p>which explains why you won’t be able to use the GPU.</p>

Valerio_Romano_Cadur: <p>Yes, do you have any ideas why this happen? The fact is that I’ve installed the cuda version in that environment using the following command <code>conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia</code> found on <a href="http://pytorch.org" rel="noopener nofollow ugc">pytorch.org</a>.<br>
How can I solve?</p>

ptrblck: <p>The install logs should show which binary is selected so make sure the one with the desired CUDA runtime is found. I would guess that either the CPU-only binary was selected (for unknown reasons so far) or you might have multiple PyTorch binaries installed where one of them is the CPU-only binary.</p>

XuehaiPan: <p>You may explicitly install <code>pytorch-mutex</code> with <code>cuda</code> build. This works for me:</p>
<pre><code class="lang-bash">conda install pytorch::pytorch torchvision torchaudio pytorch::pytorch-cuda=11.7 "pytorch::pytorch-mutex=*=*cuda*" -c pytorch -c nvidia
</code></pre>
<p>It installs <code>pytorch::pytorch-mutex=*=*cuda*</code>.</p>

Valerio_Romano_Cadur: <p>How can I check that? I did all the steps I’ve done on a friends machine and on his everything is working fine. It is probably a matter of having several binaries as you were saying. Sorry for my ignorance.</p>

ptrblck: <p>Rerun <code>pip uninstall torch -y</code> and <code>conda uninstall pytorch -y</code> multiple times until neither can find any installed packages anymore. Then check it again via <code>pip list | grep torch</code> and the same for <code>conda</code>.</p>

Valerio_Romano_Cadur: <p>Thanks, I probably had done something really bad before, your assistance solved my problem. Have a nice day!</p>