ImportError:libcudart.so.8.0:无法打开共享对象文件:没有这样的文件或目录

时间:2017-04-01 22:26:26

标签: tensorflow keras

我正在尝试在我的系统上使用tensorflow-gpu。我重新安装了很多次,它给出了下面的错误。但是当我使用tensorflow-cpu时它工作正常。我安装了cuda 8.0工具包和cudnn 5.1。

  Traceback (most recent call last):
  File "finetune.py", line 17, in <module>
    import tensorflow as tf
  File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

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

3 个答案:

答案 0 :(得分:5)

如果更改路径变量不起作用,在终端中运行以下内容通常可以解决这个问题:

@RequestMapping(value="/imageUpload", method = RequestMethod.POST)
    public void UploadFile(@RequestParam("file") MultipartFile file,RedirectAttributes redirectAttributes) throws IOException {
        System.out.println("file uploading ...............");
        /*
        Iterator<String> itr=request.getFileNames();
        MultipartFile file=request.getFile(itr.next());
        String fileName=file.getOriginalFilename();
        File dir = new File("C:\\file");
        if (dir.isDirectory())
        {
            File serverFile = new File(dir,fileName);
            BufferedOutputStream stream = new BufferedOutputStream(
                    new FileOutputStream(serverFile));
            stream.write(file.getBytes());
            stream.close();
        }else {
            System.out.println("not");
        }
        */
    }

(有时sudo ldconfig /usr/local/cuda/lib64 可能需要cuda,具体取决于您的安装方式)

答案 1 :(得分:4)

问题是您没有设置环境变量CUDA_HOME。如果您认为已安装CUDA,则需要确保上述环境变量设置为prob = perly,并包含所有共享库所在的CUDA安装目录的地址。

export CUDA_HOME=/CUDA/installation/path
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"

答案 2 :(得分:0)

sudo ldconfig / usr / local / cuda / lib64

适合我。

请参阅此链接以获取更多信息。 https://github.com/tensorflow/tensorflow/issues/5343