Help us understand the problem. What is going on with this article?

Ubuntu 16.04+CUDA 8.0+Tensorflow 環境で起きるlibcudartが見つからない問題を解決する

More than 3 years have passed since last update.

Ubuntu 16.04 + GTX1080 + Tensorflow v0.10 が使えていたのに、急に以下のエラーが出るようになってしまった。

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/val/.pyenv/versions/anaconda3-4.1.1/envs/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/home/val/.pyenv/versions/anaconda3-4.1.1/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 48, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/val/.pyenv/versions/anaconda3-4.1.1/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/val/.pyenv/versions/anaconda3-4.1.1/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
  File "/home/val/.pyenv/versions/anaconda3-4.1.1/envs/tensorflow/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/val/.pyenv/versions/anaconda3-4.1.1/envs/tensorflow/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory

CUDA 8.0 を入れた状態で動いていた(つまりCUDA 7.5は入れていない)のにどうして急に7.5のlibcudartを欲しがるようになってしまったのか謎。。

困っていろいろやってみたもののだめ。Tensorflow の再インストールが必要かと思い公式のページ( https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html )のAnaconda install を見ていると、たしかにv0.10のところのコメントにはCUDA 7.5が必要とある。

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.5
# Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp35-cp35m-linux_x86_64.whl

で、r0.11がリリースになっていたので見てみると、コメントが変わっていてCUDA toolkit 8.0 が必要、とある。これを見て、思い切ってv.0.11にアップデートしてみた。

 Ubuntu/Linux 64-bit, GPU enabled, Python 3.5
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Install from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0-cp35-cp35m-linux_x86_64.whl
# Python 3
(tensorflow)$ pip3 install --ignore-installed --upgrade $TF_BINARY_URL

source activate して実行してみると、なんと成功!

>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally

というわけで、CUDA 8.0 を入れたひとは、r0.11以上を使うのがよさそう。

kei_bility
Research field: Image Processing, CG, CV, Machine Learning Research interest: Illustration Style, Image recognition of cooking recipe, Deep Learning, ...etc.
http://www.val.cs.tut.ac.jp/~yamaya/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away