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

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

Related

pytorch unable to run inference with GPU

I'm developing a project based on yolov7, but I started facing this error where torch recognizes my GPU but torchvision throws an Not Implemented Error.
This is the error
NotImplementedError: Could not run 'torchvision::nms' with arguments from the 'CUDA' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'torchvision::nms' is only available for these backends: [CPU, QuantizedCPU, BackendSelect, Python, FuncTorchDynamicLayerBackMode, Functionalize, Named, Conjugate, Negative, ZeroTensor, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradMPS, AutogradXPU, AutogradHPU, AutogradLazy, Tracer, AutocastCPU, AutocastCUDA, FuncTorchBatched, FuncTorchVmapMode, Batched, VmapMode, FuncTorchGradWrapper, PythonTLSSnapshot, FuncTorchDynamicLayerFrontMode, PythonDispatcher].
I tried installing torchvision with cuda built-in but that gave me the same error, also tried reinstalling pytorch , that didn't work either
the version of torch vision installed in my env was not equipped with cuda as it was a common install with pip with pip install torchvision whereas for torchvision to function with cuda it has to be equipped with cuda in-order for it to function with an Nvidia GPU to do so install torch with the following command conda install pytorch torchvision torchaudio pytorch-cuda={CUDA version} -c pytorch -c nvidia

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

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']

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")

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.

Tensorflow is creating an error on the proto-files

Background:
Purpose is to develop a machine learning algorithm involving tensorflow.
Problem:
Importing tensorflow results in the error: "invalid proto descriptor for file "tensorboard/compat/proto/resource_handle.proto"" (see error log after my code at the end.)
Action taken:
Tried running pip uninstall protobuf. Next, pip install --no-binary protobuf protobuf.
But, that creates a second error that there is "no google protobuf. If I install protobufs I run into the first error again.
Platform:
Ubuntu 18.10, v 64 bit forGPU. Python 3.6.8.
My Code:
import tensorflow-nightly-gpu #(regardless of version of tf I get the error)
import pandas as pd
...
Error Log:
Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file
"tensorboard/compat/proto/resource_handle.proto":
tensorboard.ResourceHandleProto.device: "tensorboard.ResourceHandleProto.device" is already defined in file "tensorboard/src/resource_handle.proto".
tensorboard.ResourceHandleProto.container: "tensorboard.ResourceHandleProto.container" is already defined in file "tensorboard/src/resource_handle.proto".
tensorboard.ResourceHandleProto.name: "tensorboard.ResourceHandleProto.name" is already defined in file "tensorboard/src/resource_handle.proto".
tensorboard.ResourceHandleProto.hash_code: "tensorboard.ResourceHandleProto.hash_code" is already defined in file "tensorboard/src/resource_handle.proto".
tensorboard.ResourceHandleProto.maybe_type_name: "tensorboard.ResourceHandleProto.maybe_type_name" is already defined in file "tensorboard/src/resource_handle.proto".
Solved my own problem with these steps:
1.Remove all existing GPU, CUDA, CUDNN drivers and remove all tensorflow from my computer
Install drivers for GPU, CUDA, CUDNN with instructions here, https://www.tensorflow.org/install/gpu
Install tensorflow from here, phttps://www.tensorflow.org/install/pip

Resources