Setting up numpy on a local jobe server

Setting up numpy on a local jobe server

by Chris Sangwin -
Number of replies: 12

We are writing coderunner questions in Python3 and want to import NumPy functions into these questions.

Our questions work fine if we point to jobe2.cosc.canterbury.ac.nz

Python3 is installed on the command line, and the numpy module imports and executes fine if we use python3 from the command line on our jobe server.

However, if we point coderunner to our jobe server we get a "segmentation fault".  See the attached image.

There must be a fault with the way we have installed our jobe server.  We have used "apt-get" to install all packages, and installed python3 etc from apt-get repositories.

Can anyone suggest what this might be caused by or how we could track down the problem?

Thanks,

Chris



Attachment NumPyWoe.png
In reply to Chris Sangwin

Re: Setting up numpy on a local jobe server

by Richard Lobb -

Ouch. Messy!

It certainly looks like a Linux/Python/Numpy problem, nothing to do with CodeRunner. However, to confirm you could import numpy from within a Python shell on Jobe. For example:

rjl83@csse-jobe2:~$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> 

I'm guessing the import will give you a segmentation fault.

From earlier email correspondence with David, I think numpy and possibly the rest of scipy was originally installed using pip, but the install was for python2. It's possible you now have conflicts between the python3 and python2 libraries. I've had issues of this sort before, though never a segmentation fault. My only suggestion, which is horrible system hacking stuff, is to uninstall all the extra Python libraries, both for python2 and python3, then uninstall python3 and move any remaining python3 folders sidewise. Reinstall python3 followed by just numpy, using pip3 not pip.

Richard

In reply to Richard Lobb

Re: Setting up numpy on a local jobe server

by Chris Sangwin -

Thanks Richard,

We have a script to install our Jobe server, and regularly re-build from this. I think our preferred solution is to find an install path from scratch which will work.  This avoids "uninstall" and "move sideways" which David (rightly!) seeks to avoid.  I think we will pursue the PIP route then.  I'll post an update.

Chris


In reply to Richard Lobb

Re: Setting up numpy on a local jobe server

by David Marsh -

Hi Richard,

We had previously followed the SciPy instructions for installing via apt-get, which (unknown to me at the time), only related to Python2. We then also installed the corresponding SciPy packages for Python3 as well, but, as you suggest, the system is possibly confused as to which it should be using.

I have now purged our test jobe server and started again, this time installing only Python3 packages, and we are about to test again.

One thing I notice from the jobe installation instructions is the optional installation of pylint. This seems to be a Python2 package, and there also is a corresponding pylint3 package, should we perhaps be installing and using that instead (the jobe testsubmit.py script uses this as part of its tests)?

(I am wondering whether bringing in any Python2 packages perhaps causes the system confusion as to which Python environment it should be using? We are also wondering if there is anything that we perhaps need to do (such as setting the PYTHONPATH variable somewhere) to ensure that submissions sent to the jobe server are trying to use the Python3 environment rather than the Python2 one?)


In reply to Richard Lobb

Re: Setting up numpy on a local jobe server

by David Marsh -

If we continue to have no luck with the NumPy packages from the Ubuntu .deb package repository, I am wondering whether using pip3 would actually work for us as an alternative?

The SciPy instructions for pip appear to suggest that pip is for installing packages into a user's filespace (which then needs to be set up to add the installation folder to the user's path). I am not sure how (or whether) this would work for installing the packages to be available to jobe: what user would need to have and "know about" the pip packages?

In reply to Richard Lobb

Re: Setting up numpy on a local jobe server

by David Marsh -
And just to sanity-check everything (my own sanity, that is!)...

Can I just check:

  • The jobe server needs to be able to receive requests from the Moodle/CodeRunner server on port 80
  • (How does the jobe server return its results: our Moodle server only responds on the https port 443, and will display a (Moodle) error page if an incoming request is made to port 80 (I don't know enough about REST to know whether it returns data via the same initial connection that was made from the Moodle server)?)
  • Is code in submitted questions interpreted/compiled/run only on the jobe server? Specifically, any additional programming language packages would not (also) need to be installed on the Moodle/CodeRunner server?
  • Does the PYTHONPATH variable (or similar) need to be set for jobe somehow?
  • Any other requirements for communication between the Moodle and jobe servers that I may have missed?
In reply to David Marsh

Re: Setting up numpy on a local jobe server

by Richard Lobb -

Answering your various queries:

  1. I'm pretty sure pip3 installs globally by default, unless you're using virtualenv, which you shouldn't do on Jobe. You need to run pip/pip3 with sudo but make sure your umask at the time you run pip allows access for all (e.g. run umask 022  first).
  2. I think you might have a point about pylint. I vaguely remember having to fix pylint for Python 3 on the most recent Jobe server and I maybe forgot to update the documentation. I might recommend the use of pip3 here, rather than apt-get, too. Thanks.
  3. Yes, the Jobe server receives all requests on port 80 and responds on the same connection so doesn't need to be able to open outgoing connections. [And indeed it would be a security flaw to allow it to do so.]
  4. All code is executed on Jobe. No language packages need to be installed on the Moodle server.
  5. You shouldn't need to touch PYTHONPATH. I never do.
  6. I don't think there are any further communication requirements other than those documented in the Jobe install instructions.
Hope it all goes well this time around.

Richard

In reply to Richard Lobb

Re: Setting up numpy on a local jobe server

by David Marsh -

Thanks so much again, Richard, for your help.

Unfortunately, we still seem to have the same problem (NumPy code runs OK from the terminal on the jobe server, something coredumps when NumPy is run from CodeRunner).

Here is the setup of our test jobe server, in case there is anything that I have inadvertently missed out or got wrong:

  • Ubuntu 16.04 LTS server install (ie, a very minimal install with no X window system, etc)
  • The first user account has sudo rights.

We installed jobe by:

sudo apt-get install apache2 php libapache2-mod-php php-mcrypt \
mysql-server php-mysql \
php-cli octave nodejs \
git python3 build-essential openjdk-8-jre openjdk-8-jdk python3-pip \
fp-compiler pylint3 acl

# Need to temporarily 'be' root for the following command (rather than sudo?) ?
sudo su
pylint --reports=no --generate-rcfile > /etc/pylintrc
exit

# ^^^^ We skipped this part on our last attempt: for pylint3,
# should the config file have the same name?


# To install using pip3 instead
# (pip suggests that the -H option to sudo is a Good Thing?)
sudo -H pip3 install numpy scipy matplotlib ipython jupyter pandas sympy nose


# The jobe installer expects it to be the in the following folder
cd /var/www/html
sudo git clone https://github.com/trampgeek/jobe.git

cd jobe
sudo ./install

We would be able to give you a login account to our test jobe server, if you would perhaps be kind enough to be able to login and have a look?

Thanks again,

David.

In reply to David Marsh

Re: Setting up numpy on a local jobe server

by David Marsh -
A further follow-up:

It looks as though pip3 has installed its packages into /usr/local (/usr/local/bin/, /usr/local/lib/python3.5/, etc), but it seems at this point that CodeRunner (from sys.path) is possibly looking in /usr/lib/python3.5/ (etc) first(?) in preference?

['/home/jobe/runs/jobe_7xQnjG', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages’]
In reply to David Marsh

Re: Setting up numpy on a local jobe server

by David Marsh -
I am also wondering if this thread is relevant to us (or whether it relates to an older version of jobe)?


Would we perhaps need to manually edit the file:

/var/www/html/jobe/application/libraries/python3_task.php

in order to have jobe look somewhere else for the NumPy packages installed via pip3?


(I am not sure how the OS Python (/usr/bin/python3) and the pip packages installed under /usr/local (/usr/local/lib/python3.5/dist-packages) relate to and/or know about and/or ignore each other (as appropriate)?)

In reply to David Marsh

Re: Setting up numpy on a local jobe server

by Richard Lobb -
Let's take this off the forum for now David. I'll send you an email.


Richard

In reply to Richard Lobb

Re: Setting up numpy on a local jobe server [SOLVED]

by David Marsh -

Thank you, Richard, for your help with this.

For anybody else following this thread, it turned out that our questions were exceeding the default resource limits for tasks for jobe (possibly this may have been if our NumPy installation was loading in many other packages), causing the segmentation fault (the limits are listed in a section further down the jobe README).

To resolve the problem, we needed to:

  1. Open the author's view of the question
  2. Click the Customise checkbox
  3. Open Advanced Customisation
  4. Set the memory limit to a larger value.
In reply to David Marsh

Re: Setting up numpy on a local jobe server [SOLVED]

by David Marsh -

(Just also confirming that, once we had identified that it was the memory limit that was causing the problem for us, the SciPy/NumPy packages installed via apt-get do in fact work, and it is not necessary to use pip.)