PyTorch Installation-RTX 3060

Hello, I have been working diligently to install Pytorch but I haven’t been successful so far. Here’s the summary of my situation:
Using NVIDIA RTX 3060 GPU (with the latest updates).
Installed CUDA 11.7, cuDNN 8.9.3, running Python 3.8.17 on my conda environment.
Correct Paths are set in the environment variables.

Tried the following commands to install Pytorch:

  1. conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
  2. pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
  3. conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.7 -c pytorch -c nvidia
    4)conda install pytorch torchvision torchaudio -c pytorch

Neither of them work and getting the same errors as following:
AssertionError: Torch not compiled with CUDA enabled
GPU not available, using CPU.
cuDNN Version: None

Could you please assist me in diagnosing and resolving this issue?
Thanks a lot

The error message explains that you’ve installed the CPU-only binary. A simple pip install torch install command will install 2.0.1+cu117 and will work on your GPU.

1 Like

Thanks a lot for your message.
I just created a new environment and installed:
pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 --extra-index-url https://download.pytorch.org/whl/cu117

But again getting the same error and doesn’t recognize the GPU. So weird!

Could you post the install log here so that I could have a look at it, please?

I am not sure if you are asking for this, but hope this is the one:

Using pip 23.2.1 from C:\Users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages\pip (python 3.8)
Looking in indexes: Simple index, https://download.pytorch.org/whl/cu117
Requirement already satisfied: torch==2.0.1+cu117 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (2.0.1+cu117)
Requirement already satisfied: torchvision==0.15.2+cu117 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (0.15.2+cu117)
Requirement already satisfied: filelock in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torch==2.0.1+cu117) (3.12.3)
Requirement already satisfied: typing-extensions in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torch==2.0.1+cu117) (4.7.1)
Requirement already satisfied: sympy in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torch==2.0.1+cu117) (1.12)
Requirement already satisfied: networkx in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torch==2.0.1+cu117) (3.1)
Requirement already satisfied: jinja2 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torch==2.0.1+cu117) (3.1.2)
Requirement already satisfied: numpy in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torchvision==0.15.2+cu117) (1.24.4)
Requirement already satisfied: requests in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torchvision==0.15.2+cu117) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from torchvision==0.15.2+cu117) (10.0.0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from jinja2->torch==2.0.1+cu117) (2.1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from requests->torchvision==0.15.2+cu117) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from requests->torchvision==0.15.2+cu117) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from requests->torchvision==0.15.2+cu117) (2.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from requests->torchvision==0.15.2+cu117) (2023.7.22)
Requirement already satisfied: mpmath>=0.19 in c:\users\seyed\anaconda3\envs\pytorch_rtx\lib\site-packages (from sympy->torch==2.0.1+cu117) (1.3.0)


nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:59:34_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0

import torch
print(torch.version)
2.0.1+cu117


Python 3.8.17 (default, Jul 5 2023, 20:44:21) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.

2.0.1+cu117 is already installed. What does this return:

import torch
print(torch.__version__)
print(torch.version.cuda)
print(torch.randn(1).cuda())

2.0.1+cpu
None
AssertionError: Torch not compiled with CUDA enabled

Your environment is apparently mixing up different PyTorch installations since the install log shows 2.0.1+cu117 while now it’s printing 2.0.1+cpu.
Uninstall all PyTorch binaries until pip and conda complain they cannot find any installation and install a single binary with the CUDA dependencies once.

Thank you so much. I uninstalled all PyTorch binaries from all environments, created a new environment, and installed version 2.0.1+cu117. Finally, I achieved the desired results:

2.0.1+cu117
11.7
tensor([0.4651], device=‘cuda:0’)

However, I encountered the same error when using Jupyter Notebook. But, it’s now working perfectly in PyCharm, and I’m pretty happy about it.
Thanks again for your help.

Great! Your Jupyter environment might still use another PyTorch binary. You could check and compare the paths via print(torch.__path__) between the working and failing environment.

1 Like

Sure, will do. thanks a lot!