Comments (27)
I'm guessing that my OpenCL compiler/hardware doesn't support tanh
from deepcl.
Yes.... that's two of you now... but looking at http://www.notebookcheck.net/AMD-Radeon-HD-8750M.87147.0.html seems this card supports OpenCL 1.2?
from deepcl.
(Had a browse through the AMD drivers download, and came up with http://support.amd.com/en-us/download/desktop?os=Linux+x86_64 , but it didnt say what version of OpenCL these support... might be worth a shot though?)
(Edit: ah, per http://wiki.cchtml.com/index.php/Hardware , seems like maybe this driver doesnt support HD8750M? Kind of hard to tell...)
from deepcl.
(Note that I'm pretty sure opencl 1.1 itself solidly supports tanh: https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html )
from deepcl.
I'm running the open-source driver, which could be why it is at v1.1
from deepcl.
Ok. Maybe you can add in tanh
:-) I think you can construct it as ( e^x - c^(-x) ) / ( e^x + e^(-x) )
. Or... you could hack the DeepCL code to use this. In cl/activate.cl
, simply replace tanh(output)
with this expression.
from deepcl.
I know :) I'm just curious as to why the OpenCL compiler can't already do that - maybe I should submit a bug report for mesa
from deepcl.
Well... I guess you could modify their code. But... I'm curious how this could be running on your GPU. It seems like Clover is compiling the opencl itself, and I doubt it's compiling into AMD ISA? (ie http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/07/AMD_GCN3_Instruction_Set_Architecture.pdf and so on ). So, seems like it might be running in software, on your CPU?
from deepcl.
Could be, although I'd be amazed if my Haswell + Intel's drivers couldn't handle tanh!
from deepcl.
So, what I think is, Clover runs your OpenCL code, just like a script, like running something in Python and so on. I'm fairly sure that no OpenCL code is actually sent to your CPU, to run as Intel OpenCL.
OpenCL => Clover OpenCL Scripting engine => executes as normal x86 program, inside Clover
(Edit: I should have just used hte 'Edit' button really :-P Not sure why I didnt.... )
(Edit2: but I'm not really sure what Clover is doing. Scripting would sound too slow. But compiling to x86 on the fly would sound strange too. But compiling to AMD ISA seems unlikely. Soo... ????)
from deepcl.
You're right, Clover runs on CPU. Given this, I'm amazed that it doesn't support tanh...
from deepcl.
:-)
from deepcl.
Hi. Apparently I'm wrong. Clover does run on GPU :-) See Element-Research/rnn#41
from deepcl.
So, what I'd suggest is, creating a fork/branch, and modifying activate.cl to write tanh
in terms of exp
. The expression for tanh
in terms of exp
is something like: (exp(y) - exp(-y)) / (exp(y) + exp(-y))
from deepcl.
Note: you'd need to modify these lines basically: https://github.com/hughperkins/DeepCL/blob/master/cl/activate.cl#L10-L13
#ifdef TANH
#define ACTIVATION_FUNCTION(output) (tanh(output))
#elif defined SCALEDTANH
#define ACTIVATION_FUNCTION(output) (1.7159f * tanh(0.66667f * output))
I guess it will need to look something like (just doing it for TANH
for now):
#ifdef TANH
#define ACTIVATION_FUNCTION(output) ((exp(output) - exp(-output)) / (exp(output) + exp(-output)))
from deepcl.
I've been having the same issue with tanh on my system (R9 290 but with OpenCL 1.1). I would like to start messing around with what you've suggested hughperkins. However, editing the cl/activate.cl
seems to do absolutely nothing, after make or after running the test Python script. After running the Python script, I still get:
Something went wrong with clCreateKernel, OpenCL erorr code -45
cl/activate.cl build log:
input.cl:30:23: warning: implicit declaration of function 'tanh' is invalid in C99
input.cl:11:42: note: expanded from macro 'ACTIVATION_FUNCTION'
unsupported call to function tanh in activate
Traceback (most recent call last):
File "test_deepcl.py", line 35, in <module>
net, "rt2-8c5z-relu-mp2-16c5z-relu-mp3-150n-tanh-10n")
File "NetDefToNet.pyx", line 7, in PyDeepCL.NetdefToNet.createNetFromNetdef (PyDeepCL.cxx:15006)
RuntimeError:
kernel source:
It then repeats the original source of cl/activate.cl
without any of my changes. I'm sure I'm missing something simple, but do you mind pointing out what I'm missing? How do I actually test my changes to cl/activate.cl
?
from deepcl.
You need to do one of two things, either:
- obtain an OpenCL driver for your GPU that implements the
tanh
function, or - modify DeepCL to write
tanh
usingexp
function, which is fairly straightforward, see #35 (comment)
from deepcl.
Thanks for the quick reply! I'm trying to choose option 2 and modify DeepCL.
However, after I've modified cl/activate.cl
by using the exp
and compiled, my changes don't seem to matter. I get the same error and the build log error shows the previous source code. Does that make sense? What do I need to do to compile the changes I've made to cl/activate.cl
?
from deepcl.
You'll need to turn on cog
during compilation. Basically, cd
into build
directory, run ccmake ..
, and set the configuration options something like:
You wont see the COG
option initially, but if you set MAINTAINER_OPTIONS
to ON
, and press c
, it will appear :-)
I'd recommend you start by getting the non-python version working first, since it involves fewer compilation steps. You can test by running the unit tests ./deepcl_unittests
, creating a new one if necessary, but I think you can use:
./deepcl_unittests tests=testactivationforward.comparespecific_0_1_activation3_small2_tanh
from deepcl.
Great! Took a little more troubleshooting but compiling is working and my changes are showing up.
Thanks again for the quick response and the wonderful project.
from deepcl.
Awesome! Once you have that working, do you mind creating a fork/branch, so other people can use it too? (I'll probably take a copy of the fork too; and might ponder if there's a way of adding it into master
somehow)
from deepcl.
I'm happy to do so. However, a few things to consider:
- I basically just added one line to the
cl/activate.cl
consisting of your suggestion. This then fixed the missingtanh
problem, and I was finally able to pass thetestactivationforward.comparespecific_0_1_activation3_small2_tanh
unit test. - However, I was still failing 49 of the unit tests (before the fix I was failing 50). This seems to be due to the another OpenCL 1.1 error,
OpenCL does not support the 'static' storage class specifier
. - I randomly just got OpenCL 1.2 to work and now I am passing 100% of the unit tests.
Do you still think it's worth it for just this fix? If OpenCL 1.1 is a priority, it seems we might want to tackle the other issue as well...
from deepcl.
Ah, so finally you've switched to OpenCL 1.2 for now? Concretely, this means you are using the AMD drivers, rather than the Clover drivers, is that right?
from deepcl.
By the way, I dont think either of the issues (missing tanh
and missing static
support are actually OpenCL 1.1 issues, I think these are both specific to the the Clover implementation of OpenCL 1.1. Having said this, maybe we can create a fork like 'clover-compatibility', where we handle these two issues? You can start by creating this from your change '1.', and then someone can revert my static
additions, to handle the clover issue with static
support (probably just revert some of 022b6a3 approximately, or just go through the cl/*.cl
files, and replace static
with ``)
from deepcl.
Not exactly. Before I was using the Clover drivers for OpenCL 1.1. I was then trying to upgrade OpenCL and somehow managed to get the Intel driver for OpenCL 1.2. So all the tests were successful using the Intel driver and my i5.
I now finally got the AMD drivers working for my R9 290 with OpenCL 2.0. That is also passing all the unit tests.
So yes, it seems like it is just Clover. I created the PR: #60
from deepcl.
For anyone else coming across this thread, please note that the clover compatibility fork is at: https://github.com/hughperkins/DeepCL/tree/clover-compatibility (or https://github.com/rhyzomatic/DeepCL/tree/clover-compatibility , depending on how you look at it)
from deepcl.
Added notes on this to README.md 8ac7b0f Closing this issue for now
from deepcl.
Related Issues (20)
- MNIST data format HOT 1
- Python Q-Learning - Add Dropout Layout causes runtime error HOT 11
- can passed all test in #ad1ab61, but not now (#b256220) HOT 48
- function "NetLearner::learn" is deprecated, how to train a network by the new method? HOT 2
- How to use ExpectedData correctly in training? HOT 2
- tutorial and documentation is very less
- integrated demo HOT 2
- could deepcl run on FPGAs? HOT 1
- deepcl_predict HOT 5
- does the Neural network created on GPU? HOT 3
- captcha
- pip with windows does not work
- Need cythonize
- deepcl_unittests not running in CentOS 7. HOT 2
- opencl 1.1?
- Feature Request: Add Mish activation HOT 3
- How to set stride of conv layer? HOT 2
- Implementation of DNN on FPGA HOT 2
- Any examples for face detection?
- is there any ConvTranspose2d?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepcl.