- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在尝试使用这个 GPU 库 Rootbeer
我已经运行了演示,它们运行良好,然后我尝试运行我的代码,在该代码段的倒数第二行 (Rootbeer rootbeer = new Rootbeer();
) 中,我收到一个错误(请参阅上一节)。
// This sesction is within a JSlider change event.
int val = sldBrightness.getValue();
List<Kernel> jobs = new ArrayList<Kernel>();
jobs.add(new Brightness(val));
Rootbeer rootbeer = new Rootbeer();
rootbeer.runAll(jobs);
这是我正在运行的类(class):
package pocketshop.graphics.adjustments;
import edu.syr.pcpratts.rootbeer.runtime.Kernel;
import java.awt.image.BufferedImage;
import pocketshop.Canvas;
import pocketshop.graphics.Colors;
import pocketshop.graphics.Preview;
/**
*
* @author Ryan
*/
public class Brightness implements Kernel {
protected int amount = 0;
protected int width, height;
int[] pixels; // = new int[width * height];
public void amount(int amount) {
this.amount = amount;
}
public Brightness(int amount) {
this.amount = amount;
width = Canvas.image.getWidth();
height = Canvas.image.getHeight();
pixels = new int[width * height];
Canvas.image.getRGB(0, 0, width, height, pixels, 0, width);
}
public void setImage() {
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, width, height, pixels, 0, width);
Preview.setImage(img);
}
@Override
public void gpuMethod() {
int[] pixels = this.pixels;
for (int i = 0; i < pixels.length; i++) {
int pixel = pixels[i];
int red = Colors.red(pixel);
int green = Colors.green(pixel);
int blue = Colors.blue(pixel);
red += amount;
if (red > 255) {
red = 255;
} else if (red < 0) {
red = 0;
}
green += amount;
if (green > 255) {
green = 255;
} else if (green < 0) {
green = 0;
}
blue += amount;
if (blue > 255) {
blue = 255;
} else if (blue < 0) {
blue = 0;
}
pixels[i] = Colors.rgba(red, green, blue);
}
}
}
这是输出错误。我真的很困惑为什么会显示Caused by: edu.syr.pcpratts.rootbeer.runtime2.cuda.CudaErrorException: CUDA_ERROR_OUT_OF_MEMORY: gpuHandlesMemory内存分配失败
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at edu.syr.pcpratts.rootbeer.runtime.RootbeerFactory.create(RootbeerFactory.java:19)
at edu.syr.pcpratts.rootbeer.runtime.Rootbeer.<init>(Rootbeer.java:19)
at pocketshop.dialogs.BrightnessContrastDialog.sldBrightnessStateChanged(BrightnessContrastDialog.java:191)
at pocketshop.dialogs.BrightnessContrastDialog.access$100(BrightnessContrastDialog.java:21)
at pocketshop.dialogs.BrightnessContrastDialog$2.stateChanged(BrightnessContrastDialog.java:65)
at javax.swing.JSlider.fireStateChanged(JSlider.java:432)
at javax.swing.JSlider$ModelListener.stateChanged(JSlider.java:350)
at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:364)
at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:302)
at javax.swing.DefaultBoundedRangeModel.setValue(DefaultBoundedRangeModel.java:168)
at javax.swing.JSlider.setValue(JSlider.java:531)
at pocketshop.dialogs.BrightnessContrastDialog.txtBrightnessActionPerformed(BrightnessContrastDialog.java:180)
at pocketshop.dialogs.BrightnessContrastDialog.access$300(BrightnessContrastDialog.java:21)
at pocketshop.dialogs.BrightnessContrastDialog$4.actionPerformed(BrightnessContrastDialog.java:88)
at javax.swing.JTextField.fireActionPerformed(JTextField.java:508)
at javax.swing.JTextField.postActionEvent(JTextField.java:721)
at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:836)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1664)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2879)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2926)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2842)
at java.awt.Component.processEvent(Component.java:6282)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
at java.awt.Component.dispatchEventImpl(Component.java:4731)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:155)
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
at java.awt.Dialog.show(Dialog.java:1077)
at java.awt.Component.show(Component.java:1651)
at java.awt.Component.setVisible(Component.java:1603)
at java.awt.Window.setVisible(Window.java:1014)
at java.awt.Dialog.setVisible(Dialog.java:1003)
at pocketshop.Main.jMenuItem4ActionPerformed(Main.java:233)
at pocketshop.Main.access$200(Main.java:15)
at pocketshop.Main$3.actionPerformed(Main.java:180)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Caused by: edu.syr.pcpratts.rootbeer.runtime2.cuda.CudaErrorException: CUDA_ERROR_OUT_OF_MEMORY: gpuHandlesMemory memory allocation failed
at edu.syr.pcpratts.rootbeer.runtime2.cuda.CudaRuntime2.setup(Native Method)
at edu.syr.pcpratts.rootbeer.runtime2.cuda.CudaRuntime2.<init>(CudaRuntime2.java:92)
at edu.syr.pcpratts.rootbeer.runtime2.cuda.CudaRuntime2.v(CudaRuntime2.java:38)
at edu.syr.pcpratts.rootbeer.runtime.ConcreteRootbeer.<init>(ConcreteRootbeer.java:27)
... 105 more
最佳答案
尝试编辑文件:/.rootbeer/config
将 Reserve_mem 值更改为更大的数字。
然后可以通过电子邮件将此命令的结果发送给我:$ java -jar Rootbeer.jar -printdeviceinfo
关于java - Rootbeer GPU CUDA_ERROR_OUT_OF_MEMORY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13409482/
我正在尝试在 TensorFlow 中构建一个大型 CNN,并打算在多 GPU 系统上运行它。我采用了“塔式”系统,并为两个 GPU 拆分批处理,同时将变量和其他计算保留在 CPU 上。我的系统有 3
我一直在尝试使用这个 GPU 库 Rootbeer 我已经运行了演示,它们运行良好,然后我尝试运行我的代码,在该代码段的倒数第二行 (Rootbeer rootbeer = new Rootbeer(
当你想训练一个神经网络时,你需要设置一个batch size。批量越大,GPU 内存消耗越高。当您缺乏 GPU 内存时,tensorflow 会引发这种消息: 2021-03-29 15:45:04.
我正在尝试运行 tensorflow 项目,但在大学 HPC 集群上遇到内存问题。我必须为数百个不同长度的输入运行预测作业。我们有具有不同数量 vmem 的 GPU 节点,所以我试图以一种不会在 GP
我正在运行 Tensorflow 对象检测 API,使用 object_detection/train.py 脚本训练我自己的检测器,发现 here 。问题是我不断收到CUDA_ERROR_OUT_O
我应该如何解决这个错误? [jalal@goku bin]$ source activate deep_emotion (deep_emotion) [jalal@goku bin]$ python
我的模型大约有 2.4GB。在我的推理步骤中,我想在每个 GPU 中通过多处理方法加载模型。这意味着我尝试在一个 GPU 中做两个进程,每个进程加载一个模型。在我完成每个 session 的配置后,每
我在 python 上使用 tensorflow 训练了一个没有问题的模型。我现在正尝试将此模型的推理集成到预先存在的支持 OpenGL 的软件中。但是,我在 cuInit 期间得到了一个 CUDA_
我是一名优秀的程序员,十分优秀!