Restricted Boltzmann Machines using Cloo (ATI Mobility Radeon)

Mar 6, 2011 at 6:49 PM
Edited Mar 6, 2011 at 8:04 PM

Hello SharpRBM creator,

I've been doing C# for about 5 years now.  I'm pretty new to neural networks, and I also haven't really tapped into the GPU/Interop side because I really haven't had to in the past.   Here's what's going on: I converted your solution to work with my ATI Mobility Radeon graphics card.  It was not building the SharpRMB.c file program so I decided to look for another implementation of the OpenCL code that was compatible with my graphics card.  http://sourceforge.net/projects/cloo/ is what I used.  So now it works, but only for about 15 iterations with drawing turned on.

Do you know what could be happening or how I could troubleshoot the issue ( I attached my source http://sharprbm.codeplex.com/SourceControl/list/patches)?

{System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.   at Cloo.Bindings.CL10.EnqueueWriteBuffer(IntPtr command_queue, IntPtr buffer, ComputeBoolean blocking_write, IntPtr offset, IntPtr cb, IntPtr ptr, Int32 num_events_in_wait_list, IntPtr* event_wait_list, IntPtr* new_event)   at Cloo.ComputeCommandQueue.Write[T](ComputeBufferBase`1 destination, Boolean blocking, Int64 destinationOffset, Int64 region, IntPtr source, ICollection`1 events) in C:\Source\Downloads\sharprbm\Cloo\Source\ComputeCommandQueue.cs:line 663   at Cloo.ComputeCommandQueue.WriteToBuffer[T](T[] source, ComputeBufferBase`1 destination, Boolean blocking, Int64 sourceOffset, Int64 destinationOffset, Int64 region, ICollection`1 events) in C:\Source\Downloads\sharprbm\Cloo\Source\ComputeCommandQueue.Added.cs:line 554   at Cloo.ComputeCommandQueue.WriteToBuffer[T](T[] source, ComputeBufferBase`1 destination, Boolean blocking, ICollection`1 events) in C:\Source\Downloads\sharprbm\Cloo\Source\ComputeCommandQueue.Added.cs:line 533   at SharpRBM.Core.LearningModules.OpenCLLearningModule.ActivateLowerToUpper(Layer lower, Layer upper, ActivationMethod method) in C:\Source\Downloads\sharprbm\SharpRBM.Core\LearningModules\OpenCLLearningModule.cs:line 101   at SharpRBM.SimpleLetterDemo.MainForm.<GenerateReconstructedBitmaps>d__c.MoveNext() in C:\Source\Downloads\sharprbm\SharpRBM.SimpleLetterDemo\MainForm.cs:line 303}

Thanks, Kyle

Mar 10, 2011 at 12:24 AM

Nevermind, I fixed the code by adding what's in bold.

protected ComputeMemory(ComputeContext context, ComputeMemoryFlags flags) {
     this.context = context;
     this.flags = flags;
     GC.SuppressFinalize(this);
     GC.KeepAlive(this);
}

Coordinator
Mar 10, 2011 at 6:18 AM

Sorry I didn't see this in time to reply, but you solved it which is great - I probably couldn't have anyway.

It's very unusual that you'd have to fiddle around with the garbage collection, that's usually a sign that something really hinky is going on - but if it works and doesn't leak memory then good work.

I developed SharpRBM for a NVidia card, but it should work for ATIs as well, strange that it should give you errors.

cheers,
mattias

Mar 16, 2011 at 1:39 AM
Edited Mar 16, 2011 at 1:55 AM

I was able to run it for 8480 iterations so I'm assuming that it isn't leaking Link to Snapshot of the form on Facebook.  I realize that you're probably super busy with life as we all are, but it is my personal goal to understand neural networks to as far as we are with them right now.  Have you seen the latest: http://www.youtube.com/user/GoogleTechTalks#p/search/0/VdIURAu1-aU.  It would be very useful to me to understand the generation of the time based neural networks with the third factor involved.