增加 java 中 weka 的堆大小
我正在尝试增加 java 中 weka 的堆大小,但它一直崩溃。我使用了建议的行:
> java -Xmx500m -classpath
但出现以下错误:
-classpath requires class path specification
我不确定这意味着什么。有什么建议吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(17)
我发现实际问题出在
'\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.
在终端中运行此命令:
Run this command in your terminal:
省略
-classpath
选项。仅使用-Xmx500m
选项。因此,不仅仅是:
你这样做:
如果你通过某个脚本(例如 RunWeka.bat)运行 weka,那么你需要修改该脚本(使用一些文本编辑器,如记事本)。
Omit the
-classpath
option. Use just-Xmx500m
option.So, instead of just:
you do:
If you run weka via some script (RunWeka.bat for example), then you need to modify that script (with some text editor like notepad).
如果您在 Windows 上使用 Weka 3.8.1,您可以通过编辑
javaOpts
参数来省去很多麻烦。参数maxheap
不再使用,因此您可以在RunWeka.ini文件中像这样设置javaOpts
:其中
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 parametermaxheap
isn't used anymore, so you can setjavaOpts
like this in RunWeka.ini file: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.Weka 官方答案(适用于所有操作系统和 Weka 版本)可以在 http:// /weka.wikispaces.com/OutOfMemoryException。
如果您在 Windows 上使用最新的 Weka 版本,答案是:
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:
在 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
您需要在
-classpath
之后指定一个类路径,类似于PATH
环境变量,您需要指定 Java 可以找到类的路径。-Xmx500m
设置看起来不错,但我建议使用 512m。You need to specify a classpath after
-classpath
, similar to thePATH
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.对于 Mac OS,您必须编辑配置文件才能增加 Weka UI 应用程序的堆大小。
我重复我写的内容: 当已指定最大堆值时,是否有解决方法来解决“Java堆空间”内存错误?
如果 Weka 正在运行,请退出。
cd 进入 /Applications/weka-XXX.app/Contents ,或者安装 weka 可执行文件的任何位置。那里会有一个名为
Info.plist
的文件。它是一个 XML 文本文件。我建议您将其副本保存到另一个位置,因为您需要在下一步中对其进行编辑。在您喜欢的文本编辑器中打开
Info.plist
(XML) 文件,然后查找显示“VMOptions”的块。应该有一个值“-Xmx256M”或类似的值指定最大值堆大小。您应该将该值更改为更大的值,例如“-Xmx1024M”。启动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?
Quit out of Weka if it is running.
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.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".Start Weka.
我在 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"
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).
Weka 3.9.2 也不再有 maxheap 的选项。 RunWeka.ini中有javaOpts的选项,所以你可以将下面的内容更改为你需要的内存分配,
这里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,
Here 1024m is the customised amount of memory you want to allocate.
使用此命令的最佳方法
The best way to do it using this command
上面的答案太旧了(最后一个是一年前的)。
我在 Windows 10 上的 WEKA(版本 3.8.1) 遇到了同样的问题。
我在更新堆大小时遇到了问题,我修复它的方法是添加一个环境变量(在控制面板下)如下:
提示:只需确保 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:
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.
您还应该查看默认线程堆栈大小 20MB 是否足够。将文件 /Applications/weka-3-8-1-oracle-jvm.app/Contents/Info.plist(在 MAC 上)中的值增加到 50MB,如下所示:
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:
正如文档建议的,运行时参数应该是 -Xmx[size_required]m,其中 [size_required] 是您打算保留以避免内存异常的内存大小。
打开 RunWeka.ini
在我的情况下,我保留 maxheap=4G ,可以设置 maxheap=4096m 并将 -Xmx#maxheap# 添加到 # setups 的所有运行选项(前缀为“cmd_”) ") java 命令旁边的部分
如下所示,
通过重新启动 Weka 和 Help>>SystemInfo 来验证是否相同
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
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
Verify the same by restarting Weka and Help>>SystemInfo
如果您从命令行而不是通过 java 运行 weka,即在命令行中键入
weka
,而不是键入指定内存标志
,这将指定 1024 兆字节。
If you run weka from the command line but not through java i.e. typing
weka
into the command line, instead of typingspecify the memory flag
This will specify 1024 megabytes.
如果您通过 weka.sh 运行 weka,则可以直接使用内存选项运行它。
例如,
这会将堆大小增加到 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,
This will increase the heap size to 10Gb (tested using Weka 3.8.4 on Ubuntu 18.04)