Coder Social home page Coder Social logo

Comments (19)

Hazarapet avatar Hazarapet commented on August 20, 2024 5

I've already solved it.You should change "gpu0" to "cuda0"

from deep-learning-keras-tensorflow.

leriomaggio avatar leriomaggio commented on August 20, 2024 1

Ok I think I should probably improve the part in which I explain how to properly setup theano:

Since version 0.9 they finally introduced the libgpuarray which was previously only available in the development version.

These are the two options I came up with to properly install and configure theano on (ubuntu) Linux with GPU support:

  1. [If you're using Anaconda] conda install theano pygpu should be just fine!

Sometimes it is suggested to install pygpu using the conda-forge channel:

conda install -c conda-forge pygpu

  1. [Works with both Anaconda Python or Official CPython]

After Theano is installed:

echo "[global]
device = cuda
floatX = float32

[lib]
cnmem = 1.0" > ~/.theanorc

HTH

from deep-learning-keras-tensorflow.

leriomaggio avatar leriomaggio commented on August 20, 2024

Hi @akYoung.

According to Theano documentation, the cpu value should be valid: http://deeplearning.net/software/theano/library/config.html#config.device

I think that the problem may be related to the device=cpu and other settings reported.
For instance, the nvcc section only relates to the cuda code and GPUs.

Could you please share the exact error you get?
Which operating system?

Thanks,
Valerio

from deep-learning-keras-tensorflow.

akYoung avatar akYoung commented on August 20, 2024

The system is Ubuntu 16.04 64bit system.
The $HOME/.theanorc is configured as following.

[global]
floatX = float32
device = cpu # switch to cpu if no GPU is available on your machine

And when I import keras
It shows the following error,

Using Theano backend.
Traceback (most recent call last):
File "", line 1, in
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/keras/init.py", line 2, in
from . import backend
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/keras/backend/init.py", line 58, in
from .theano_backend import *
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 1, in
import theano
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/theano/init.py", line 42, in
from theano.configdefaults import config
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/theano/configdefaults.py", line 109, in
in_c_key=False)
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/theano/configparser.py", line 276, in AddConfigVar
configparam.get(root, type(root), delete_key=True)
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/theano/configparser.py", line 324, in get
self.set(cls, val_str)
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/theano/configparser.py", line 335, in set
self.val = self.filter(val)
File "/home/akyang/anaconda3/envs/deep-learning/lib/python3.5/site-packages/theano/configdefaults.py", line 95, in filter
% (self.default, val, self.fullname)))
ValueError: Invalid value ("cpu") for configuration variable "cpu # switch to cpu if no GPU is available on your machine". Valid options start with one of "device", "gpu", "opencl", "cuda"
'

from deep-learning-keras-tensorflow.

drscotthawley avatar drscotthawley commented on August 20, 2024

I get essentially the same error on my Mac, when I set "device = cpu" , as shown....

>>> import numpy as np
>>> import scipy as sp
>>> import pandas as pd
>>> import matplotlib.pyplot as plt
>>> import sklearn
>>> import keras
Using Theano backend.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/keras/__init__.py", line 2, in <module>
    from . import backend
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/keras/backend/__init__.py", line 58, in <module>
    from .theano_backend import *
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 1, in <module>
    import theano
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/theano/__init__.py", line 42, in <module>
    from theano.configdefaults import config
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/theano/configdefaults.py", line 109, in <module>
    in_c_key=False)
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/theano/configparser.py", line 276, in AddConfigVar
    configparam.__get__(root, type(root), delete_key=True)
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/theano/configparser.py", line 324, in __get__
    self.__set__(cls, val_str)
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/theano/configparser.py", line 335, in __set__
    self.val = self.filter(val)
  File "/Users/shawley/anaconda/lib/python3.5/site-packages/theano/configdefaults.py", line 95, in filter
    % (self.default, val, self.fullname)))
ValueError: Invalid value ("cpu") for configuration variable "cpu  # switch to cpu if no GPU is available on your machine". Valid options start with one of "device", "gpu", "opencl", "cuda"


If one leaves it as "gpu", then a different error results:

AttributeError: ('This name is already taken', 'floatX').

If one comments out the line in .theanorc with floatX in it, then the same error about floatX being already taken still occurs.

Fix: commenting out the line with "device" on it has resulted in a working keras installation. i.e.:

% cat ~/.theanorc
[global]
floatX = float32
#device = cpu  # switch to cpu if no GPU is available on your machine

[nvcc]
fastmath = True

[lib]
cnmem=.90
>>> import keras
Using Theano backend.
>>>

from deep-learning-keras-tensorflow.

ibrahim-amer avatar ibrahim-amer commented on August 20, 2024

I have exactly the same error but no solution worked for me. Please advice

Invalid value ("cpu") for configuration variable "gpu". Valid options start with one of "device", "opencl", "cuda"

from deep-learning-keras-tensorflow.

Andrjusha avatar Andrjusha commented on August 20, 2024

Same problem for me

from deep-learning-keras-tensorflow.

Hazarapet avatar Hazarapet commented on August 20, 2024

same problem for me.Is there any idea?

from deep-learning-keras-tensorflow.

akYoung avatar akYoung commented on August 20, 2024

Try removing ~/.theanorc.

from deep-learning-keras-tensorflow.

Hazarapet avatar Hazarapet commented on August 20, 2024

@akYoung how to remove that file? It's configuration file.

from deep-learning-keras-tensorflow.

Andrjusha avatar Andrjusha commented on August 20, 2024

I solved my problem by installing the new backend.

from deep-learning-keras-tensorflow.

Primula avatar Primula commented on August 20, 2024

I insalled the new backend but it does not work for me...
Same error:
"ValueError: Invalid value (“cpu”) for configuration variable “gpu”. Valid options start with one of “device”, “opencl”, “cuda”"
Can you help me, please?

from deep-learning-keras-tensorflow.

akYoung avatar akYoung commented on August 20, 2024

@Hazarapet It's been a long time and I am a little fuzzy about it. I suppose I just ran 'rm -rf ~/.theanorc' and it just worked. Maybe you can back it up and try removing it.

from deep-learning-keras-tensorflow.

akYoung avatar akYoung commented on August 20, 2024

@Hazarapet ok.

from deep-learning-keras-tensorflow.

Primula avatar Primula commented on August 20, 2024

@Hazarapet Error is chnged now
"ERROR (theano.gpuarray): pygpu was configured but could not be imported or is too old (version 0.6 or higher required)
NoneType: None
Traceback (most recent call last):
File "Desktop\TheanoCode\firstTest.py", line 9, in
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
NameError: name 'shared' is not defined"

It seems to depend on the Theano beckend that I modified!
It's so instable!!!

from deep-learning-keras-tensorflow.

Hazarapet avatar Hazarapet commented on August 20, 2024

I forgot to say that you have to install "gpuarray"
http://deeplearning.net/software/libgpuarray/installation.html

from deep-learning-keras-tensorflow.

Primula avatar Primula commented on August 20, 2024

I changed python version and now theano works!
I have installed python 2.7 by Anaconda and then theano by conda with pygpu.
At this moment the test seems to go :-)
Thanks a lot!

from deep-learning-keras-tensorflow.

leriomaggio avatar leriomaggio commented on August 20, 2024

@Primula it works with Python 3 as well. This is just to point out that it is not a matter of Python version ;)

from deep-learning-keras-tensorflow.

Primula avatar Primula commented on August 20, 2024

Are you italian? Your name suggests me that's true.
I think I'll try Anaconda3 asap, but when I installed Theano by Anaconda2 it worked immediatly.
I have Win 10, and in some Microsoft developer forum I find this option.
Finally, I'm Italian so if my impression is real, we may interact more clearly.

from deep-learning-keras-tensorflow.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.