增加 java 中 weka 的堆大小

发布于 2024-12-23 09:16:19 字数 219 浏览 2 评论 0 原文

我正在尝试增加 java 中 weka 的堆大小,但它一直崩溃。我使用了建议的行:

> java -Xmx500m -classpath

但出现以下错误:

-classpath requires class path specification

我不确定这意味着什么。有什么建议吗?

I'm trying to increase the heap size in java for weka which keeps crashing. I used the suggested line:

> java -Xmx500m -classpath

but I get the following error:

-classpath requires class path specification

I'm not sure what this means. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

仄言 2024-12-30 09:16:19

我发现实际问题出在 '\Program Files (x86)\Weka-3-6' 中的文件 'RunWeka.ini' 中。我用记事本打开它,文件中间有一行'maxheap = 512m'

我将行更改为 'maxheap=2000m',保存文件并重新加载 weka,这解决了我的问题。

我不确定这是否是正确的方法,但它对我有用。

What I found was the actual issue was in the file 'RunWeka.ini' in '\Program Files (x86)\Weka-3-6'. I opened it with notepad and in the middle of the file there is a line 'maxheap = 512m'.

I changed the line to read 'maxheap=2000m', saved the file and reloaded weka and this fixed my problems.

I'm not sure if this is the correct way to do it or not but it worked for me.

南街女流氓 2024-12-30 09:16:19

在终端中运行此命令:

java -Xmx1024m -jar weka.jar

Run this command in your terminal:

java -Xmx1024m -jar weka.jar
擦肩而过的背影 2024-12-30 09:16:19

省略 -classpath 选项。仅使用 -Xmx500m 选项。

因此,不仅仅是:

java weka.core.Instances data/soybean.arff

你这样做:

java -Xmx500m weka.core.Instances data/soybean.arff

如果你通过某个脚本(例如 RunWeka.bat)运行 weka,那么你需要修改该脚本(使用一些文本编辑器,如记事本)。

Omit the -classpath option. Use just -Xmx500m option.

So, instead of just:

java weka.core.Instances data/soybean.arff

you do:

java -Xmx500m weka.core.Instances data/soybean.arff

If you run weka via some script (RunWeka.bat for example), then you need to modify that script (with some text editor like notepad).

葬心 2024-12-30 09:16:19

如果您在 Windows 上使用 Weka 3.8.1,您可以通过编辑 javaOpts 参数来省去很多麻烦。参数maxheap不再使用,因此您可以在RunWeka.ini文件中像这样设置javaOpts

javaOpts= -Xmx1040m

其中1040m 是您要分配的内存量。

请注意该文件区分大小写。

有很多方法可以进行设置,但这是让 Weka 在此版本的 Windows 环境中运行的更快方法。

编辑:如果您希望Weka在Windows上使用超过1gb,您需要安装JDK。普通的 JRE 不会这样做。

If you're using Weka 3.8.1 on Windows you can save yourself a lot of trouble by editing the javaOpts parameter. The parameter maxheap isn't used anymore, so you can set javaOpts like this in RunWeka.ini file:

javaOpts= -Xmx1040m

Where 1040m is the amount of memory you want to allocate.

Mind that the file is case sensitive.

There are a lot of ways to set this up, but this is the faster way to get Weka runing on a Windows environment at this version.

Edit: If you want Weka to use more than 1gb on windows, you need to have JDK installed. Regular JRE wont do it.

十级心震 2024-12-30 09:16:19

Weka 官方答案(适用于所有操作系统和 Weka 版本)可以在 http:// /weka.wikispaces.com/OutOfMemoryException

如果您在 Windows 上使用最新的 Weka 版本,答案是:

修改RunWeka.ini文件中的maxheap参数。

The official Weka answer (for all operating systems and Weka versions) can be found on http://weka.wikispaces.com/OutOfMemoryException.

In case you are using a recent Weka version on Windows, the answer is:

Modify the maxheap parameter in the RunWeka.ini file.

地狱即天堂 2024-12-30 09:16:19

在 Ubuntu 上我也遇到了同样的问题
但我通过增加 Java 虚拟机使用的内存量来解决这个问题
运行这个:weka -m 1024m

On Ubuntu i had the same problem
but i solve it by increasing the amount of memory to use for the Java Virtual Machine
run this : weka -m 1024m

屋顶上的小猫咪 2024-12-30 09:16:19

您需要在 -classpath 之后指定一个类路径,类似于 PATH 环境变量,您需要指定 Java 可以找到类的路径。

-Xmx500m 设置看起来不错,但我建议使用 512m。

You need to specify a classpath after -classpath, similar to the PATH env variable you need to specify the path where Java can find the classes.

The -Xmx500m setting looks fine, except that I would suggest to use 512m.

差↓一点笑了 2024-12-30 09:16:19

对于 Mac OS,您必须编辑配置文件才能增加 Weka UI 应用程序的堆大小。

我重复我写的内容: 当已指定最大堆值时,是否有解决方法来解决“Java堆空间”内存错误?

  1. 如果 Weka 正在运行,请退出。

  2. cd 进入 /Applications/weka-XXX.app/Contents ,或者安装 weka 可执行文件的任何位置。那里会有一个名为 Info.plist 的文件。它是一个 XML 文本文件。我建议您将其副本保存到另一个位置,因为您需要在下一步中对其进行编辑。

  3. 在您喜欢的文本编辑器中打开 Info.plist (XML) 文件,然后查找显示“VMOptions”的块。应该有一个值“-Xmx256M”或类似的值指定最大值堆大小。您应该将该值更改为更大的值,例如“-Xmx1024M”。

  4. 启动Weka。

For Mac OS, you have to edit a configuration file in order to increase the heap size of the Weka UI application.

I am repeating what I wrote in: Is there a workaround to solve "Java heap space" memory error when the max heap value has been already specified?

  1. Quit out of Weka if it is running.

  2. cd into /Applications/weka-XXX.app/Contents , or wherever your weka executable was installed. There will be a file called Info.plist there. It is an XML text file. I suggest you save a copy of it to another location, as you'll need to edit it in the next step.

  3. Open the Info.plist (XML) file in your favorite text editor and look for a block that says "VMOptions". There should be a value that says "-Xmx256M" or something similar that specifies the maximum heap size. You should change that value to something bigger, such as "-Xmx1024M".

  4. Start Weka.

安稳善良 2024-12-30 09:16:19

我在 Windows 中运行 Weka 3.6。这就是我所做的。
进入Weka安装目录,你会发现一个RunWeka.bat文件。在文本编辑器中打开此文件并在 java 命令行中添加 -Xmx 参数。

例如设置为 4GB 内存,
%_java% -Xmx4096m -classpath 。 RunWeka -i .\RunWeka.ini -w .\weka.jar -c %_cmd% "%2"

I am running Weka 3.6 in windows. This is what i did.
Go to the Weka installation directory and you will find a RunWeka.bat file. Open this file in a text editor and add -Xmx argument in the java command line.

for instance this sets to 4GB memory,
%_java% -Xmx4096m -classpath . RunWeka -i .\RunWeka.ini -w .\weka.jar -c %_cmd% "%2"

遥远的绿洲 2024-12-30 09:16:19

Weka 官方答案是正确的..但是....关键是首先删除所有 JVM 文件并安装相关的 32 或 64 位 Java 版本。不使用相关版本会导致许多问题,包括无法将堆增加到超过 1024m(通过更改 ini 文件)。

The official Weka answer is right..But....crucial is to first get rid of all JVM files and install the relevant 32 or 64 bit Java version. Not using the relevant version causes many problems including the impossibility to increase the heap further than 1024m (by changing the ini file).

ゃ人海孤独症 2024-12-30 09:16:19

Weka 3.9.2 也不再有 maxheap 的选项。 RunWeka.ini中有javaOpts的选项,所以你可以将下面的内容更改为你需要的内存分配,

javaOpts=%JAVA_OPTS%   ---- > javaOpts= -Xmx1024m

这里1024m是你想要分配的自定义内存量。

Weka 3.9.2 also does not has the option of maxheap anymore. RunWeka.ini have the option of javaOpts, So you may change the below to your required memory allocation,

javaOpts=%JAVA_OPTS%   ---- > javaOpts= -Xmx1024m

Here 1024m is the customised amount of memory you want to allocate.

愁杀 2024-12-30 09:16:19

使用此命令的最佳方法

    java -Xmx1024m -[weka classifier] -t [training file path]

The best way to do it using this command

    java -Xmx1024m -[weka classifier] -t [training file path]
∞梦里开花 2024-12-30 09:16:19

上面的答案太旧了(最后一个是一年前的)。
我在 Windows 10 上的 WEKA(版本 3.8.1) 遇到了同样的问题。

我在更新堆大小时遇到​​了问题,我修复它的方法是添加一个环境变量(在控制面板下)如下:

JAVA_OPTS = -Xms30000m -Xmx30000m

提示:只需确保 RunWeka.ini 使用此环境变量即可。

在上面的示例中,我给 WEKA 30GB。有用。

希望它对某些人有帮助。

The answers above are too old (last one is 1 year ago).
I had same issue with my WEKA (version 3.8.1) on Windows 10.

I had a problem to update the heap size , the way I fixed it is by adding an environment variable (under control panel) as follows:

JAVA_OPTS = -Xms30000m -Xmx30000m

Tip: Just ensure that RunWeka.ini is using this environment variable.

In the above example I give WEKA 30GB. It works.

Hope it will be helpful for some people.

空心空情空意 2024-12-30 09:16:19

您还应该查看默认线程堆栈大小 20MB 是否足够。将文件 /Applications/weka-3-8-1-oracle-jvm.app/Contents/Info.plist(在 MAC 上)中的值增加到 50MB,如下所示:

<string>-Xss50M</string>

You should also see if default thread stack size 20MB is enough. Increase the value to 50MB in the file /Applications/weka-3-8-1-oracle-jvm.app/Contents/Info.plist (on MAC) like below:

<string>-Xss50M</string>
南风起 2024-12-30 09:16:19

如果我们使用 Weka Workbench CLI 或 Knowledge explorer,我们需要
更改如下。

正如文档建议的,运行时参数应该是 -Xmx[size_required]m,其中 [size_required] 是您打算保留以避免内存异常的内存大小。

打开 RunWeka.ini

定义 maxheap=[size_required]G

在我的情况下,我保留 maxheap=4G ,可以设置 maxheap=4096m 并将 -Xmx#maxheap# 添加到 # setups 的所有运行选项(前缀为“cmd_”) ") java 命令旁边的部分
如下所示,

cmd_default=javaw -Xmx#maxheap# ...............
cmd_console=cmd.exe /K start cmd.exe ..................
cmd_explorer=java -Xmx#maxheap# .................
cmd_knowledgeFlow=java -Xmx#maxheap#....................

maxheap=4G

通过重新启动 Weka 和 Help>>SystemInfo 来验证是否相同

If we are using Weka Workbench CLI or Knowledge explorer we need to
change as below.

As the documentation suggests the runtime parameter should be -Xmx[size_required]m where [size_required] is memory size you intend to keep to avoid memory exception.

Open RunWeka.ini

Define maxheap=[size_required]G

In my case I kept maxheap=4G , One can set like maxheap=4096m and add -Xmx#maxheap# to all the run options at # setups (prefixed with "cmd_") sections next to java commands
like below

cmd_default=javaw -Xmx#maxheap# ...............
cmd_console=cmd.exe /K start cmd.exe ..................
cmd_explorer=java -Xmx#maxheap# .................
cmd_knowledgeFlow=java -Xmx#maxheap#....................

maxheap=4G

Verify the same by restarting Weka and Help>>SystemInfo

听风念你 2024-12-30 09:16:19

如果您从命令行而不是通过 java 运行 weka,即在命令行中键入 weka,而不是键入

weka

指定内存标志

weka -m 1024m

,这将指定 1024 兆字节。

If you run weka from the command line but not through java i.e. typing weka into the command line, instead of typing

weka

specify the memory flag

weka -m 1024m

This will specify 1024 megabytes.

守不住的情 2024-12-30 09:16:19

如果您通过 weka.sh 运行 weka,则可以直接使用内存选项运行它。
例如,

sh weka.sh -memory 10g

这会将堆大小增加到 10Gb(在 Ubuntu 18.04 上使用 Weka 3.8.4 进行测试)

If you're running weka via weka.sh, you can directly run it with memory option.
For example,

sh weka.sh -memory 10g

This will increase the heap size to 10Gb (tested using Weka 3.8.4 on Ubuntu 18.04)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文