RuntimeError: Could not load cudnn library. Check your cudnn installation. Maybe using the Theano flag dnn.base_path can help you - theano

enter image description here
I don't know how to solve the problem, although I searched google.
My computer OS is win10. And following installed in a virtual environment.
enter image description here
enter image description here
UserWarning: Your cuDNN version is more recent than
Theano. If you encounter problems, try updating Theano or downgrading cuDNN to a version >= v5 and <= v7.
  warnings.warn("Your cuDNN version is more recent than "
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
RuntimeError: Could not load cudnn library. Check your cudnn installation. Maybe using the Theano flag dnn.base_path can help you. Current value "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1"

I had the same problem, and I solved it like this:
Open dnn.py.
(My path is : F:\Anaconda3\envs\python2_7\Lib\site-packages\theano)
Add 'cudnn64_8.dll' in WIN32_CUDNN_NAMES. WIN32_CUDNN_NAMES = ['cudnn64_8.dll', 'cudnn64_7.dll', 'cudnn64_6.dll', 'cudnn64_5.dll']

Related

RuntimeError: CuDNN error: CUDNN_STATUS_SUCCESS

I am running code that UI downloaded from github. It is supposed to be working (I saw that other people managed to activate it). When I try to run it I get the following error message:
RuntimeError: CuDNN error: CUDNN_STATUS_SUCCESS
The code uses pytorch 0.4.1. I have cuda installed.
When I run the command cat /usr/local/cuda/version.txt
I get the answer:
CUDA Version 10.0.130
When I run the command conda list -n <my env name>
I see:
cudatoolkit ver 9.0
cudnn ver 7.6.5
And now, my question:
What should I do to avoid this error?
Do I need to use pip install for a more recent version of cudnn? If so, which one?
I also faced the same issue. In my case, the PyTorch version was 0.4.1, and the Cuda version was 9.0. I solved the issue by adding this piece of code:
torch.backends.cudnn.benchmark = True
try this
if torch.cuda.is_available():
device = torch.device("cuda")
print("working on gpu")
else:
device = torch.device("cpu")
print("working on cpu")

Unable to load model trained on Pytotch version 1.6.0 in Pytorch version 1.5.1

I have recently updated my Pytorch version to 1.6.0 on my local machine to use their mixed-precision training, since then I am encountering this issue, I have tried the solution mentioned here, but it is still throwing below error.
RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /opt/conda/conda-bld/pytorch_1591914880026/work/caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 4, but the maximum supported version for reading is 3. Your PyTorch installation may be too old.
Link to reproduce: https://www.kaggle.com/rohitsingh9990/error-reproducing-code?scriptVersionId=37468859
Any help will be appreciated, thanks in advance.
In torch.__version__ == 1.6.0 :
torch.save(model_.state_dict(), 'best_model.pth.tar', use_new_zipfile_serialization=False)
then in torch.__version__ == 1.5.1:
torch.load('best_model.pth.tar',map_location='cpu')

Dlib ImportError in Windows 10 on line _dlib_pybind11 import *, DLL Load Failed

I am able to successfully install Dlib with CUDA support in Windows 10 but getting an error during "import dlib" in my python code of computer vision project.
Environment: Windows 10, Python 3.7.6 (Anaconda), CUDA 11, CuDNN 10.2
Error Message:
>>> import dlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\dlib-19.20.99-py3.7-win-amd64.egg\dlib\__init__.py", line 12, in <module>
from _dlib_pybind11 import *
ImportError: DLL load failed: The specified module could not be found.
This can be solved by copying the cudnn64_7.dll (available here: https://developer.nvidia.com/cudnn)
into the %CUDA_PATH%/bin directory (probably something like this: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin)
I am able to find and fix this issue. CUDA 11 installation wasn't able to add few of the directories into the PATH environment variable (Windows 10). It was truncated due to the max length of 2048 characters. I have removed a few of the unused software paths from PATH value and after reinstallation, dlib 19.20 is working with CUDA 11 now.
I created an issue on DLIB Github under the following link which has more information regarding error logs and snapshots for this issue.
https://github.com/davisking/dlib/issues/2097
In my environment, the problem was due to an error somewhere in the build process that resulted code to load CuDNN dynamic libraries not being included in the generated file dlib/__init__.py despite having no build error. In my case the file always included this strange block of code:
if 'OFF' == 'ON':
add_lib_to_dll_path('cudnn-NOTFOUND')
add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5/lib/x64/cudart.lib')
The second line's cudnn-NOTFOUND gave a clue of what happened with my build.
As I followed instructions on this page, copying all the binaries and include files to the right places within the CUDA directory, I only needed to modify the code to (similar to what Epic Chen's answer suggests but I got rid of the if clause and the bad code line):
add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5/lib/x64/cudart.lib')
That workaround fixed the problem for me.
My configuration is CUDA 11.5, CuDNN 8.3.1.22, dlib compiled using Visual Studio 2019. The environment variable CMAKE_PREFIX_PATH to the CuDNN directory to get the compiler to find the include files and libraries.
If you are using Anaconda, uninstall dlib and reinstall dlib.
In anaconda command prompt, type
pip uninstall dlib
After successfully uninstalling, type
pip install dlib
It helped me fix the problem.
Try to check the __init__.py file which the error message indicate as below.
Your path is not the same as me.
In the __init__.py file, the if statement should be 'ON' == 'ON'
Besides, the following library paths must be correct. Your version may not be the same as me.

OpenCL error using Python 3.6 on Windows 10

I am trying to use PyOpenCL for the first time on Windows 10 (64 bit) to accelerate some code using my GPU. When trying to import pyopencl I get the error:
File "C:\Users\me\Anaconda3\lib\site-packages\pyopencl\__init__.py", line 39, in <module>
import pyopencl._cl as _cl
ImportError: DLL load failed: The specified module could not be found."
I am using Python 3.6.8 and have the pyopencl 2018.2.5+cl21 package installed.
I have also just installed the latest CUDA toolkit cuda.10.1.105 and Visual Studio as recommended during the CUDA toolkit installation.
The OpenCl.dll file in the Windows\system32 folder, is the 2.2.1.0 file version. I checked this by going into Computer Management clicking on my Nvidia GeForce GTX 1050 display adaptor.
From other post recommednations, I have tried substituting the OpenCl.dll file by others found in my system (see photo) without results. I have then reverted to the original file located in that folder.
Image for search results of 'OpenCl.dll'
I have also downloaded from and installed pyopencl‑2018.2.5+cl21‑cp36‑cp36m‑win_amd64.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl, without success. The error keeps popping up.
I am completely new to OpenCL, CUDA etc. Please forgive me if the error is easy to solve. Thank you for your help and please let me know if you need any other information.

Theano 0.10: Can not use cuDNN on context None: cannot compile with cuDNN

I just updated theano to 0.10 version with pip:
pip install --no-deps git+https://github.com/Theano/Theano.git#egg=Theano
But it cannot be imported successfully, with the error message as follows:
Can not use cuDNN on context None: cannot compile with cuDNN.
We got this error: c:\users\yl~1\appdata\local\temp\try_flags_jbgv_m.c:4:19:  
fatal error: cudnn.h: No such file or directory compilation terminated.   
Mapped name None to device cuda: GeForce 940M (0000:01:00.0)
I haven't configured theano to use cudnn. I feel theano should works without it.
My .theanorc is:
Without the .theanorc file, theano works fine.
I have also posted this issue at:
https://github.com/Theano/Theano/issues/6063#issuecomment-310064365
The best solution I have is to bypass cudnn by add in the .theanorc:
[dnn]
enabled = False
but at the price of the decreased computation speed

Resources