I have a cuda-capable gpu in my computer, and the version is NVIDIA GeForce GTX 1660 Ti. The operating system is Windows10. According to the official website
https://pytorch.org/get-started/locally/
I opened anaconda prompt(anaconda 3) and entered the following line for installing pytorch
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
but when I enter this code in pycharm:
import torch
print(torch.cuda.is_available())
It returns False and this error appears:
UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at ..\c10\cuda\CUDAFunctions.cpp:115.)
return torch._C._cuda_getDeviceCount() > 0
Why is it like this? Doesn't this command
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
by default try to install cuda version if i have a cuda-capable gpu?
This is the output of nvidia-smi
Related
Whenever I try to move a variable to cuda in pytorch (e.g. torch.zeros(1).cuda(), I get the error message "AssertionError: Torch not compiled with CUDA enabled". Besides,torch.cuda.is_available() returns False.
I have read several answers to approaching this error but for some reason several attempts to reinstall cuda and putorch didn't change anything. Here are some of the settings I used:
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
conda install pytorch torchvision cudatoolkit=11 -c pytorch-nightly
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
Yet the same error remains. What could be the issue?
Some settings:
I'm using Ubuntu 20.04, GPU is RTX 2080, nvidia-smi works fine (NVIDIA-SMI 460.91.03, Driver Version: 460.91.03, (max possible) CUDA Version: 11.2)
Try installing with pip
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
You can go through this thread for detailed explanations
Pytorch for cuda 11.2
My codes were working fine before but suddenly they stop working, without any error or warning.
this is the setting they were working fine.
After that, I have tried multiple options below
My current settings are in 1 env:
torch 1.10.0+cu113
torch-cluster 1.5.9
torch-geometric 2.0.1
torch-scatter 2.0.9
torch-sparse 0.6.12
torch-spline-conv 1.2.1
torchaudio 0.10.0+cu113
torchvision 0.11.1+cu113
but nothing worked. Even I asked my server admin to create a new account for me. he created a new account and I just installed the below packages. These are the total packages installed in my conda env.
installation by
pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f download.pytorch.org/whl/torch_stable.html
Package Version
----------------- ------------
certifi 2021.10.8
numpy 1.21.4
Pillow 8.4.0
pip 21.2.2
setuptools 58.0.4
torch 1.9.0+cu111
torchaudio 0.9.0
torchvision 0.10.0+cu111
typing_extensions 4.0.1
wheel 0.37.0
Here are the results: My code is always stuck here.
What could be a possible reason?, while my labmate with same setting and same server executed the same code on his user profile, it was ok.
Further Details:
torch.cuda.is_available()
>>> True
torch.cuda.current_device()
>>> 0
torch.cuda.device(0)
>>> <torch.cuda.device at 0x7fb4e8baa650>
torch.cuda.device_count()
>>> 4
torch.cuda.get_device_name(0)
>>> 'GeForce RTX 3090'
I have the same type of problems, but with RTX 3060. I think the problem is the torch version.
Using torch == 1.11.0, I can move tensors to GPU, but with pastest versions can't do this.
Torch Geometric don't use torch=1.11.0 at the time I'm writing.
NVIDIA GeForce RTX 3060 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3060 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
Has anyone encountered this?
I tried updating drivers and reinstalling cuda
Cuda Version: 11.4
GPU: GeForce RTX 3060 Laptop(6gb)
OS: Windows 10 home
torch.version: 1.9.0+cpu
You are using a PyTorch version compiled for CPU, you should install the appropriate version instead:
Using conda:
conda install pytorch torchvision cudatoolkit=11.1 -c pytorch -c conda-forge
Using pip:
python -m pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
For others who find this: torch.cuda.is_available() doesn't give any debugging information, but if you try to use CUDA anyway, you'll get a more informative error message:
>>> import torch
>>> torch.zeros(1).cuda()
Another answer with much more details: https://stackoverflow.com/a/61034368/69707
If you have a different CUDA version than the offered in the command selection tool to install Pytorch, I recommend you to install the nightly binaries:
This worked for me having the cuda version 11.6:
pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu114
I have anaconda3 installed on my windows10 system and I want to install pytorch using anaconda.
I was looking at the official website
https://pytorch.org/get-started/locally/
where I see only the versions 10.2 and 11.1 for cuda are written in the selector. Now, I know I have a cuda-capable gpu in my computer, and the version is NVIDIA GeForce GTX 1660 Ti.
I was also checking nvidia website for finding out the compute capability of my gpu so that I can select the appropriate one in the installation. Here's the link:
https://developer.nvidia.com/cuda-gpus#compute
As you see, the compute capability of all the versions is at most 8.7 ( Mine was 7.5 )
Does this mean I can't use this command for installing pytorch?
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
Or can I use this command? and they won't cause a problem?
I have tried several solutions which hinted at what to do when the CUDA GPU is available and CUDA is installed but the Torch.cuda.is_available() returns False. They did help but only temporarily, meaning torch.cuda-is_available() reported True but after some time, it switched back to False. I use CUDA 9.0.176 and GTX 1080. What should I do to get the permanent effect?
I tried the following methods:
https://forums.fast.ai/t/torch-cuda-is-available-returns-false/16721/5
https://github.com/pytorch/pytorch/issues/15612
Note: When torch.cuda.is_available() works fine but then at some point switches to False, then I have to restart the computer and then it works again (for some time).
The reason for torch.cuda.is_available() resulting False is the incompatibility between the versions of pytorch and cudatoolkit.
As on Jun-2022, the current version of pytorch is compatible with cudatoolkit=11.3 whereas the current cuda toolkit version = 11.7. Source
Solution:
Uninstall Pytorch for a fresh installation. You cannot install an old version on top of a new version without force installation (using pip install --upgrade --force-reinstall <package_name>.
Run conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch to install pytorch.
Install CUDA 11.3 version from https://developer.nvidia.com/cuda-11.3.0-download-archive.
You are good to go.
Also with torch.cuda.is_available () had false.
But when installing the Nvidia driver to the most updated version 436.48, True is displayed. I previously updated Pytorch to 1.2.0.
I have windows 10 and Anaconda.
Install CUDA 9.1 using apt-get, following the instructions in this link:
https://cryptoandcoffee.com/mining-gems/cuda-9-0-install-ubuntu-16-04-apt-get/
Installed PyTorch using pip:
pip install torchvision ( this will install both torch and torchvision )
Rebooted
Now try it:
~$ python -c 'import torch; print torch.cuda.is_available()'
I saw this issue as well. The reason was the CUDA version used by Pytorch being out of sync with the installed Nvidia driver. As in Joe's answer, the solution was updating the Nvidia drivers. Some other important background info to be aware of:
Each release of CUDA requires a minimum Nvidia driver version (see here for a compatibility table).
You can check your Nvidia driver version with nvidia-smi.
Pytorch comes pre-packaged with a version of CUDA that may be different from the version you installed on your computer.
The CUDA version that you installed manually is the one shows up when you run nvidia-smi. Even if your driver version is compatible with this CUDA version, it may be incompatible with the Pytorch CUDA version.
You can get the Pytorch CUDA version by printing the torch.version.cuda variable in ipython or in a Python program. This is the version that determines the needed Nvidia driver version.