Created
April 26, 2022 17:51
-
-
Save raeidsaqur/8a7797851d71258008b036cb87cd3fc1 to your computer and use it in GitHub Desktop.
Bash script for Virtual X-server setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install NVIDIA driver: | |
sudo apt-get update | |
sudo apt-get install nvidia-driver-460 | |
sudo reboot now | |
# Wait 3 minutes and reconnect | |
sleep 3m | |
# Check that nvidia driver is loaded: | |
nvidia-smi | |
# Set up virtual X-server | |
sudo apt-get install -y xserver-xorg mesa-utils | |
sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024 | |
# Create an xorg.conf file | |
echo 'Section "ServerLayout" | |
Identifier "Layout0" | |
Screen 0 "Screen0" | |
EndSection | |
Section "Monitor" | |
Identifier "Monitor0" | |
VendorName "Unknown" | |
ModelName "Unknown" | |
Option "DPMS" | |
EndSection | |
Section "Device" | |
Identifier "Device0" | |
Driver "nvidia" | |
VendorName "NVIDIA Corporation" | |
BoardName "Tesla K80" | |
EndSection | |
Section "Screen" | |
Identifier "Screen0" | |
Device "Device0" | |
Monitor "Monitor0" | |
DefaultDepth 24 | |
Option "UseDisplayDevice" "None" | |
SubSection "Display" | |
Virtual 1280 1024 | |
Depth 24 | |
EndSubSection | |
EndSection | |
Section "ServerFlags" | |
Option "AllowMouseOpenFail" "true" | |
Option "AutoAddGPU" "false" | |
Option "ProbeAllGpus" "false" | |
EndSection' >> xorg.conf | |
# Launch the X-server on DISPLAY 1 | |
sudo Xorg -noreset -sharevts -novtswitch -config xorg.conf :1 vt1 & | |
sudo Xorg -noreset -sharevts -novtswitch :0 vt0 & | |
sudo Xorg -noreset -sharevts -novtswitch :1 vt1 & | |
# Set the DISPLAY environment variable to point to this new display | |
export DISPLAY=":1" | |
# Check that it works (should get FPS in the tens of thousands): | |
glxgears |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment