Saturday, January 02, 2010

Running OpenCyc 2.0 on OS X

The latest release of OpenCyc uses a Java runtime so it is portable. I often keep OpenCyc running on one of my servers, but for convenience I also wanted to be able to run it on my MacBook. My MacBook only has 2GB of RAM but this seems to be adequate, especially because I don't run the JVM in server mode on my laptop. Start by downloading the Linux OpenCyc 2.0 distribution.

Make a copy of the file opencyc-2.0/server/cyc/run/bin/run-cyc.sh and replace the original file contents with:
#!/bin/bash                                                                                         

MIN_HEAP=1300m
MAX_HEAP=1300m
PERM_SIZE=98m

java -Xms$MIN_HEAP -Xmx$MAX_HEAP -XX:MaxPermSize=$PERM_SIZE -cp lib/cyc.jar:lib/subl.jar:lib/juni\
t.jar:resource:lib/ext:plugins com.cyc.tool.subl.jrtl.nativeCode.subLisp.SubLMain -f "(progn (load\
\"init/jrtl-release-init.lisp\")))" "$@"
With these settings, OpenCyc 2.0 starts up quickly and has fairly good runtime performance on my MacBook: fine for experimenting with OpenCyc. Run the system using the top level run script (which you do not need to modify):
cd opencyc-2.0
scripts/run-cyc.sh
OpenCyc 2.0 consists of a AI reasoning runtime, a "real world" ontology, hundreds of thousands of terms and millions of relationships.

12 comments:

Fabiola Hanna said...

Thanks Mark for these instructions.

Is there something else that is needed for opencyc to run on a mac?
When I try to run it after following your instructions, I get this exception:

Exception in thread "main" java.lang.NoClassDefFoundError: com/cyc/tool/subl/jrtl/nativeCode/subLisp/SubLMain

Can you please explain?

Mark Watson, author and consultant said...

Hello Fabiola, I just downloaded a fresh Linux OpenCyc 2.0, un-tarred it, edited the pencyc-2.0/server/cyc/run/bin/run-cyc.sh, and everything worked OK.

I had to edit the pencyc-2.0/server/cyc/run/bin/run-cyc.sh file a bit when I copied the text from my blog post because of the continued lines - that is, this should all be on one line:

java -Xms$MIN_HEAP -Xmx$MAX_HEAP -XX:MaxPermSize=$PERM_SIZE -cp lib/cyc.jar:lib/subl.jar:lib/junit.jar:resource:lib/ext:plugins com.cyc.tool.subl.jrtl.nativeCode.subLisp.SubLMain -f "(progn (load \"init/jrtl-release-init.lisp\")))" "$@"
markws-macbook:opencyc-2.0

Please let me know if you have further problems.

Fabiola Hanna said...

Thanks! almost there, now I get the following exception:

Launching CYC server at Fri Apr 30 16:29:51 PDT 2010 ...
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
Cyc server has shut down at Fri Apr 30 16:29:52 PDT 2010


Thanks again,
fabiola

Mark Watson, author and consultant said...

Hello Fabiola, that looks (maybe) like you are using the wrong version of Java. On my system:

markw$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-10M3025)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)

If you are using a current version of Java, then email me directly - email is a faster way to communicate :-)

Mark Watson, author and consultant said...

Fabiola: good that you have it running. Enjoy!

Everyone else: make sure that you are using Java 1.6 and not 1.5.

Arthur said...

Thanks for your information. Is there a version of opencyc available that will run under java1.5 on a 32-bit powerbook g4 with 2gb? In December I was told to get java 1.6, but only after installing it did I discover that (a) it is 64-bit only, (b) its installer doesn't warn you that it won't work on 32-bit, and (c) the only way to revert is to reinstall the OS X.

Let others with old kit be warned ...

And if there's an old opencyc available that would run on my box, I'd love to know.

Mark Watson, author and consultant said...

Hello Author, I can't test this myself, but: OpenCyc should run fine with a properly installed JDK 1.5 (1.6 is probably not needed). So, if you can run other Java software on your Mac and compile Java source code (so you know you have both the JDK and JRE installed) then hopefully you should be good to go.

Hongzhao said...

Hello, Mr. Watson;

I have successfully run opencyc on windows XP and Vista. But cannot run ResearchCyc successfully.

The same exception as Fabiola happens:

Exception in thread "main" java.lang.NoClassDefFoundError: com/cyc/tool/subl/jrtl/nativeCode/subLisp/SubLMain

Can you tell me what is wrong with this? I have spent lots of time on this. Still cannot solve it.

Thank you very much.
Henry.

Mark Watson, author and consultant said...

Hello Hongzhao,

I don't have a copy of ResearchCyc; I just use OpenCyc. Sorry, but I can't really offer any advice except to contact the people at http://researchcyc.cyc.com/ and ask them.

-Mark

Henry said...

Hi, Mr.Watson;

Thank you for your reply. Now I can run ResearchCyc now.Need to run the startup batch file from one level up.

Hongzhao.

Aky Han said...

Hello,Mr Watson.I'm having problems with running the bat.

'm a novice on this.When I follow the instructions and run the run-cyc.bat.
1.It said missing server\jvm.dll.Then I copied the file from JDK's folder to the JRE's bin folder,then this error gone.
2.Then according to default parameters,memory exceeded.I lower down to get it started ,becomes like this -Xms256m -Xmx512m -XX:MaxPermSize=128m,so it's okay.
3. Could not create the Java Virtual Machine,so I found delete -XX:+UseCompressedOops could work.
4.But finally there's a problem that I could not solve: Could not find the main class : com.cyc.tool.subl.jrtl.nativeCode.subLisp.SubLMain

How to solve it,please help

Mark Watson, author and consultant said...

Hello Aky, it looks like the Java classpath is not set correctly. You might try running the startup script from a different directory.