TUTORIAL : How to install VirtualGL and TurboVNC on Jetson Nano

Hello.

I’ve installed VirtualGL and TurboVNC in my Jetson Nano. I followed and adapted the tutorial that do the same but on the Jetson TK1 :

and also this script that does not work out of the box :

On this cezs github there are two scripts that should be modified a little bit and also some packages should be installed before running these scripts. Below there are the scripts modified by me :

nv_nano_build_and_install_vgl_and_vnc.sh :

# Built VirtualGL, TurboVNC and libjpeg-turbo for 64-bit Linux / Jetson nano / For Tegra R32.4.2
#
# Largely based on https://devtalk.nvidia.com/default/topic/828974/jetson-tk1/-howto-install-virtualgl-and-turbovnc-to-jetson-tk1/2
#

rm -r tmp
mkdir tmp
cd tmp
currentDir=$(pwd)

# DEPENDENCIES

# install necessary packages to build them.
sudo apt-get install git
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install cmake
sudo apt-get install g++
sudo apt-get install libpam0g-dev
sudo apt-get install libssl-dev
sudo apt-get install libjpeg-turbo8-dev libjpeg8-dev libturbojpeg0-dev
sudo apt-get install ocl-icd-opencl-dev

# upgrade CMAKE

wget https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5.tar.gz
tar -zxvf cmake-3.16.5.tar.gz
cd cmake-3.16.5
./bootstrap
make
make install

# LIBJPEG-TURBO

wget http://launchpadlibrarian.net/482987839/libturbojpeg_1.5.2-0ubuntu5.18.04.4_arm64.deb
dpkg -i libturbojpeg_1.5.2-0ubuntu5.18.04.4_arm64.deb

# Build and install libjpeg-turbo
#git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
#mkdir libjpeg-turbo-build
#cd libjpeg-turbo
#autoreconf -fiv
#cd ../libjpeg-turbo-build
#sh ../libjpeg-turbo/configure
#make

# Change "DEBARCH=aarch64" to "DEBARCH=arm64"

#sed -i 's/aarch64/arm64/g' pkgscripts/makedpkg.tmpl
#make deb
#sudo dpkg -i libjpeg-turbo_1.5.2_arm64.deb
#cd ../

# VIRTUALGL

# Preventing link error from "libGL.so", check this:
# https://devtalk.nvidia.com/default/topic/946136/jetson-tx1/building-an-opengl-application/

#cd /usr/lib/aarch64-linux-gnu
#sudo rm libGL.so
#sudo ln -s /usr/lib/aarch64-linux-gnu/tegra/libGL.so libGL.so

# Build and install VirtualGL
cd $currentDir
git clone https://github.com/VirtualGL/virtualgl.git
mkdir virtualgl-build
cd virtualgl-build
cmake -G "Unix Makefiles" -DTJPEG_LIBRARY="-L/usr/lib/ -lturbojpeg" ../virtualgl
make

# Change "DEBARCH=aarch64" to "DEBARCH=arm64"
sed -i 's/aarch64/arm64/g' pkgscripts/makedpkg
# Change "Architecture: aarch64" to "Architecture: arm64"
sed -i 's/aarch64/arm64/g' pkgscripts/deb-control
make deb

# sudo dpkg -i virtualgl_2.5.2_arm64.deb
cd ..

# TURBOVNC

# Build and install TurboVNC
git clone https://github.com/TurboVNC/turbovnc.git

mkdir turbovnc-build
cd turbovnc-build
cmake -G "Unix Makefiles" -DTVNC_BUILDJAVA=0 -DTJPEG_LIBRARY="-L/usr/lib/ -lturbojpeg" ../turbovnc

# Prevent error like #error "GLYPHPADBYTES must be 4",
# edit ../turbovnc/unix/Xvnc/programs/Xserver/include/servermd.h
# and prepend before "#ifdef __avr32__"
#servermd="$currentDir/turbovnc/unix/Xvnc/programs/Xserver/include/servermd.h"
#line="#ifdef __avr32__"
#defs="#ifdef __aarch64__\n\

# define IMAGE_BYTE_ORDER       LSBFirst\n\
# define BITMAP_BIT_ORDER       LSBFirst\n\
# define GLYPHPADBYTES          4\n\
#endif\n"
#sed -i "/$line/i $defs" "$servermd"
make

# Change "DEBARCH=aarch64" to "DEBARCH=arm64"
#sed -i 's/aarch64/arm64/g' pkgscripts/makedpkg
# Change "Architecture: aarch64" to "Architecture: arm64"
#sed -i 's/aarch64/arm64/g' pkgscripts/deb-control
#make deb

# sudo dpkg -i turbovnc_2.1.1_arm64.deb

# SYSTEM

# Add system-wide configurations
cd $currentDir
echo "/opt/libjpeg-turbo/lib64" > libjpeg-turbo.conf
sudo cp libjpeg-turbo.conf /etc/ld.so.conf.d/
sudo ldconfig
rm ./libjpeg-turbo.conf

# Add TurboVNC to path
if ! grep -Fq "/root/Desktop/turbovnc/jtx1_remote_access/tmp/turbovnc-build/bin" "$HOME/.bashrc"; then
    echo '-export PATH=$PATH:/root/Desktop/turbovnc/jtx1_remote_access/tmp/turbovnc-build/bin' >> ~/.bashrc
fi

# Add VirtualGL to path
if ! grep -Fq "/root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin" "$HOME/.bashrc"; then
    echo 'export PATH=$PATH:/root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin' >> ~/.bashrc
fi

# copied from https://github.com/nicksp/dotfiles/blob/master/setup.sh
answer_is_yes() {
  [[ "$REPLY" =~ ^[Yy]$ ]] \
    && return 0 \
    || return 1
}

print_question() {
  # Print output in yellow
  printf "\e[0;33m  [?] $1\e[0m"
}

# copied from https://github.com/nicksp/dotfiles/blob/master/setup.sh
ask_for_confirmation() {
  print_question "$1 (y/n) "
  read -n 1
  printf "\n"
}

cd ..
ask_for_confirmation "Do you want to remove leftover files?"
if answer_is_yes; then
    rm -drf tmp
fi

nano_configure_vgl_and_vnc.sh :

# Built VirtualGL, TurboVNC and libjpeg-turbo for 64-bit Linux for Jetson Nano / Tegra R32.4.2
#
# Based on https://devtalk.nvidia.com/default/topic/828974/jetson-tk1/-howto-install-virtualgl-and-turbovnc-to-jetson-tk1/2
#

# copied from https://github.com/nicksp/dotfiles/blob/master/setup.sh
answer_is_yes() {
  [[ "$REPLY" =~ ^[Yy]$ ]] \
    && return 0 \
    || return 1
}

print_question() {
  # Print output in yellow
  printf "\e[0;33m  [?] $1\e[0m"
}

# copied from https://github.com/nicksp/dotfiles/blob/master/setup.sh
ask_for_confirmation() {
  print_question "$1 (y/n) "
  read -n 1
  printf "\n"
}

# Configure VirtualGL
# See https://cdn.rawgit.com/VirtualGL/virtualgl/2.5/doc/index.html#hd006
echo -e "Configuring VirtualGL..." 
#sudo /opt/VirtualGL/bin/vglserver_config
chmod +x /root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl/server/vglserver_config
chmod +x /root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl/server/vglgenkey
sudo /root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl/server/./vglserver_config
#sudo usermod -a -G vglusers ubuntu
echo -e "\n" 

# Install xfce4
echo -e "Configuring window manager...\n" 
ask_for_confirmation "Do you want to install xfce4 window manager? (There might be problems with running default unity on TurboVNC)."
if answer_is_yes; then
    cp /root/.vnc/xstartup xstartup.turbovnc
    chmod -x /root/.vnc/xstartup
    xstartup="$HOME/.vnc/xstartup.turbovnc"
    line="unset DBUS_SESSION_BUS_ADDRESS"
    startline="# enable copy and paste from remote system\n\
vncconfig -nowin &\n\
export XKL_XMODMAP_DISABLE=1\n\
autocutsel -fork\n\
# start xfce4\n\
startxfce4 &"
#   sudo apt-get install xfce4 gnome-icon-theme-full xfce4-terminal
    if ! grep -Fq "startxfce4" $xstartup; then
        sed -i "/$line/a $startline" $xstartup
    fi
fi

ln -sf /usr/lib/aarch64-linux-gnu/libdrm.so.2.4.0 /usr/lib/aarch64-linux-gnu/libdrm.so.2

it works nice :

c53c9ccae563c5e6d4594883af95d03e825c6407_2_690x388

@rreddy78

You may check this.

thanks man. this command solved the problem : ln -sf /usr/lib/aarch64-linux-gnu/libdrm.so.2.4.0 /usr/lib/aarch64-linux-gnu/libdrm.so.2

now it works wonderfully :

anyway :

root@zi-desktop:/# /usr/local/cuda-10.2/samples/5_Simulations/oceanFFT/./oceanFFT
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
Error unable to find GLSL vertex and fragment shaders!

Try to run from oceanFFT directory, as a data directory is required and looked for in current directory.

cd usr/local/cuda/samples/5_Simulations/oceanFFT
./oceanFFT

root@zi-desktop:/usr/local/cuda/samples/5_Simulations/oceanFFT# ./oceanFFT
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
GPU Device 0: “Maxwell” with compute capability 5.3

CUDA error at oceanFFT.cpp:296 code=999(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&cuda_heightVB_resource, heightVertexBuffer, cudaGraphicsMapFlagsWriteDiscard)”
corrupted size vs. prev_size
Aborted

iirc, running some CUDA + OpenGL sample requires -nodl option like:

/opt/VirtualGL/bin/vglrun -nodl ./oceanFFT

root@zi-desktop:/# /home/zi/Desktop/Work/I9/Tools/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin/vglrun -nodl /usr/local/cuda/samples/5_Simulations/oceanFFT/./oceanFFT

ERROR: ld.so: object ‘libvglfaker-nodl.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
Error unable to find GLSL vertex and fragment shader

root@zi-desktop:/usr/local/cuda/samples/5_Simulations/oceanFFT# /home/zi/Desktop/Work/I9/Tools/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin/vglrun -nodl ./oceanFFT

ERROR: ld.so: object ‘libvglfaker-nodl.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
GPU Device 0: “Maxwell” with compute capability 5.3

CUDA error at oceanFFT.cpp:296 code=999(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&cuda_heightVB_resource, heightVertexBuffer, cudaGraphicsMapFlagsWriteDiscard)”
corrupted size vs. prev_size
Aborted

Anyway,anytime my jetson nano reboots suddenly,this symbolic link : usr/lib/aarch64-linux-gnu/libdrm.so.2 is removed and I must recreate it.

@demotomohiro
maybe you know how to address the issue as follows

 /opt/VirtualGL/bin/vglrun -d 1  -nodl glxgears
[VGL] ERROR: Could not open display 1.

but

 glxgears
libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
3145 frames in 5.0 seconds = 625.513 FPS

the latter works while the former fails to find a display

echo $DISPLAY
:1.0
/opt/VirtualGL/bin/vglrun -d 1.0 -nodl glxgears
[VGL] ERROR: Could not open display 1.0.

VirtualGL needs Xorg running for 3D rendering even if your machine is not connected to display.
Are you sure Xorg running?
If not, you might need to add Option “AllowEmptyInitialConfiguration” in xorg.conf to run Xorg without the external display.
Xorg runs in display 0 and TurboVnc runs in display 1 in default.
In that case, you don’t need to add “-d 1” option to vglrun.

@demotomohiro
thank you for your response!
it seems the first issue was due to the incorrect display identifier ;
the correct way was to put

-d :1.0

then it turned into another issue
that got addressed by

sudo  ln -sf /usr/lib/aarch64-linux-gnu/libdrm.so.2.4.0 /usr/lib/aarch64-linux-gnu/libdrm.so.2

[Thanks @Honey_Patouceul for pointing to the quick patch]
then it got all like glxgears runs with VGL without issue:

$ /opt/VirtualGL/bin/vglrun -nodl -d :1.0 glxgears
917 frames in 5.0 seconds = 182.773 FPS

then I edited xorg.conf once again so GL seems to work with oceanFTT.
then -d :1.0 was omitted so everything works without it

Thank you very much!

root@zi-desktop:~/Desktop/zi/Work# /root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin/./vglrun -d 1 -nodl glxgears

ERROR: ld.so: object 'libvglfaker-nodl.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

but it works :

221 frames in 5.0 seconds = 44.172 FPS

173 frames in 5.0 seconds = 34.598 FPS

root@zi-desktop:~/Desktop/zi/Work# glxgears
323 frames in 5.0 seconds = 64.596 FPS

no errors

    root@zi-desktop:~/Desktop/zi/Work# /root/Desktop/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin/./vglrun -nodl glxgears
    
    ERROR: ld.so: object 'libvglfaker-nodl.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

but it works :

221 frames in 5.0 seconds = 44.042 FPS

root@zi-desktop:/usr/local/cuda/samples/5_Simulations/oceanFFT# ./oceanFFT
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
GPU Device 0: “Maxwell” with compute capability 5.3

CUDA error at oceanFFT.cpp:296 code=999(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&cuda_heightVB_resource, heightVertexBuffer, cudaGraphicsMapFlagsWriteDiscard)”
corrupted size vs. prev_size
Aborted

@marietto2008
it seems you need may to edit your xorg.conf to overcome the “:296 code=999(” error.
you may try adding the Section for screen 0, unless it is there already,
otherwise Xorg won’t start without a connected display on Display=:0 interface, likely

Section “Screen”
Identifier “Screen0”
Display=:1
Option “AllowEmptyInitialConfiguration”
Option “UseEdid” “False”
EndSection

virtualgl-build/bin# /usr/local/cuda/samples/5_Simulations/oceanFFT/./oceanFFT
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
Error unable to find GLSL vertex and fragment shaders!

root@zi-desktop:~/Desktop/zi/Work/I9/Tools/turbovnc/jtx1_remote_access/tmp/virtualgl-build/bin# echo $DISPLAY
:1.0

You may try to run from oceanFFT directory as advised in post #6.

root@zi-desktop:/usr/local/cuda/samples/5_Simulations/oceanFFT# ./oceanFFT
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
GPU Device 0: “Maxwell” with compute capability 5.3

CUDA error at oceanFFT.cpp:296 code=999(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&cuda_heightVB_resource, heightVertexBuffer, cudaGraphicsMapFlagsWriteDiscard)”
Segmentation fault

When I put Display=:0 on the xorg file echo $DISPLAY returns 1,so I’ve put 1 but it gives that error.