我一直在尝试使用这个GPU库Rootbeer
我已经运行了演示,它们运行正常,然后我尝试运行我的代码,并在此片段的倒数第二行({{ 1}}),我收到错误(见上一节)。
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);
这是输出错误。我真的很难过为什么会显示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 memory allocation failed
答案 0 :(得分:1)
尝试编辑文件:/.rootbeer/config
将reserve_mem值更改为更大的数字。
然后可以通过电子邮件发送给我这个命令的结果: $ java -jar Rootbeer.jar -printdeviceinfo