TensorFlow – failed call to cuInit: CUDA_ERROR_UNKNOWN

Scenario: You’re trying to get your GPU to work in TensorFlow on a Ubuntu Laptop. You’ve already installed Tensorflow, Cuda, and Nvidia drivers.

You run python and import TensorFlow:

import tensorflow as tf

And you see encouraging messages like: "successfully opened CUDA library libcublas.so locally"

But in Python, when you run,

tf.Session()

You get this cryptic error:

failed call to cuInit: CUDA_ERROR_UNKNOWN

Here’s how to fix this.

The Solution

The solution is from here (given by user: urvishparikh)

From the command prompt, run:

sudo apt-get install nvidia-modprobe

Start python and try Tensorflow again:

import tensorflow as tf
tf.Session()

And you should get an output message showing your GPU

name: GeForce GTX 860M
Total memory: 1.99GiB
Free memory: 1.95GiB

Yay!

2 thoughts on “TensorFlow – failed call to cuInit: CUDA_ERROR_UNKNOWN”

Questions/comments? If you just want to say thanks, consider sharing this article or following me on Twitter!