Tips for running Mathematica on Solaris (and why Sage is better a choice)

I've been a long time user of Mathematica from Wolfram Research is a high-end maths program that runs on various operating systems. Whereas the maths programs MATLAB, Maple and Mathematica are all available for Sun's Solaris on Sun's SPARC hardware, Mathematica is the only commercial maths program currently available on Solaris x86. However, due to their popularity, both Windows and Linux versions of Mathematica appear to undergo more testing, so sometimes issues arise on Solaris which are not met on other platforms, such as Windows or Linux. This document will highlight some of these, and give solutions where I am aware of them.

However, I've now come to the conclusion that generally, the expensive closed-source Mathematica is not an ideal tool, as you have to trust these black boxes. Whilst it is cheap as a student, when you go into the real world you find that the cost puts many companies off of using Mathematica. (Do a search for jobs requiring Mathematica skills, and you will find very few indeed). Bug reports are not public, so generally I've become less trustfull of Mathematica and are swapping to use the open-source Sage maths software, which to me at least, has more advantages than Mathmatica. But I've collected this information about Mathematica, so I will share it.

The necessary -noTrueTypeFont

Some versions of Solaris will need the -noTrueTypeFont option to Mathematica, as described on the Wolfram Reserach web site

Removing cache data

If Mathematica gets in a mess, crashes or otherwise mis-behaves, the cache data it computes may be invalid. Try the option

Other useful command line options

It's worth trying any sensible looking command line options listed on Wolfram's web site, in the event of problems.

Mathematica 6.0.1 crashes on Solaris (SPARC)

If you find Mathematica crashing all the time, update the XSun patch. Solaris patch 119059-31 caused Mathematica to crash on my system. You will also need -noTrueTypeFont. Once Mathematica has had a problem, always use -cleanStart to.

Mathematica 5.x using excessive CPU time on Solaris 10.

On some systems, computing something as simple as 1+1=2 on Mathematica 5.1 and 5.2 can result in Mathematica using loads of CPU time. The anwser is returned quickly, but the program just pegs the CPU. The following conditions are necessary for the bug to be exhibited:

The problem was introduced following a change to Solaris in the first release of Solaris 10 in January 2006. Sun would say this was not a Solaris bug, but an enhancement to Solaris. But the enhancement broke binary backward compatibility, so it was submitted as a bug ID 6404383 on 27th March 2006. A solution was found by Casper Dik of Sun Microsystems following my post to comp.unix.solaris under the title Mathematica problems on Solaris. I then posted the solution to sci.math.symbolic and comp.unix.solaris under the new title SOLVED - Excessive Mathematica CPU usage on Solaris 10.
The best way to solve this is to update to Solaris 10 update 3 or later.

Another method, which is detailed on sci.math.symobic and comp.unix.solaris is quicker to implement. This involves compiling a small C file select_preload.c to create a shared library, then ensuring Mathematica loads this before the main libraries. (Here is a copy of the compiled library if you would rather not compile it youself). Read the thread SOLVED - Excessive Mathematica CPU usage on Solaris 10 if you want to use this method, but upgrading the operating system is probably a good idea.

Mathematica uses excessive CPU time on multi-processor machines

Another bug noticed on Mathematica 5.2 only appeared in some calculations and only when there were multiple CPUs present.
The solution to this is to either disable the extra CPUs with /usr/sbin/psradm, or set the environment variable OMP_NUM_THREADS to 1. Clearly setting an environment variable that only affects Mathematica and not every application on the system is better, so it is suggested you use
$ /usr/local/bin/mathematica
or if you use the csh or tcsh,
% set env OMP_NUM_THREADS 1
% /usr/local/bin/mathematica

Mathematica 6.0.1 or 6.0.2 has some characters unreadable

Mathematica has been known to generate tons of error messages to stderr, like the following

X Error: BadMatch (invalid parameter attributes) 8
  Extension:    156 (RENDER)
  Minor opcode: 4 (RenderCreatePicture)
  Resource id:  0x3600003
X Error: RenderBadPicture (invalid Picture parameter) 182
  Extension:    156 (RENDER)
  Minor opcode: 7 (RenderFreePicture)
  Resource id:  0x3600004
X Error: BadMatch (invalid parameter attributes) 8
  Extension:    156 (RENDER)
  Minor opcode: 4 (RenderCreatePicture)
  Resource id:  0x3600004
X Error: RenderBadPicture (invalid Picture parameter) 182
  Extension:    156 (RENDER)
  Minor opcode: 7 (RenderFreePicture)
  Resource id:  0x3600005
  Major opcode of failed request:  156 (RENDER)
  Minor opcode of failed request:  7 (RenderFreePicture)
    Picture id in failed request: 0x36002dc

and not display some characters such as [ and ]. This has been observed on both Solaris x86 and Linux. The characters are actually displayed, but the problem is they are in the same colour as the background, so you can't see them.
The solution is given on a Linux web site, under the title Mathematica renders fonts incorrectly in Hardy. (Hardy is the code name for some Linux release I believe). One needs to to pass the command line parameter -defaultvisual to mathematica. It might be easier to edit /usr/local/bin/mathematica and add -defaultvisual to the last line.

Mathematica crashes on Solaris x86 with an Intel CPU

Mathematica 6.0, 6.0.1 and 6.0.2 are all supported on Solaris 10 x86, but only on AMD CPUs, not Intel CPUs. You will get error messages similar to these MathKernel: fatal: version `SUNWprivate_1.1' not
found (required by file
/usr/local/Wolfram/Mathematica/6.0/SystemFiles/Libraries/Solaris-x86-64/ MathKernel: fatal: open failed: No such file or

The reason for the error is that some of the libraries supplied with Mathematica 6.0, 6.01 and 6.0.2 need the AMD_3DNOW instruction set, which Intel CPUs don't have. (At the time of writing, Mathemtaica 6.0.2 is the latest release, so this may or may not apply to later releases of Mathematica.)
The solution to this is to replace some of the libraries supplied with Mathematica by those supplied by Sun, which do not need the AMD_3DNOW instructions. I posted full instructions on the sci.math.symoblic newsgroup, under the title A hack to run Mathematica 6 on Solaris x86 with an Intel CPU The instructions there require you to install Sun Studio 12 development system to get the libraries. If you dont have Sun Stuidio 12, you can download the librares from this web site.

Mathematica fails to determine the number of CPUs correctly on SPARC

At least some versions of Mathematica prior to 6.0.2, the scripts /usr/local/bin/mathematica and /usr/local/bin/math set a variable SystemID to Solaris-SPARC on Solaris SPARC. There is a test
if [ "${SystemID}" = "UltraSPARC" -o "${SystemID}" = "Solaris-x86-64" ];
That will never evaluate to true, since the SystemID was set to Solaris-SPARC and not UltraSPARC. Instead the code should have been:
if [ "${SystemID}" = "Solaris-SPARC" -o "${SystemID}" = "Solaris-x86-64" ];
That was fixed in 6.0.2 (and possibly in 6.0.1, but I dont know.) Note also that I think the test is a bit simplistic, as it actually measures the number of CPUs in the system, not the number online, which might be different. I'm not sure how it will handle the cases of processor sets. For original post on this was in the thread Mathematica 6 bug. Fails to find number of CPUs - a cure!!.

Any more tips?

If you have any more tips for Mathematica on Solaris, send them to me by email.

I'd like to express my thanks to Megagate who are providing free hosting for this site.

Valid HTML 4.01 Valid CSS! Thank you to MegaGate for hosting