Torch.cuda.is_available() returns false even with compatible graphics card

I am trying to install PyTorch through anaconda on my machine (runs on Linux, my graphics card is NVIDIA GTX 1080 Ti) using this command:
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
However, even though the installation seems right, the torch.cuda.is_available() command returns False. I checked my driver version and card and they are supposed to be compatible with CUDA 10.2. Here’s what I my nvidia-smi command returns:

±----------------------------------------------------------------------------+
| NVIDIA-SMI 440.36 Driver Version: 440.36 CUDA Version: 10.2 |
±----------------------------------------------------------------------------+

I even tried to downgrade and use earlier version of PyTorch using this command:
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

However, downgrading didn’t work either. After searching stuffs online and trying different methods, I am lost at this point. Any help will be highly appreciated.

I’ve seen a similar problem when I had an incorrect version of CUDA installed/multiple pytorch installations. I am not sure if the same problem applies to you.

First uninstall all existing versions of torch (pip uninstall torch). It’s possible that multiple torch installations exist in the same conda environment (installed through pip and conda). Ensure that you remove all of them first. If you don’t mind installing torch==1.5.1, installl pytorch using:

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

The above worked for me in a python 3.6 conda environment.

There are other threads that report the same problem: https://github.com/pytorch/pytorch/issues/6041

The conda environment is a new installation in this machine, so there should not be any PyTorch, except my own installed one. The conda list command shows only one PyTorch.

However, I removed my PyTorch and run your suggested command. The problem still exists.