I am looking to develop an AI entity using OpenGL and C++. I did some research about libraries I can use for deep learning. However, I was not able to come up with a clear answer. As an alternative, I was wondering if it is possible to use Python with OpenGL.
I am a complete newbie to OpenGL, so please feel free to elaborate on trivial OpenGL common knowledge.
Check out OpenCV. There is http://answers.OpenCV.org for asking questions. perhaps I’ll see you there, my username is sjhalayka. The person that you really need to get in touch with is berak! he’s a CNN god.
The easiest way to do calculations on the GPU is to use a compute shader. That requires OpenGL 4.3, which is like a decade old… lots of new computers support 4.5 or 4.6. A somewhat simple demonstration of a computer shader can be found at https://github.com/sjhalayka/qjs_compute_shader
@taby Thanks for posting this. But my question was about Deep Learning and not about shaders. If you know anything about that please feel free to reply.
@taby Thanks for posting this. But my question was about Deep Learning and not about shaders. If you know anything about that please feel free to reply.
“Shader” is a term applied to many jobs done on the GPU. For instance a vertex shader doesn't actually shade anything, it transforms vertexes. Likewise a compute shader is used for general parallel computations on the GPU, so to the extent that these kinds of computations are advantageous in deep learning (which I know nothing about) it would be useful to use a compute shader. I think the fact that you brought up OpenGL and C++ together with Deep Learning implied to some of us that that's the direction you were going with this. Perhaps you just meant OpenGL will be used in the user interface.
Yeah, there are a lot of parallelizable functionality in a neural network… namely the getting and setting of network weights. Seriously though, go talk to berak.
come to think of it… if I implemented a standard feedforward back-propagation artificial neural network in OpenGL for you, would that be a good enough start, until you talk to berak about CNNs and stuff. It would be a noisy image classifier, so that way there’s a lot of neurons in the input and hidden layer(s), to really test how fast your GPU is.
David_Barel said: I am looking to develop an AI entity using OpenGL and C++.
Gnollrunner said: Perhaps you just meant OpenGL will be used in the user interface.
David_Barel said: I was wondering if it is possible to use Python with OpenGL.
Qt is one of the simplest way to combine GUI (user interface) and OpenGL in one window. I prefer to use Qt C++ but you can use PyQt5. Just google text and video tutorials. Qt has a simple wrapper around of OpenGL to simplify of programming. It is very easy with Qt C++ to build your application on any OS like Windows, macOS, Linux, Android and iOS. For example, see how it is simple to get a shader program by five lines of code:
If you need a simple example I can show you. Open this project in Qt Creator IDE: SetRectangleColorWithMouse_OpenGL33Qt5Cpp.zip (95 KB). It sets colors of rectangle by mouse pressing. I wrote it special for you from scratch for practice. Make more practice to study something.
Scene.h
#ifndef SCENE_H
#define SCENE_H
#include <QOpenGLWidget>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
class Scene : public QOpenGLWidget
{
Q_OBJECT
public:
explicit Scene(QWidget *parent = nullptr);
public slots:
void setRedColor();
void setGreenColor();
void setBlueColor();
private:
QOpenGLShaderProgram m_program;
QOpenGLBuffer m_vertPosBuffer;
int m_uColorLocation;
void initializeGL() override;
void paintGL() override;
void resizeGL(int w, int h) override;
};
#endif // SCENE_H