Tag Archives: CUDA

[Solved] Error caused by correspondence between tensorflow GPU version number and CUDA

Preface

perception: CUDA 8.0 + cudnn 6.0 + tensorflow 1.3

cuda 9.0+cudnn 7.0+TensorFlow 1.7

python3.6.2+cuda 9.0+cudnn7.5+Tensorflow 1.10.0+Anaconda4.6.11

Recently, the GPU version of tensorflow has been re installed on a new workstation. At the beginning, it was easy to update to the latest version 1.13, and then input the Hello tensorflow program. However, the error “importerror: DLL load failed: unable to find the specified module” was reported. In desperation, all kinds of Baidu, seeing an old blog, proposed to reduce tensorflow version to 1.4, so they first unloaded and then reloaded it. After a modification, they reported an error of “could not find ‘cudart64″_ 80.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit ”The tensorflow version I installed is too low to support cuda8.0, but I installed cuda9.0, So there is a mismatch. Later, I uninstall the current tensorflow environment and specify to install version 1.7. This is a record to prevent future generations from stepping on the pit less

The following figures are all command line operations

Tensorflow version is too low, CUDA version is too high

The specific errors are as follows:

(tensorflow-gpu) C:\Users\WW>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check
    ctypes.WinDLL(build_info.cudart_dll_name)
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
    self_check.preload_check()
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\platform\self_check.py", line 82, in preload_check
    % (build_info.cudart_dll_name, build_info.cuda_version_number))
ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit

Tensorflow version is too high, CUDA version is too low

The specific errors are as follows:

(tensorflow-gpu) C:\Users\WW>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "D:\TensorFlow\Anaconda\Anaconda\envs\tensorflow-gpu\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

Correspondence between tensorflow and CUDA version

Attached are several forms:

For the latest version, please refer to tensorflow Chinese website: https://www.tensorflow.org/install/source#tested_source_configurations

Summary

Installation environment reference blog must pay attention to time, time, time. Maybe it could have been done at that time. Now it’s not necessarily OK. The version problem is really annoying

Don’t be greedy, update to the latest version, understand clearly in advance, and then install the corresponding version

[record a problem] Linux + opencv + cuvid decodes 1080p video. When using CUDA kernel function, it will crash

Explain the function of static keyword and final keyword in Java in detail>>>

The information about the crash is as follows:

1 OpenCV(4.1.0-dev) Error: Gpu API call (invalid configuration argument) in videoDecPostProcessFrame, file /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuda/nv12_to_rgb.cu, line 203
2 terminate called after throwing an instance of 'cv::Exception'
3   what():  OpenCV(4.1.0-dev) /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuda/nv12_to_rgb.cu:203: error: (-217:Gpu API call) invalid configuration argument in function 'videoDecPostProcessFrame'
4 
5 Aborted (core dumped)

The strange points are as follows:
1. The same program decodes 720p video/480p video and calls CUDA kernel function for further processing

2. 1080p video decodes the first frame and calculates it. It is normal

3. Write an empty kernel function, nothing is bad. 1080p video still has errors when decoding the second frame
it seems that it is not my own code pot, which can only be solved by submitting it to opencv team

==================================

Added at 15:00 on May 16, 2019, the problem has been solved

The key problem is that there are too many threads in the kernel function. I changed the code as follows:

1     if (rows>500){
2         _hsv_cacl_hist<<<1, rows/2>>>(data, cols, rows/2, step, channels, (uint32_t*)out->hist);
3         _hsv_cacl_hist<<<1, rows/2>>>(data+step*(rows/2), cols, rows/2, step, channels, (uint32_t*)out->hist);
4     } else {
5         _hsv_cacl_hist<<<1, rows>>>(data, cols, rows, step, channels, (uint32_t*)out->hist);
6     }

The above code solves the problem of crash

But the strange thing is, why not crash in this function, but in video decoding