How to Run a Graphics Application in a PBS Batch Job

Article ID: 523
Last updated: 14 Sep, 2026

In order to run a graphics application in a PBS batch job, you must provide a value for the DISPLAY environment variable—even if you do not have or need an actual display for the job. If the batch job cannot find this value, it will quit and return an error such as "Can't open display" or "Display not set."

To provide a value for the DISPLAY variable, you can set up a display connection using either X11 forwarding or a VNC session, or you can run the job on the NAS GPU nodes, which include graphics cards. Each of these methods is described below.

Method 1: Use X11 Forwarding to Set Up a Display

Complete these steps to use your local system as an remote X11 server, which acts as the display:

  1. Set up X11 Forwarding (if it's not set up already).
  2. Log in to a PFE and submit a PBS batch job with the -V option on the qsub command line or inside the PBS script. For example:
    your_local_system% ssh pfe25
    pfe25% echo $DISPLAY
    10.150.27.21:30.0
    pfe% qsub -V job_script

    In the above example, using the -V option will export the DISPLAY environment variable (with its value set to 10.150.27.21:30.0) from your PFE login session to the PBS batch job.

Drawbacks to using this method:

  • Because the connection from the PBS job to your local system must be maintained, you cannot exit from either your local system or from the PFE login window until the job completes.
  • Application performance on remote X11 servers deteriorates with latency, so unless your local system is physically close to the NAS facility, job performance may not be optimal.

Method 2: Use a VNC Session to Set Up a Display

Complete these steps on a PFE to set up a VNC viewer, which acts as the display:

  1. Complete steps 1–4 of the instructions in VNC: A Faster Alternative to X11 to establish a VNC session. 

    Once the VNC viewer is set up and running, you will see the following messages (or something similar) in the PFE login window:

    pfe25% vncserver
    
    New 'X' desktop is pfe25:9
    
    Starting applications specified in /u/username/.vnc/xstartup
    Log file is /u/username/.vnc/pfe25:9.log

    This information indicates that the DISPLAY value pfe25:9.0 is set, providing a valid display that your PBS batch jobs can access.

  2. In your PBS batch job script, add the following line to instruct the job to use this display:
    • For csh: setenv DISPLAY pfe25:9.0
    • For bash: export DISPLAY=pfe25:9.0
  3. Submit your PBS batch job from the PFE connection window where the VNC session is running.

Benefits of using this method:

  • Job performance is not impacted.
  • The VNC viewer will be maintained as long as the PFE you started it on (pfe25 in this example) is online. The session will stay open even if you exit from your local system or from the PFE connection window where the viewer is running. To reconnect to the session, simply log in to the PFE and repeat steps 3 and 4 in the VNC instructions with the same port number (5909 in this example).

Note: The number of VNC ports on each PFE is limited. You must stop the vncserver script after your PBS job completes, or the port will remain open and owned by you, which prevents other users from using it. Remember to complete step 5 in the VNC instructions to properly shut down your VNC session.

Method 3: Run Your Job on the NAS GPU Nodes

When you run a job on a GPU node, a display is enabled automatically. 

Complete these steps to run your job on a GPU node:

  1. Modify your PBS script to run startx and set DISPLAY to :0.0 by adding these lines:
    /bin/startx /usr/bin/Xvnc :1 -s 0 -ac -br -listen tcp passwordFile=$HOME/.vnc/passwd &
    setenv DISPLAY :1.0       (for csh)
    or
    export DISPLAY=:1.0       (for bash)
    sleep 15  # wait 15 seconds to allow the startx to fully start up before using the display
  2. Submit a batch job to request a GPU node using the correct queue:

    To request a GPU node:

    cfe01% qsub -q a100 -lselect=1:model=mil_a100 pbs_script

    Note: The NAS GPUs with x86-64 CPUs are accessible from cfe01 or cfe02, not the PFEs.

Drawbacks to using this method:

  • There are fewer GPU nodes available than non-GPU nodes.
  • You cannot use this method if your graphics application needs more than 64 GB of memory. 

Contact Us

General User Assistance

Security

  • Report security issues 24x7x365
  • Toll-free: 1-877-NASA-SEC (1-877-627-2732)
  • E-mail: soc@nasa.gov

User Documentation

High-End Computing Capability (HECC) Portfolio Office

NASA High-End Computing Program

Tell Us About It

Our goal is furnish all the information you need to efficiently and effectively use the HECC resources needed for your NASA computational projects.

We welcome your input on features and topics that you would like to see included on this website.

Please send us email with your wish list and other feedback.