Repository navigation
Description
Running b.gcr.io/tensorflow/tensorflow:latest-gpu having CUDA 7.0 installed on the host when I try to create the session it returns CUDA_ERROR_NO_DEVICE and was unable to find libcuda.so DSO loaded into this program but when the strange thing is that when the module is imported all the libraries are loaded correctly.
Log:
root@5b1e79697b49:~# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcublas.so.7.0 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcudnn.so.6.5 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcufft.so.7.0 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcuda.so locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcurand.so.7.0 locally
>>>
>>> with tf.Session() as sess:
... with tf.device("/gpu:0"):
... matrix1 = tf.constant([[3., 3.]])
... matrix2 = tf.constant([[2.],[2.]])
... product = tf.matmul(matrix1, matrix2)
... sess.run(product)
...
I tensorflow/core/common_runtime/local_device.cc:40] Local device intra op parallelism threads: 8
E tensorflow/stream_executor/cuda/cuda_driver.cc:481] failed call to cuInit: CUDA_ERROR_NO_DEVICE
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:114] retrieving CUDA diagnostic information for host: 5b1e79697b49
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:121] hostname: 5b1e79697b49
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:146] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:257] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 358.16 Mon Nov 16 19:25:55 PST 2015
GCC version: gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
"""
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:150] kernel reported version is: 358.16
I tensorflow/core/common_runtime/gpu/gpu_init.cc:127] DMA:
I tensorflow/core/common_runtime/direct_session.cc:58] Direct session inter op parallelism threads: 8
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 368, in run
results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 444, in _do_run
e.code)
tensorflow.python.framework.errors.InvalidArgumentError: Cannot assign a device to node 'Const_1': Could not satisfy explicit device specification '/gpu:0'
[[Node: Const_1 = Const[dtype=DT_FLOAT, value=Tensor<type: float shape: [2,1] values: 2 2>, _device="/gpu:0"]()]]
Caused by op u'Const_1', defined at:
File "<stdin>", line 4, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/constant_op.py", line 165, in constant
attrs={"value": tensor_value, "dtype": dtype_value}, name=name).outputs[0]
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1834, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1043, in __init__
self._traceback = _extract_stack()
>>>
Versions:
- OS:
CentOS Linux elease.2.1511(Core) - Kernel:
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux - GPU:
NVIDIA Corporation GM200 [GeForce GTX TITAN X] (rev a1) - Docker:
1.9.1
Env:
CUDA_HOME=/usr/local/cuda-7.0
LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:
Command:
docker run -it -v /usr/lib/x86_64-linux-gnu/libcudadevrt.a:/usr/lib/x86_64-linux-gnu/libcudadevrt.a -v /usr/lib/x86_64-linux-gnu/libcudart.so:/usr/lib/x86_64-linux-gnu/libcudart.so -v /usr/lib/x86_64-linux-gnu/libcudart.so.7.0:/usr/lib/x86_64-linux-gnu/libcudart.so.7.0 -v /usr/lib/x86_64-linux-gnu/libcudart.so.7.0.28:/usr/lib/x86_64-linux-gnu/libcudart.so.7.0.28 -v /usr/lib/x86_64-linux-gnu/libcudart_static.a:/usr/lib/x86_64-linux-gnu/libcudart_static.a -v /usr/lib/x86_64-linux-gnu/libcuda.so:/usr/lib/x86_64-linux-gnu/libcuda.so --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-modeset:/dev/nvidia-modeset b.gcr.io/tensorflow/tensorflow:latest-gpu
Activity
zheng-xq commentedon Jan 19, 2016
@mcuadros, TF docker has trouble finding your Cuda driver, not the Cuda libraries. Could you check?
Thanks.
ruffsl commentedon Jan 28, 2016
@mcuadros, the images taged with
-gpuare intended to be used with the nvidia-docker project, as you may well note the parent image they are built from,FROM nvidia/cuda:7.0-cudnn2-runtime. Go check out nvidia-docker wiki on how to get started and launch GPU enabeled containers. Cuda is already setup in the image, all your host needs is the nvidia driver, docker, and the nvidia-docker plugin.Looks like this wasn't yet made clear in the README.md, could a dev kindly touch that up?
mcuadros commentedon Jan 28, 2016
@ruffsl I will try to run it with nvidia-docker, to see if works.
In the documentation always speaks about the normal docker-engine and also the old bash to run tf with docker was running the normal command.
cancan101 commentedon Feb 2, 2016
I tried to start this using
nvidia-dockerand it still does not work:caisq commentedon Feb 2, 2016
Here are the debugging steps that I recently went through to get TensorFlow working (kind of) with GPU and Docker. (I say "kind of" because there are still some GPU-related bugs in Tensorflow, which caused some test failures and will likely cause some user-code errors in that regard as well).
See:
#952
#953
That said, here are the things you want to check on:
On the host, outside Docker, you have NVIDIA driver installed. If you have it installed, the binaries "nvidia-smi" and "nvidia-debugdump" ought to be available on the host. Make sure that the following two commands list your GPU:
nvidia-sminvidia-debugdump -lOn the host, the output of nvidia-smi tells you the version of the NVIDIA driver installed. It needs to be recent enough for your GPU. For example, on my machine, version 340 doesn't work, but version 352 does.
On the host, get the CUDA sample code and compile the deviceQuery binary:
http://docs.nvidia.com/cuda/cuda-samples/#axzz3z3C3lhk1
For this you'll need to install the CUDA toolkit, which includes the nvcc compiler and supporting libraries.
https://developer.nvidia.com/cuda-downloads
Once the deviceQuery binary is compiled, try to run it
./deviceQueryIf it fails, don't panic, just try
sudo ./deviceQueryThere are some file permissions issues related to NVIDIA devices in /dev that requires you to do sudo like the above for each boot cycle, for detailed dicussion, see:
https://devtalk.nvidia.com/default/topic/749939/cuda-is-not-active-unless-i-run-it-with-sudo-privillages-/
After this make sure that the following files are present in your docker, as they will be used by (the current version of) TensorFlow:
It is okay for NVIDIA driver to be unavailable inside the Docker, even though the CUDA Toolkit is required inside it.
Also, map a bunch of lib files, to make sure that cuda library files are visible inside the container
Now the NVIDIA docker container should be ready to run TensorFlow with GPU.
ruffsl commentedon Feb 4, 2016
@cancan101 , that's odd. Just did a fresh build of both cuda and tensorflow with
Dockerfile.devel-gpuand then got the same error you got:I checked to make sure the library was installed and ldconfig finds it just fine:
Is there a path missing somewhere?
I even tried the old images up on docker hub last repo modified 2 months ago and the b.gcr.io updated recently by adding in the new nvidia meta label:
for nvidia-docker, but still got the same error.
3XX0 commentedon Feb 4, 2016
@ruffsl I suppose you used
nvidia-dockergiven your paths.I quickly looked at the Tensorflow code, the DsoLoader tries to find
libcudainthird_party/gpus/cuda/driver/lib64. Not sure how it is supposed to end up there, butlibcudais not part of the CUDA toolkit so you can't rely on the standard CUDA path to find it.In the case of
nvidia-dockerit is mounted at runtime in/usr/local/nvidia/, you will need to add this location into the third_party search script.ruffsl commentedon Feb 5, 2016
Pardon the noise, but pinging @vrv @craigcitro or @jendap , do you know what the intended setup for tensorflow cuda paths are? Or perhaps what this feature is meant to address? I'm not sure how this
third_partypath is coming into play.vrv commentedon Feb 5, 2016
@zheng-xq, any ideas here?
craigcitro commentedon Feb 5, 2016
also pinging @ebrevdo who may have hit this more recently.
ebrevdo commentedon Feb 5, 2016
You have cuda_path set, maybe it should be CUDA_HOME?
ebrevdo commentedon Feb 5, 2016
Also add this to ld library path:
/usr/lib/x86_64-linux-gnu
14 remaining items
manjunaths commentedon Jul 13, 2016
I am using nvidia-docker and the latest everything on RHEL 7.2 and I still have this issue.
manju@o185i089:/lvol/manju$ docker run -it gcr.io/tensorflow/tensorflow:latest-devel-gpuUnable to find image 'gcr.io/tensorflow/tensorflow:latest-devel-gpu' locallylatest-devel-gpu: Pulling from tensorflow/tensorflow759d6771041e: Pull complete8836b825667b: Pull completec2f5e51744e6: Pull completea3ed95caeb02: Pull completed5b215eff347: Pull complete34d39ef2e894: Pull completea7a36155eb9e: Pull completeb1bfa35e6e17: Pull complete8210f508bb7c: Pull completefd02f6ca3839: Pull completec7e296ba93f3: Pull complete7b9159cc5928: Pull complete25abb1637a5a: Pull complete71595b8a5fcb: Pull complete00fa70dea9b1: Pull complete4c3f9ea22d7e: Pull complete077e0cee8ca6: Pull complete65b6e5754aad: Pull complete0811f4c80537: Pull completee0a07be9804b: Pull completec8e3ab48d3ab: Pull completecc5ff4523b24: Pull completeDigest: sha256:a38c40a95869d8e36380f88bb0682c77988d12cefd28d4e161093049a4bbb4b5Status: Downloaded newer image for gcr.io/tensorflow/tensorflow:latest-devel-gpuroot@40afc612354b:~#root@40afc612354b:~#root@40afc612354b:~# pythonPython 2.7.6 (default, Jun 22 2015, 17:58:13)[GCC 4.8.2] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import tensorflow as tfI tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locallyI tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locallyI tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locallyI tensorflow/stream_executor/dso_loader.cc:99] Couldn't open CUDA library libcuda.so.1. LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64:I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:121] hostname: 40afc612354bI tensorflow/stream_executor/cuda/cuda_diagnostics.cc:146] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this programI tensorflow/stream_executor/cuda/cuda_diagnostics.cc:257] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 352.93 Tue Apr 5 18:18:24 PDT 2016GCC version: gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)"""I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:150] kernel reported version is: 352.93I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1051] LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64:I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1052] failed to find libcuda.so on this system: Failed precondition: could not dlopen DSO: libcuda.so.1; dlerror: libcuda.so.1: cannot open shared object file: No such file or directoryI tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally>>>Is there a fix for this issue ?
RiemannianAnalyzer commentedon Jul 27, 2016
Did you guys find a solution to this issue? I am on dual Titan X. The error that I get is similar to the one reported above:
$ python input_data.py I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally E tensorflow/stream_executor/cuda/cuda_driver.cc:491] failed call to cuInit: CUDA_ERROR_NO_DEVICE I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:153] retrieving CUDA diagnostic information for host: maximus I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:160] hostname: maximus I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:185] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:347] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 340.96 Sun Nov 8 22:33:28 PST 2015 GCC version: gcc version 4.8.5 (Ubuntu 4.8.5-2ubuntu1~14.04.1) """ I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] kernel reported version is: 340.96.0 I tensorflow/core/common_runtime/gpu/gpu_init.cc:81] No GPU devices available on machine. Extracting MNIST_data/train-images-idx3-ubyte.gz Extracting MNIST_data/train-labels-idx1-ubyte.gz Extracting MNIST_data/t10k-images-idx3-ubyte.gz Extracting MNIST_data/t10k-labels-idx1-ubyte.gz 0.9092manjunaths commentedon Jul 27, 2016
RiemannianAnalyzer,
In my case the libcuda.so was not available in the container at the specified location. I was also using docker instead of nvidia-docker. I added in a libcuda* from the host machine into the cuda path (/usr/local/cuda/lib/*) and then froze the image. Now I no longer get the error, with the new image.
In your case, did your driver install successfully (Have you looked at the driver install log?) ? It seems that the cuda library is missing. Also I am using a more recent version of the driver than you are. I don't know if that makes a difference. In one of my machines I had to install cuda and other support libraries by myself, too.
HTH.
pulak09 commentedon Feb 1, 2019
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="0"
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA