Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

torch.cuda.is_available() is false after installed cuda 9.1. Anyone can help me out? #6098

Closed
HongweiLuan opened this issue Mar 29, 2018 · 13 comments
Labels
awaiting response (this tag is deprecated) This tag is deprecated while we figure out what to do with it

Comments

@HongweiLuan
Copy link

PyTorch GitHub Issues Guidelines

We like to limit our issues to bug reports and feature requests. If you have a question or would like help and support, please visit our forums: https://discuss.pytorch.org/

If you are submitting a feature request, please preface the title with [feature request].

When submitting a bug report, please include the following information (where relevant):

  • OS: Windows
  • PyTorch version: 0.4
  • How you installed PyTorch (conda, pip, source): source
  • Python version: 3.6
  • CUDA/cuDNN version: 9.1/7.1
  • GPU models and configuration: NVIDIA 940MX
  • GCC version (if compiling from source): MS visual studio 15 2017

In addition, including the following information will also be very helpful for us to diagnose the problem:

  • A script to reproduce the bug. Please try to provide as minimal of a test case as possible.
  • Error messages and/or stack traces of the bug
  • Context around what you are trying to do

Traceback (most recent call last):
File "C:/Users/hanyi/Downloads/Kaggle/20180306/build/mask-rcnn-resnet50-ver-01.a.tar/mask-rcnn-resnet50-ver-01.a/common.py", line 94, in
print ('\t\ttorch.backends.cudnn.version() =', torch.backends.cudnn.version())
File "C:\Users\hanyi\Anaconda3\lib\site-packages\torch\backends\cudnn_init_.py", line 65, in version
if libcudnn() is None:
File "C:\Users\hanyi\Anaconda3\lib\site-packages\torch\backends\cudnn_init
.py", line 53, in _libcudnn
compile_version = torch._C._cudnn_version()
AttributeError: module 'torch._C' has no attribute '_cudnn_version'

@peterjc123
Copy link
Collaborator

peterjc123 commented Mar 29, 2018

@HongweiLuan Could you please show me the code of your function definition of _libcudnn() in torch\backends\__init__.py?

@peterjc123
Copy link
Collaborator

peterjc123 commented Mar 29, 2018

@HongweiLuan And are you compiling a CUDA version? It will only happen when you are using a CPU-only package. Do you have cudnn in your CUDA 9.1 install?

@tobyclh
Copy link

tobyclh commented Mar 29, 2018

I am also having the same issue, on ubuntu (fresh install) compiling from source, master branch with cuda 9.1 and newest cudnn.
During installation both CUDA and CuDNN are detected by CMAKE.
And FYR


def _libcudnn():
    global lib, __cudnn_version
    if lib is None:
        if sys.platform == "win32":
            lib = find_cudnn_windows_lib()
        else:
            lib = ctypes.cdll.LoadLibrary(None)
        if hasattr(lib, 'cudnnGetErrorString'):
            lib.cudnnGetErrorString.restype = ctypes.c_char_p
            __cudnn_version = lib.cudnnGetVersion()
            compile_version = torch._C._cudnn_version()
            # Check that cuDNN major and minor versions match
            if (__cudnn_version // 100) != (compile_version // 100):
                raise RuntimeError(
                    'cuDNN version mismatch: PyTorch was compiled against {} '
                    'but linked against {}'.format(compile_version, __cudnn_version))
        else:
            lib = None
    return lib

@HongweiLuan
Copy link
Author

@peterjc123 Thank you very much for your response.

the code is below. I copied the source files of cudnn to cuda library. I also tried to cuda.find_nvcc() and find_cuda_version() from pytorch.tools.setup_helpers import cuda. This works. However, torch.cuda.is_available() gives me false. When I checked the code in the cuda.py, hasattr(torch._C, '_cuda_isDriverSufficient') also gives me false.

I am not sure whether torch._C is not working or my Driver is not updated. I tried to update it to M391 but it downgraded to 388 when I installed cuda 9.1.

Thanks

print('@%s: ' % os.path.basename(file))

if 1:
SEED = 35202 #1510302253 #int(time.time()) #
random.seed(SEED)
np.random.seed(SEED)
torch.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED)
print ('\tset random seed')
print ('\t\tSEED=%d'%SEED)

if 1:
torch.backends.cudnn.benchmark = True ##uses the inbuilt cudnn auto-tuner to find the fastest convolution algorithms. -
torch.backends.cudnn.enabled = True
print ('\tset cuda environment')
print ('\t\ttorch.version =', torch.version)
print ('\t\ttorch.version.cuda =', torch.version.cuda)
print ('\t\ttorch.backends.cudnn.version() =', torch.backends.cudnn.version())
try:
print ('\t\tos['CUDA_VISIBLE_DEVICES'] =',os.environ['CUDA_VISIBLE_DEVICES'])
NUM_CUDA_DEVICES = len(os.environ['CUDA_VISIBLE_DEVICES'].split(','))
except Exception:
print ('\t\tos['CUDA_VISIBLE_DEVICES'] =','None')
NUM_CUDA_DEVICES = 1

print ('\t\ttorch.cuda.device_count()      =', torch.cuda.device_count())
print ('\t\ttorch.cuda.current_device()    =', torch.cuda.current_device())

print('')

@tartavull
Copy link

+1

@soumith
Copy link
Member

soumith commented May 4, 2018

cuda 9.1 requires the latest nvidia driver. check if you have the lastest version.

@zou3519 zou3519 added the awaiting response (this tag is deprecated) This tag is deprecated while we figure out what to do with it label May 14, 2018
@GusSand
Copy link

GusSand commented Jul 25, 2018

I have the latest nvidia driver and still getting the same issue. I even installed the CUDA SDK. My laptop is a SurfaceBook running bash on ubuntu on Windows 10 which has a GPU.

Any suggestions?
BTW

torch.backends.cudnn.enabled()

returns true

thanks!

@vivekanandgoud
Copy link

+1

@peterjc123
Copy link
Collaborator

@GusSand Wait! Are you trying to use it under WSL? It is actually impossible at the moment because GPUs cannot be found under WSL. There is an issue (feature request) for this under WSL repo. However, since there is Windows support, why don't you just install it in the main Windows environment?

@vivekanandgoud
Copy link

issue fixed for me

windows 10
GPU 940 MAX
CUDA 9.0

installed CUDA tool kit https://developer.nvidia.com/cuda-downloads
replaced CUDANN libraries https://developer.nvidia.com/cudnn

Check if your CUDA_HOME, CUDA_PATH & CUDA_PATH_V8 is set up properly. If not add it.

then re install pytorch with cuda 90 compatibility https://pytorch.org/

......................................................................>
torch.cuda.is_available()
True

ref: https://medium.com/@viveksingh.heritage/how-to-install-tensorflow-gpu-version-with-jupyter-windows-10-in-8-easy-steps-8797547028a4

@RoyiAvital
Copy link

@vivekanandgoud ,
I have Windows 10 with CUDA 9.2 Installed.
All System Environment Variables are set.

Yet I still get:

In [1]: import torch
In [2]: torch.cuda.is_available()
Out[2]: False

Any idea?

@satybald
Copy link

I had the same issue with cuda.is_available(). In the end the issue is not pytorch related, it was coming of improper installation of cuda-toolkit. I have ubuntu 18.04 and Cuda 9.2. While runing ./deviceQuery in cuda samples I found that I have an nvidea driver 390; however, cuda 9.2 requires driver 396.xx. After re-installing the driver everything worked fine and torch.cuda.is_available() returns True

@mustaphaweather
Copy link

This worked for me on Linux:

1- Uninstall the package via pip:

pip uninstall setuptools

2- Reinstall using the following command:

conda install -c anaconda setuptools

@pietern pietern closed this as completed Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response (this tag is deprecated) This tag is deprecated while we figure out what to do with it
Projects
None yet
Development

No branches or pull requests

13 participants