Skip to content

Instantly share code, notes, and snippets.

@Quasimondo
Quasimondo / gist:7e1068e488e20f194d37ba80696b55d8
Last active December 9, 2023 09:17
A possible fix for "failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device"
This is a dreaded error that seems pop up its ugly head again and again, in particular after upgrading CUDA or Tensorflow.
Typcially it looks like this:
2020-12-30 17:31:40.829615: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2020-12-30 17:31:42.149768: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2020-12-30 17:31:42.150368: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2020-12-30 17:31:42.176643: E tensorflow/stream_executor/cuda/cuda_driver.cc:328] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
Here is a solution that currently seems to work on my system,
with Cuda 11.0 and Tensorflow 2.4.0, you can try it if all the
# This file is part of EAP.
#
# EAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# EAP is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the