How to use CUDA

If you've completed all the previous steps to get CUDA working, then using CUDA is a fairly simple affair. You simply need to compile your application with the following:

go build -tags='cuda'

This builds your executable with CUDA support and uses CUDA, rather than the CPU, to run your deep learning model.

To illustrate, let's use an example we're already familiar with – a neural network with weights:

w0 := gorgonia.NewMatrix(g, dt, gorgonia.WithShape(784, 300), gorgonia.WithName("w0"), gorgonia.WithInit(gorgonia.GlorotN(1.0)))

w1 := gorgonia.NewMatrix(g, dt, gorgonia.WithShape(300, 100), gorgonia.WithName("w1"), gorgonia.WithInit(gorgonia.GlorotN(1.0)))

w2 := gorgonia.NewMatrix(g, dt, gorgonia.WithShape(100, 10), gorgonia.WithName("w2"), gorgonia.WithInit(gorgonia.GlorotN(1.0)))

This is just our simple feedforward neural network that we built to use on the MNIST dataset.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.110.155