When I try to run this command "import keras" I got this error:
Invalid value ("cpu") for configuration variable "gpu". Valid options start with one of "device", "opencl", "cuda"
Both Keras and Theano are updated to the latest version.
Here is THEANO_FlAGS env variable:
"floatX=float32,device=gpu,nvcc.fastmath=True,lib.cnmem=0.6,nvcc.flags=-D_FORCE_INLINES"
I also tried "device=cuda" and "device=cuda0" now I'm getting this error:
C:\Users\Ibrahim Amer\Anaconda\lib\site-packages\theano\configdefaults.py:1711:
UserWarning: Theano does not recognise this flag: lib.cnmem
warnings.warn('Theano does not recognise this flag: {0}'.format(key))
C:\Users\Ibrahim Amer\Anaconda\lib\site-packages\theano\configdefaults.py:1711:
UserWarning: Theano does not recognise this flag: nvcc.fastmath
warnings.warn('Theano does not recognise this flag: {0}'.format(key))
C:\Users\Ibrahim Amer\Anaconda\lib\site-packages\theano\configdefaults.py:1711:
UserWarning: Theano does not recognise this flag: nvcc.flags
warnings.warn('Theano does not recognise this flag: {0}'.format(key))
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
File "C:\Users\Ibrahim Amer\Anaconda\lib\site-packages\theano\gpuarray__init_
_.py", line 175, in
use(config.device)
File "C:\Users\Ibrahim Amer\Anaconda\lib\site-packages\theano\gpuarray__init_
_.py", line 162, in use
init_dev(device, preallocate=preallocate)
File "C:\Users\Ibrahim Amer\Anaconda\lib\site-packages\theano\gpuarray__init_
_.py", line 65, in init_dev
sched=config.gpuarray.sched)
File "pygpu\gpuarray.pyx", line 614, in pygpu.gpuarray.init (pygpu/gpuarray.c:
9415)
File "pygpu\gpuarray.pyx", line 566, in pygpu.gpuarray.pygpu_init (pygpu/gpuar
ray.c:9106)
File "pygpu\gpuarray.pyx", line 1021, in pygpu.gpuarray.GpuContext.__cinit__ (
pygpu/gpuarray.c:13468)
GpuArrayException: Error loading library: 0
When I try to run this code I get "used the cpu":
`vlen = 10 * 30 * 768 # 10 x #cores x # threads per core
iters = 1000
rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], tensor.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in range(iters):
r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, tensor.Elemwise) and
('Gpu' not in type(x.op).__name__)
for x in f.maker.fgraph.toposort()]):
print('Used the cpu')
else:
print('Used the gpu')`
Windows 7, NVIDIA 1060 6GB
CUDA 7.5
Graphics Driver: 378.92
I just upgraded both keras and theano to the latest version and I get this error too.
Yes, started having the very same problem just today! Please fix! Run with flags
THEANO_FLAGS='floatX = float32, device = cuda0'
get
ValueError: Invalid value ("cpu") for configuration variable "gpu0". Valid options start with one of "device", "opencl", "cuda"
Ubuntu 16.04, NVIDIA GeForce GTX 560 Ti, CUDA 8.0
Best solution is to install the new backend for Theano: http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install
and then have device = cuda0 (or whatever appropriate number) in the .theanorc
Same problem
I've got the same problem.Could you please suggest any other idea?
Me too! I'll try to dig into it! Any help will be appreciated!
I installed the new backend and it worked
You mean you reinstall theano? Can you post the link with instructions?
No need to reinstall theano, just install the new backend, see the link above by the-moliver
I have installed the new backend but it didn't work
You should change "gpu0" to "cuda0". It worked for me.
Same issue. On Windows, issue started after upgrading theano 0.8.2 to 0.9.0 latest branch. Installing new backend didn't work, changing "gpu0" to "cuda" or "cuda0" didn't work. Removing the .theanorc didn't work. Rolling back to theano 0.8.2 fixes the problem, but how do I get 0.9.0 latest branch to work?
Edit: I had upgraded to the latest theano branch as of this comment, not stable 0.9.0. Switching to 0.9.0 does work with the old settings, though the problem still stands if I want to use the latest branch with windows.
You will have a lot of problems with windows.I suggest you to use another OS.The "cuda0" helped for many people.
Here is what I did to fix the problem:
1- Install pygpu library using this command: conda install Theano pygpu
2- Download mingw64 package from here, extract it to C:\ drive then add C:\mingw64\bin to PATH env variable
3- THEANO_FLAGS = "floatX=float32,device=cuda0"
Now everything is working fine using the GPU
I'm running an LSTM but I was having this issue until I pip installed theano-lstm. Using device=gpu0 in my .theanorc. I am not using conda so the above options were just complicating things for me.
Hope this helps at least a few.
I resolved my issue on Windows. I had THEANO_FLAGS set as a system environment variable with the line device=gpu, which was overriding my .theanorc file settings. I'm guessing the stable 0.9.0 version allowed for either gpu or cuda0, but the latest branch does not. Anyway, deleting the environment variable allowed my theanorc settings to go through and it works fine now.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
Most helpful comment
Best solution is to install the new backend for Theano: http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install
and then have
device = cuda0(or whatever appropriate number) in the .theanorc