Torch.cuda.is_available() -> False

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.

I saw that you helped many to solve the same issue so I tagged you hope not to bother.
@ptrblck
Best,

Valerio

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.

Could you post the output of python -m torch.utils.collect_env here by wrapping it into three backticks ``` instead of posting screenshots, please?

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 <module>
    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>``` 
Thanks for your time and availability.

Could you download the file manually and execute it:

wget https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py
python collect_env.py
--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%[=================================================>]  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>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>```

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

Thanks for the update.
Based on the output you have installed the CPU-only binary:

PyTorch version: 2.0.0+cpu

which explains why you won’t be able to use the GPU.

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 conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia found on pytorch.org.
How can I solve?

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.

You may explicitly install pytorch-mutex with cuda build. This works for me:

conda install pytorch::pytorch torchvision torchaudio pytorch::pytorch-cuda=11.7 "pytorch::pytorch-mutex=*=*cuda*" -c pytorch -c nvidia

It installs pytorch::pytorch-mutex=*=*cuda*.

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.

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

Thanks, I probably had done something really bad before, your assistance solved my problem. Have a nice day!