keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62.14k stars 19.49k forks source link

feature request: more backends #2370

Closed fayeshine closed 3 years ago

fayeshine commented 8 years ago

could we support or do we plan to support more backends? Theano can only support multiple GPU using OpenCL but not CUDA, tensorflow seems slower than other framework using GPU for now.

Could we support Caffe, Leaf, MXNET, CNTK or Torch7? image image

iaroslav-ai commented 8 years ago

+1

fchollet commented 8 years ago

I think MXNet and CNTK would be the interesting ones to have. You guys want to work on that?

iaroslav-ai commented 8 years ago

Consider also using neon backend: https://github.com/NervanaSystems/neon It actually seems quite nice, compilation is lazy (no need to wait for graph to compile) and documentation at least so far seems to be quite decent. As a bonus it seems like this backend is the fastest so far at least with popular CV deep nets :D Here is a minimal example of neon that demonstrates some of its features:

from neon.backends import gen_backend, Autodiff
import numpy as np

# decide where to run (gpu/cpu)
be = gen_backend('cpu') 

# create variables
x0, x1 = be.empty((2,2)), be.empty((2,2))

# construct computational graph
f = x0 * x0 + x0 * x1

# initialize variables
x0[:] = np.random.rand(2,2);
x1[:] = 0.0;

# return result as np array (could return variable of course)
print f.asnumpyarray()

# do autodifferentiation
ad = Autodiff(op_tree=f, be=be, next_error=None)

# compute the gradient w.r.t. some variables
print ad.get_grad_asnumpyarray([x0, x1])
iaroslav-ai commented 8 years ago

Yeah, at least with neon backend I could try contributing, I am not sure however how soon that would happen. Lets say if no one else does it I do it (if neon backend is interesting), but I cannot promise anything w.r.t. time as I am already busy with all kinds of exciting things :D

iaroslav-ai commented 8 years ago

I am not familiar with MXNet and CNTK though

iaroslav-ai commented 8 years ago

Just looked for examples of CNTK usage in python, google did not reveal any so far. What Microsoft say is that python CNTK will be available in future releases. Thus it seems that it makes sense to consider MXNet only for extra backend as of now.

lemuriandezapada commented 8 years ago

CNTK isn't available in python yet They probably will later this year

What would be more interesting would be to see if the new cuDNN RNN implementation can be ported into theano/tf and keras

iaroslav-ai commented 8 years ago

@fchollet : from other issues it seems that neon backend is actually interesting. Do you know if someone is already working on it and if there are already any results?

marcj commented 8 years ago

Doesn't neon support GPU only in payed licenses?

lemuriandezapada commented 8 years ago

Neon supports GPU in free license. Only supports multi-GPU in paid.

marcj commented 8 years ago

Ah, you are right - it was multi-gpu :)

NasenSpray commented 8 years ago

I'll take a look at MXNet

nouiz commented 8 years ago

We can and want to wrap the rnn implementation from cudnn. But we don't know when it will be done. Le 18 avr. 2016 05:28, "lemuriandezapada" notifications@github.com a écrit :

CNTK isn't available in python yet They probably will later this year

What would be more interesting would be to see if the new cuDNN RNN implementation can be ported into theano/tf and keras

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/fchollet/keras/issues/2370#issuecomment-211293802

cmarschner commented 8 years ago

Cross-referencing... CNTK backend. https://github.com/Microsoft/CNTK/issues/797

wangdelp commented 8 years ago

@fchollet More backend would be awesome. Do you have an estimated timeline when would the CNTK and MXNet be added into the keras backend? Thank you.

sflc6 commented 7 years ago

Hi! Curious as to whether anyone has followed up on integrating CNTK/other backends with Keras.

n17s commented 7 years ago

There's now a CNTK backend

choongng commented 7 years ago

My company Vertex.AI uses Keras internally for model development and we are actively working on OpenCL support: http://vertex.ai/blog/bringing-deep-learning-to-opencl

znmeb commented 7 years ago

Is there such a thing as a "how to integrate a backend" document? Or a way to translate models / data from an "arbitrary" deep learning library into TensorFlow or CNTK? I'm thinking mostly about caffe for now, but there are others out there.

choongng commented 7 years ago

We've just open sourced PlaidML which includes a new Keras backend with OpenCL support: http://vertex.ai/blog/announcing-plaidml

@fchollet Now that our source is open we'll see what we can do to make our integration with Keras cleaner.

znmeb commented 7 years ago

@choongng I'm planning to test this over the weekend.

astrojuanlu commented 7 years ago

It would be nice to have an extension mechanism in keras that doesn't involve monkey patching (which is what @choongng and the rest of the Vertex.AI folks are doing) or submitting a pull request upstream. pytest and other projects support plugins via setuptools entry_points. Right now PlaidML monkey patching does not work in Python 3 so it would be nice to have a cleaner method. What do others think?

sandeep-krishnamurthy commented 6 years ago

Tracking ticket for Keras2-MXNet backend https://github.com/keras-team/keras/issues/8697