Skip to content

Instantly share code, notes, and snippets.

@alexholehouse
Last active May 22, 2024 19:55
Show Gist options
  • Save alexholehouse/32f07b8ef1bddf942148926673649a4f to your computer and use it in GitHub Desktop.
Save alexholehouse/32f07b8ef1bddf942148926673649a4f to your computer and use it in GitHub Desktop.
Guide on running VMD on high DPI screens

Guide on running VMD on high DPI screens

Running VMD on HDPI (high DPI - i.e. high resolution) screens in Linux remains a challenge due in part to the underlying FLTK library.

After exploring this for a while I came across the current solution which works reasonably well and should be relatively robust across cross-linux platforms. I'd be delighted if there were a simpler way, so please pull-request and update this if/when a better solution emerges. I wanted to write this so that someone with a minimal background in Linux could still get this up and running, as many people who use VMD may be new to Linux computing. If this describes you and things remain unclear, please

Setting up run_scaled

run_scaled is a simple but incredibly helpful bash script written by Alexander Kauer. It can be downloaded from here and added into your $PATH. If you know what this means, jump ahead to the Dependencies section.

$PATH is a list of location that the shell checks for executable files when you type something into the terminal. To see which directories are currently in your $PATH variable type

echo $PATH

# on ubuntu 18.04 this reveals
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Now you have two options for adding things to your $PATH. One is to select one of those directories and copy the file run_scaled into that directory. To do this you may need to copy as root. A better option, however, is to create a new directory in user space where you can add any/all executable files you might want to use.

To do this, we'll create a file in our home directory called bin

 cd ~           # cd to the home directory
 mkdir bin      # make the directory bin

Then copy run_scaled into this directory and make sure the permission is set to executable - i.e. if you downloaded run_scaled into your home/<username>/Downloads folder and were currently in your home directory, this would look like

 cp Downloads/run_scaled bin/ 

To check this has worked, type

  ls ~/bin    # list all the files in the newly created bin directory 

This should print the name run_scaled to the terminal prompt. Note that '~' is shorthand for your 'home' directory.

Finally make sure run_scaled is executable by running

  cd ~/bin
  chmod +x run_scaled

This moves us to the ~/bin directory and adds the eXecutable permission stamp to the file (if it's already executable nothing bad will happen).

Finally, we have to add the directory /home//bin to the $PATH. The easies way to do this is to edit your shell configuration file. To check what shell you're running type

echo $SHELL

If this prints out either /usr/bin/zsh or /usr/bin/bash then great! If it prints out something else you may need to do some Googling to check how to add a directory to the $PATH in your shell.

For zsh or bash this is easy though.

If you're using zsh...

If you're running zsh (echo $SHELL = /usr/bin/zsh) then enter the following into your terminal:

echo "export PATH=\${PATH}:~/bin" >> .zshrc

If you're using bash...

If you're running bash (echo $SHELL = /usr/bin/bash) then enter the following into your terminal:

echo "export PATH=\${PATH}:~/bin" >> .bashrc

What do these do?

Both of these commands add the line

export PATH=${PATH}:~/bin

To your .zshrc or .bashrc files, respectively, adding the directory ~/bin into the $PATH. To check this has worked start a new terminal and typ

echo $PATH   

and, HOPEFULLY your /home/bin directory is now the last directory in the $PATH.

Dependencies

run_scaled actually uses a few other bit of software to work. These are

Ubuntu (tested on 18.04)

For Ubuntu 18.04 these dependencies can be installed via

sudo apt install xpra 
sudo apt install xvfb  

Using run_scaled with VMD

Finally, to use runscaled with vmd simply type

run_scaled vmd

Or

run_scaled --scale=3 vmd

Where the '3' can be any number and defines the scaling factor

This format can still pass arguments to vmd; e.g.

    run_scaled --scale=3 vmd my_pdb.pdb

The interface may be slightly laggy, but not to a extent that is problematic. However, the window text can now be easily scaled without issue, making everything legible.

Postscript

I wanted to put this in one place because in all my Googling of VMD with small font, small text, can't read, I didn't find an example where someone had discussed the VMD-issue with run_scaled

@tautomer
Copy link

Hi, Prof. Holehouse.

Thanks a lot for the guide. I can run lots of GUI apps scaled up with this script, but VMD seems to quit itself automatically when I run run_scaled vmd.

Here is the log of xpra.

2022-01-27 15:18:44,690 cannot use uinput for virtual devices:
2022-01-27 15:18:44,690  [Errno 13] Failed to open the uinput device: Permission denied
2022-01-27 15:18:44,760 created unix domain socket '/run/user/37640/xpra/daeva-96799327'
2022-01-27 15:18:44,761 cannot create group socket '/run/xpra/daeva-96799327'
2022-01-27 15:18:44,761  [Errno 13] Permission denied
2022-01-27 15:18:44,839 pointer device emulation using XTest
2022-01-27 15:18:44,848 Error: cannot find the html web root
2022-01-27 15:18:44,848  '/usr/share/xpra/www' does not exist
2022-01-27 15:18:44,874 Warning: OpenGL support check failed:
2022-01-27 15:18:44,874  unknown error
2022-01-27 15:18:44,879 Warning: failed to load the mdns publisher
2022-01-27 15:18:44,880  No module named 'avahi'
2022-01-27 15:18:44,880  either install the 'python-avahi' module
2022-01-27 15:18:44,880  or use the 'mdns=no' option
2022-01-27 15:18:44,885 D-Bus notification forwarding is available

(Xpra:55080): Gtk-CRITICAL **: 15:18:44.887: gtk_widget_realize: assertion 'widget->priv->anchored || GTK_IS_INVISIBLE (widget)' failed
2022-01-27 15:18:44,909 Warning: webcam forwarding is disabled
2022-01-27 15:18:44,909  the virtual video directory '/sys/devices/virtual/video4linux' was not found
2022-01-27 15:18:44,909  make sure that the 'v4l2loopback' kernel module is installed and loaded
2022-01-27 15:18:44,909 found 0 virtual video devices for webcam forwarding
2022-01-27 15:18:44,915 xpra is ready.
2022-01-27 15:18:44,915 xpra GTK3 X11 version 3.0.6-r25177 64-bit
2022-01-27 15:18:45,002  running with pid 55080 on Linux Ubuntu 20.04 focal
2022-01-27 15:18:45,002  connected to X11 display :96799327 with 24 bit colors
2022-01-27 15:18:45,565 printer forwarding enabled using postscript and pdf
2022-01-27 15:18:45,570 started command 'vmd' with pid 55208
2022-01-27 15:18:45,578 watching for applications menu changes in:
2022-01-27 15:18:45,578  '/usr/share/ubuntu/applications'
2022-01-27 15:18:45,579  '/usr/share/applications'
$HOME/.local/lib/vmd/vmd_LINUXAMD64: /lib/x86_64-linux-gnu/libGL.so.1: no version information available (required by $HOME/.local/lib/vmd/vmd_LINUXAMD64)
Info) VMD for LINUXAMD64, version 1.9.3 (November 30, 2016)
Info) http://www.ks.uiuc.edu/Research/vmd/                         
Info) Email questions and bug reports to vmd@ks.uiuc.edu           
Info) Please include this reference in published work using VMD:   
Info)    Humphrey, W., Dalke, A. and Schulten, K., `VMD - Visual   
Info)    Molecular Dynamics', J. Molec. Graphics 1996, 14.1, 33-38.
Info) -------------------------------------------------------------
Info) Multithreading available, 16 CPUs detected.
Info)   CPU features: SSE2 AVX AVX2 FMA KNL:AVX-512F+CD+ER+PF 
Info) Free system memory: 27GB (86%)
Info) Creating CUDA device pool and initializing hardware...
Info) Detected 1 available CUDA accelerator:
Info) [0] Quadro P620         4 SM_6.1 @ 1.35 GHz, 1.9GB RAM, KTO, AE2, ZCP
Warning) Detected X11 'Composite' extension: if incorrect display occurs
Warning) try disabling this X server option.  Most OpenGL drivers
Warning) disable stereoscopic display when 'Composite' is enabled.
Info) OpenGL renderer: llvmpipe (LLVM 12.0.0, 256 bits)
Info)   Features: STENCIL MSAA(4) MDE CVA MTX NPOT PP PS GLSL(OVFS) 
Info)   Full GLSL rendering mode is available.
Info)   Textures: 2-D (16384x16384), 3-D (512x512x512), Multitexture (8)
Info) Detected 1 available TachyonL/OptiX ray tracing accelerator
Info)   Compiling 1 OptiX shaders on 1 target GPU...
2022-01-27 15:18:46,057 Warning: icon is quite large (79 KB):
2022-01-27 15:18:46,057  '/usr/share/icons/hicolor/48x48/apps/menulibre.svg'
2022-01-27 15:18:46,392 New unix-domain connection received
2022-01-27 15:18:46,392  on '/run/user/37640/xpra/daeva-96799327'
2022-01-27 15:18:46,394 Handshake complete; enabling connection
2022-01-27 15:18:46,442  mmap is enabled using 387MB area in /run/user/37640/xpra/xpra.jd3rjrl4.mmap
2022-01-27 15:18:46,443 Python/GTK3 Linux Ubuntu 20.04 focal x11 client version 3.0.6-r25177 64-bit
2022-01-27 15:18:46,445 setting key repeat rate from client: 500ms delay / 30ms interval
2022-01-27 15:18:46,445 setting keymap: 
2022-01-27 15:18:46,454 setting keyboard layout to 'us,us'
2022-01-27 15:18:46,479 waiting for initialization thread to complete
2022-01-27 15:18:46,824 Warning: icon is quite large (195 KB):
2022-01-27 15:18:46,825  '/usr/share/pixmaps/TeXworks.png'
Info) Dynamically loaded 2 plugins in directory:
Info) $HOME/.local/lib/vmd/plugins/LINUXAMD64/molfile
2022-01-27 15:18:46,851 Warning: icon is quite large (69 KB):
2022-01-27 15:18:46,851  '/opt/nvidia/nsight-compute/2021.3.1/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.png'
2022-01-27 15:18:46,851 Warning: icon is quite large (69 KB):
2022-01-27 15:18:46,851  '/opt/nvidia/nsight-compute/2022.1.0/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.png'
2022-01-27 15:18:46,851 Warning: icon is quite large (67 KB):
2022-01-27 15:18:46,851  '/opt/nvidia/nsight-systems/2021.3.3/host-linux-x64/nsys-ui.png'
2022-01-27 15:18:46,852 Warning: icon is quite large (67 KB):
2022-01-27 15:18:46,852  '/opt/nvidia/nsight-systems/2021.5.2/host-linux-x64/nsys-ui.png'
Info) VMD for LINUXAMD64, version 1.9.3 (November 30, 2016)
Info) Exiting normally.
2022-01-27 15:18:47,324 New unix-domain connection received
2022-01-27 15:18:47,327  on '/run/user/37640/xpra/daeva-96799327'
2022-01-27 15:18:47,558 Warning: icon is quite large (92 KB):
2022-01-27 15:18:47,558  '/usr/share/icons/hicolor/scalable/apps/usb-creator-kde.svg'
2022-01-27 15:18:49,229 31.1GB of system memory
2022-01-27 15:18:49,230  client root window size is 2752x1152 with 1 display:
2022-01-27 15:18:49,230   :1.0 (1165x488 mm - DPI: 60x59) workarea: 2680x1125 at 72x27
2022-01-27 15:18:49,230     DEL DP-0 (800x335 mm - DPI: 87x87)
2022-01-27 15:18:49,231 cannot find a temporary resolution for Xinerama workaround!
2022-01-27 15:18:49,233 server virtual display now set to 2752x1152
2022-01-27 15:18:49,247 client   1 @03.301 Xpra GTK3 X11 server version 3.0.6-r25177 64-bit
2022-01-27 15:18:49,247 client   1 @03.301  running on Linux Ubuntu 20.04 focal
2022-01-27 15:18:49,249 client   1 @03.306 Attached to socket:///run/user/37640/xpra/daeva-96799327
2022-01-27 15:18:49,249 client   1 @03.307  (press Control-C to detach)
/usr/lib/python3/dist-packages/gi/overrides/Gtk.py:1632: Warning: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
  return _Gtk_main(*args, **kwargs)
2022-01-27 15:18:49,251 child 'vmd ' with pid 55208 has terminated
2022-01-27 15:18:49,251 all children have exited and --exit-with-children was specified, exiting
2022-01-27 15:18:49,251 DPI set to 96 x 96
2022-01-27 15:18:49,252 Disconnecting client /run/user/37640/xpra/daeva-96799327:
2022-01-27 15:18:49,252  server shutdown
2022-01-27 15:18:49,252 Disconnecting client /run/user/37640/xpra/daeva-96799327:
2022-01-27 15:18:49,252  server shutdown
2022-01-27 15:18:49,253 xpra client 1 disconnected.
2022-01-27 15:18:49,254 killing xvfb with pid 55082
2022-01-27 15:18:49,254 removing socket '/run/user/37640/xpra/daeva-96799327'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/server/mixins/input_server.py", line 283, in _process_keyboard_sync_enabled_status
    assert proto in self._server_sources
AssertionError

There doesn't seem to be anything wrong with VMD. It just launches and then immediately quits.

Info) VMD for LINUXAMD64, version 1.9.3 (November 30, 2016)
Info) http://www.ks.uiuc.edu/Research/vmd/                         
Info) Email questions and bug reports to vmd@ks.uiuc.edu           
Info) Please include this reference in published work using VMD:   
Info)    Humphrey, W., Dalke, A. and Schulten, K., `VMD - Visual   
Info)    Molecular Dynamics', J. Molec. Graphics 1996, 14.1, 33-38.
Info) -------------------------------------------------------------
Info) Multithreading available, 16 CPUs detected.
Info)   CPU features: SSE2 AVX AVX2 FMA KNL:AVX-512F+CD+ER+PF 
Info) Free system memory: 27GB (86%)
Info) Creating CUDA device pool and initializing hardware...
Info) Detected 1 available CUDA accelerator:
Info) [0] Quadro P620         4 SM_6.1 @ 1.35 GHz, 1.9GB RAM, KTO, AE2, ZCP
Info) OpenGL renderer: llvmpipe (LLVM 12.0.0, 256 bits)
Info)   Features: STENCIL MSAA(4) MDE CVA MTX NPOT PP PS GLSL(OVFS) 
Info)   Full GLSL rendering mode is available.
Info)   Textures: 2-D (16384x16384), 3-D (512x512x512), Multitexture (8)
Info) Detected 1 available TachyonL/OptiX ray tracing accelerator
Info)   Compiling 1 OptiX shaders on 1 target GPU...
Info) Dynamically loaded 2 plugins in directory:
Info) $HOME/.local/lib/vmd/plugins/LINUXAMD64/molfile
Info) VMD for LINUXAMD64, version 1.9.3 (November 30, 2016)
Info) Exiting normally.

Does this workaround still work on your side?

@JSYLAR
Copy link

JSYLAR commented Feb 22, 2023

This doesn't work for me, creating a remote desktop that connects locally finally solving the problem, Remmina adjusted the resolution.

@renpj
Copy link

renpj commented Feb 26, 2023

Do you mean you setup a RDP server, and then connect to it from another PC?

This doesn't work for me, creating a remote desktop that connects locally finally solving the problem, Remmina adjusted the resolution.

@michal2am
Copy link

Hi, I got the "server does not support xi input devices" error:

~/vmd_scale/run_scaled vmd      
Entering daemon mode; any further errors will be reported to:
  /run/user/1000/xpra/:93177375.log
2023-03-30 13:43:41,935 Xpra GTK3 X11 client version 3.1 64-bit
2023-03-30 13:43:41,962  running on Linux Ubuntu 22.04 jammy
2023-03-30 13:43:41,962  window manager is 'GNOME Shell'
2023-03-30 13:43:41,973 opencv not found:
2023-03-30 13:43:41,973  No module named 'cv2'
2023-03-30 13:43:41,973  webcam forwarding is disabled
2023-03-30 13:43:42,077 GStreamer version 1.20.3 for Python 3.10.6 64-bit
2023-03-30 13:43:42,078 Warning: no pulseaudio information available
2023-03-30 13:43:42,078  No module named 'distutils.spawn'
2023-03-30 13:43:42,110 No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
2023-03-30 13:43:42,300 OpenGL enabled with NVIDIA GeForce RTX 3060/PCIe/SSE2
2023-03-30 13:43:42,305  keyboard settings: rules=evdev, model=pc105, layout=pl,us
2023-03-30 13:43:42,306  desktop size is 10240x2880 with 1 screen:
2023-03-30 13:43:42,306   :1.0 (1806x508 mm - DPI: 144x144) workarea: 10240x2826 at 0x54
2023-03-30 13:43:42,306     FUS DP-0 5120x2880 at 5120x0 (597x336 mm - DPI: 217x217)
2023-03-30 13:43:42,306     FUS DP-2 5120x2880 (597x336 mm - DPI: 217x217)
2023-03-30 13:43:42,306  upscaled to 200%, virtual screen size: 5120x1440
2023-03-30 13:43:42,306   :1.0 (1806x508 mm - DPI: 72x72) workarea: 5120x1413 at 0x27
2023-03-30 13:43:42,306     FUS DP-0 2560x1440 at 2560x0 (597x336 mm - DPI: 108x108)
2023-03-30 13:43:42,306     FUS DP-2 2560x1440 (597x336 mm - DPI: 108x108)
2023-03-30 13:43:43,992 enabled fast mmap transfers using 900MB shared memory area
2023-03-30 13:43:43,992 enabled remote logging
2023-03-30 13:43:43,992 Xpra GTK3 X11 server version 3.1-runknown 64-bit
2023-03-30 13:43:43,992  running on Linux Ubuntu 22.04 jammy
2023-03-30 13:43:43,996 Attached to socket:///run/user/1000/xpra/michal-Bieszczady-Linux-93177375
2023-03-30 13:43:43,996  (press Control-C to detach)

2023-03-30 13:43:44,129 server does not support xi input devices
2023-03-30 13:43:44,129  server uses: xtest
/usr/lib/python3/dist-packages/gi/overrides/Gtk.py:1689: Warning: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
  return _Gtk_main(*args, **kwargs)
2023-03-30 13:43:46,556 server requested disconnect:
2023-03-30 13:43:46,556  server shutdown

Any ideas on how to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment