The question is really general, so here is a more detailed information: I run currently Ubuntu 14.04 and work on a neural network currently. To find optimal parameters I want to train many different parametrized networks and see which one works best.
这个问题非常普遍,所以这里有一个更详细的信息:我目前正在运行Ubuntu 14.04并在神经网络上工作。为了找到最佳参数,我想训练许多不同的参数化网络,看看哪个最好。
The network and its training sequence is written in c and I have a 4 core processor. If I run the program it trains each network one after another.
网络及其训练序列用c语言编写,我有一个4核处理器。如果我运行该程序,它会一个接一个地训练每个网络。
Now the system monitor tells me the programme is using about 25 percent of the total process power. How can I improve that, what is the best way to use all cores equally and 100 percent of my cpu(and gpu?)
现在,系统监视器告诉我程序正在使用大约25%的总过程功率。我怎样才能改善这一点,平均使用所有内核的最佳方法是什么,以及100%的cpu(和gpu?)
Currently I am using the compiling flag -pthread
, but I guess there are many more possibilities.
目前我正在使用编译标志-pthread,但我想还有更多的可能性。
2 个解决方案
#1
2
Yes, the question is general. So is the answer: learn about concurrent programming. Threads, or OpenMP. Especially with OpenMP you might turn your program into a multi-threaded program by adding a single #pragma
before the right for
loop.
是的,这个问题很笼统。答案就是:了解并发编程。线程或OpenMP。特别是使用OpenMP,您可以通过在右侧for循环之前添加一个#pragma来将程序转换为多线程程序。
A different approach could be to have each of the four trainings be performed by a different process. The strategy would be to use main's arguments (argc, argv
) to tell each process what to do. This is easy if there needs to be no communication between the processes.
不同的方法可以是让四个培训中的每一个都由不同的过程执行。策略是使用main的参数(argc,argv)告诉每个进程要做什么。如果进程之间不需要通信,这很容易。
#2
0
I would suggest you look into OpenCL and OpenMP as ways to fully exploit the processing power. There has been a lot of work on neural nets using OpenCL and CUDA.
我建议你研究一下OpenCL和OpenMP作为充分利用处理能力的方法。使用OpenCL和CUDA的神经网络已经有很多工作。
These approaches are probably more suited to your neural net. In addition OpenCL and OpenMP applications can be made to compile to use both CPU and GPU hardware with no significant changes.
这些方法可能更适合您的神经网络。此外,可以编译OpenCL和OpenMP应用程序以使用CPU和GPU硬件,而无需进行重大更改。
OpenCL is a C-like language, and although getting optimal performance from it can be quite tricky, it would, IMO, be well worth your while if neural net stuff is important to you. In OpenCL you write the bulk of support code in C and invoke a small kernel in OpenCL to do small operations on large volumes of data in parallel.
OpenCL是一种类似C语言的语言,虽然从中获得最佳性能可能非常棘手,但如果神经网络对你很重要,IMO也是值得的。在OpenCL中,您可以在C中编写大量支持代码,并在OpenCL中调用一个小内核,以便并行地对大量数据执行小型操作。
You may be developing your own software, but I believe that the FANN neural network library did have a version that supported OpenCL.
您可能正在开发自己的软件,但我相信FANN神经网络库确实有一个支持OpenCL的版本。
#1
2
Yes, the question is general. So is the answer: learn about concurrent programming. Threads, or OpenMP. Especially with OpenMP you might turn your program into a multi-threaded program by adding a single #pragma
before the right for
loop.
是的,这个问题很笼统。答案就是:了解并发编程。线程或OpenMP。特别是使用OpenMP,您可以通过在右侧for循环之前添加一个#pragma来将程序转换为多线程程序。
A different approach could be to have each of the four trainings be performed by a different process. The strategy would be to use main's arguments (argc, argv
) to tell each process what to do. This is easy if there needs to be no communication between the processes.
不同的方法可以是让四个培训中的每一个都由不同的过程执行。策略是使用main的参数(argc,argv)告诉每个进程要做什么。如果进程之间不需要通信,这很容易。
#2
0
I would suggest you look into OpenCL and OpenMP as ways to fully exploit the processing power. There has been a lot of work on neural nets using OpenCL and CUDA.
我建议你研究一下OpenCL和OpenMP作为充分利用处理能力的方法。使用OpenCL和CUDA的神经网络已经有很多工作。
These approaches are probably more suited to your neural net. In addition OpenCL and OpenMP applications can be made to compile to use both CPU and GPU hardware with no significant changes.
这些方法可能更适合您的神经网络。此外,可以编译OpenCL和OpenMP应用程序以使用CPU和GPU硬件,而无需进行重大更改。
OpenCL is a C-like language, and although getting optimal performance from it can be quite tricky, it would, IMO, be well worth your while if neural net stuff is important to you. In OpenCL you write the bulk of support code in C and invoke a small kernel in OpenCL to do small operations on large volumes of data in parallel.
OpenCL是一种类似C语言的语言,虽然从中获得最佳性能可能非常棘手,但如果神经网络对你很重要,IMO也是值得的。在OpenCL中,您可以在C中编写大量支持代码,并在OpenCL中调用一个小内核,以便并行地对大量数据执行小型操作。
You may be developing your own software, but I believe that the FANN neural network library did have a version that supported OpenCL.
您可能正在开发自己的软件,但我相信FANN神经网络库确实有一个支持OpenCL的版本。