Remote access to VMs with GPU using Citrix

This guide details the steps that you must take to prepare for remote access to virtual desktops using the technology that Citrix offers.

It will be useful to those who have recently become familiar with desktop virtualization technology, as it is a collection of useful commands assembled from ~ 10 manuals, many of which are available on the Citrix, Nvidia, Microsoft sites, after authorization.

This implementation contains the steps for preparing remote access to virtual machines (VMs) with Nvidia Tesla M60 graphics accelerators and the Centos 7 operating system.

So, let's begin.

Preparing a hypervisor for hosting virtual machines


How to download and install XenServer 7.4?
How to add XenServer to Citrix XenCenter?
How to download and install Nvidia driver?
How to change Nvidia Tesla M60 mode?
How to mount storage?


XenServer 7.4


The XenServer 7.4 download link is available after authorization on the Citrix website .



Let's install XenServer.iso on a server with 4x NVIDIA Tesla M60 in a regular way. In my case, iso is mounted via IPMI. For Dell servers, the BMC is managed through IDRAC. Installation steps are almost identical to installing Linux-like operating systems.

My XenServer c GPU address is 192.168.1.100

Install XenCenter.msi on the local computer from which we will manage hypervisors and virtual machines. Add a server with a GPU and XenServer there by clicking on the “Server” tab, then “Add”. Enter the username and password root specified during the installation of XenServer.



In XenCenter, after clicking on the name of the added hypervisor, the Console tab will be available. In the menu, select “Remote Service Configuration” and enable SSH authorization - “Enable / Disable Remote Shell”.

Nvidia driver


I will give free rein to emotions and I will say that for all the time I worked with vGPU I have never visited the site nvid.nvidia.com on the first try. If authorization does not work, then I recommend Internet Explorer.

Download zip from vGPU, as well as GPUMode Change Utility:

NVIDIA-GRID-XenServer-7.4-390.72-390.75-391.81.zip
NVIDIA-gpumodeswitch-2020-01.zip



We follow the versions. The name of the downloaded archive shows the version of suitable NVIDIA drivers that can be installed on virtual machines in the future. In my case, it is 390.72.

Throw zip-s on XenServer and unpack.

Change the GPU mode and install the vGPU driver

$ cd NVIDIA-gpumodeswitch-2020-01
$ gpumodeswitch --listgpumodes
$ gpumodeswitch --gpumode graphics
$ cd ../NVIDIA-GRID-XenServer-7.4-390.72-390.75-391.81
$ yum install NVIDIA-vGPU-xenserver-7.4-390.72.x86_64.rpm
$ reboot



Mount storage


Set up a shared directory using NFS on any computer on the network.

$ yum install epel-release
$ yum install nfs-utils libnfs-utils
$ systemctl enable rpcbind
$ systemctl enable nfs-server
$ systemctl enable nfs-lock
$ systemctl enable nfs-idmap
$ systemctl start rpcbind
$ systemctl start nfs-server
$ systemctl start nfs-lock
$ systemctl start nfs-idmap
$ firewall-cmd --permanent --zone=public --add-service=nfs
$ firewall-cmd --permanent --zone=public --add-service=mountd
$ firewall-cmd --permanent --zone=public --add-service=rpc-bind
$ firewall-cmd --reload
$ mkdir -p /nfs/store1
$ chmod -R 777 /nfs/store1
$ touch /nfs/store1/forcheck
$ cat /etc/exports
  ...
  /nfs/store1 192.168.1.0/24(rw,async,crossmnt,no_root_squash,no_all_squash,no_subtree_check)
$ systemctl restart nfs-server

In XenCenter, select XenServer and select “New SR” on the “Storage” tab. Specify the type of storage - NFS ISO. The path must point to the NFS shared directory.

Citrix Master Image Based on Centos 7


How to create a virtual machine with Centos 7?

How to prepare a virtual machine to create a directory?


The image of Centos 7



Using XenCenter, we will create a virtual machine with a GPU. In the “VM” tab, click “New VM”.



We select the necessary parameters:

VM template - Other install media
Name - template
Install from ISO library - Centos 7 ( download ), select from the mounted NFS ISO storage.
Number of vCPUs - 4
Topology - 1 socket with 4 cores per socket
Memory - 30 Gb
GPU type - GRID M60-4Q
Use this virtual disk - 80 Gb
Network

After creation, the virtual machine will appear in the vertical list on the left. Click on it and go to the "Console" tab. We will wait for the Centos 7 installer to load and complete the necessary steps to install the OS with the GNOME shell.

Image preparation


It took me a lot of time to prepare the image with Centos 7. This resulted in a set of scripts that facilitates the initial setup of Linux and allows you to create a virtual machine catalog using Citrix Machine Creation Services (MCS).

The DHCP server installed on ws-ad assigned the IP address 192.168.1.129 to the new virtual machine.

The following are the basic settings.

$ hostnamectl set-hostname template
$ yum install -y epel-release
$ yum install -y lsb mc gcc
$ firewall-cmd --permanent --zone=dmz --remove-service=ssh
$ firewall-cmd --permanent --zone=external --remove-service=ssh
$ firewall-cmd --permanent --zone=home --remove-service=ssh
$ firewall-cmd --permanent --zone=home --remove-service=mdns
$ firewall-cmd --permanent --zone=home --remove-service=samba-client
$ firewall-cmd --permanent --zone=home --remove-service=dhcpv6-client
$ firewall-cmd --permanent --zone=internal --remove-service=dhcpv6-client
$ firewall-cmd --permanent --zone=internal --remove-service=samba-client
$ firewall-cmd --permanent --zone=internal --remove-service=mdns
$ firewall-cmd --permanent --zone=internal --remove-service=ssh
$ firewall-cmd --permanent --zone=public --remove-service=ssh
$ firewall-cmd --permanent --zone=public --remove-service=dhcpv6-client
$ firewall-cmd --permanent --zone=work --remove-service=dhcpv6-client
$ firewall-cmd --permanent --zone=work --remove-service=ssh
$ firewall-cmd --permanent --zone=public --add-service=ssh
$ firewall-cmd --complete-reload

In XenCenter, in the “Console” tab, mount guest-tools.iso in the DVD drive of the virtual machine and install XenTools for Linux.

$ mount /dev/cdrom /mnt
$ /mnt/Linux/install.sh
$ reboot

When setting up XenServer, we used the NVIDIA-GRID-XenServer-7.4-390.72-390.75-391.81.zip archive downloaded from the NVIDIA website, which, in addition to the NVIDIA driver for XenServer, contains the NVIDIA driver we need for vGPU clients. Download and install it on the VM.

$ cat /etc/default/grub
  GRUB_TIMEOUT=5
  GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
  GRUB_DEFAULT=saved
  GRUB_DISABLE_SUBMENU=true
  GRUB_TERMINAL_OUTPUT="console"
  GRUB_CMDLINE_LINUX="rhgb quiet modprobe.blacklist=nouveau"
  GRUB_DISABLE_RECOVERY="true"
$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ wget http://vault.centos.org/7.6.1810/os/x86_64/Packages/kernel-devel-3.10.0-957.el7.x86_64.rpm
$ yum install kernel-devel-3.10.0-957.el7.x86_64.rpm
$ reboot
$ init 3
$ NVIDIA-GRID-XenServer-7.4-390.72-390.75-391.81/NVIDIA-Linux-x86_64-390.75-grid.run
$ cat /etc/nvidia/gridd.conf
  ServerAddress=192.168.1.111
  ServerPort=7070
  FeatureType=1
$ reboot

Download the Linux Virtual Delivery Agent 1811 (VDA) for Centos 7. The download link for Linux VDA is available after authorization on the Citrix website .

$ yum install -y LinuxVDA-1811.el7_x.rpm
$ cat /var/xdl/mcs/mcs.conf
  #!/bin/bash
  dns1=192.168.1.110
  NTP_SERVER=some.ntp.ru
  AD_INTEGRATION=winbind
  SUPPORT_DDC_AS_CNAME=N
  VDA_PORT=80
  REGISTER_SERVICE=Y
  ADD_FIREWALL_RULES=Y
  HDX_3D_PRO=Y
  VDI_MODE=Y
  SITE_NAME=domain.ru
  LDAP_LIST=ws-ad.domain.ru
  SEARCH_BASE=DC=domain,DC=ru
  START_SERVICE=Y
$ /opt/Citrix/VDA/sbin/deploymcs.sh
$ echo "exclude=kernel* xorg*" >> /etc/yum.conf

In Citrix Studio, create the Machine Catalog and Delivery group. Before this, you must install and configure Windows Server.

Windows Server with Domain Controller


How to download and install Windows Server 2016?
How to install Windows Server components?
How to configure Active Directory, DHCP and DNS?


Windows server 2016


Since a virtual machine (VM) with Windows Server does not need a GPU, we will use a server without a GPU as a hypervisor. By analogy with the description above, install another XenServer for hosting system virtual machines.

After that, create a virtual machine for Windows Server with Active Directory.

Download Windows Server 2016 from the Microsoft website . It is better to follow the link using Internet Explorer.



Using XenCenter, we will create a virtual machine. In the “VM” tab, click “New VM”.



We select the necessary parameters:

VM template - Windows Server 2016 (64-bit)
Name - ws-ad.domain.ru
Install from ISO library - WindowsServer2016.iso, select from the mounted NFS ISO storage.
Number of vCPUs - 4
Topology - 1 socket with 4 cores per socket
Memory - 20 Gb
GPU type - none
Use this virtual disk - 100 Gb
Network

After creation, the virtual machine will appear in the vertical list on the left. Click on it and go to the "Console" tab. Wait for the Windows Server installer to load and complete the necessary steps to install the OS.

Install in XenTools VM. Right-click on VM, then "Install Citrix VM Tools ...". After that, the image that you need to run and install XenTools will be mounted. At the end of the installation, a reboot of the VM will be required.

Configure the network adapter:

IP address - 192.168.1.110
Mask - 255.255.255.0
Gateway - 192.168.1.1
DNS1 - 8.8.8.8
DNS2 - 8.8.4.4

If Windows Server is not activated, then activate. The key can be taken in the same place where the image was downloaded.

[PowerShell]$ slmgr -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx

Set up the computer name. In my case, this is ws-ad.

Component Installation


In the server manager, select "Add Roles and Features." Note the installation of the DHCP server, DNC server, and Active Directory Domain Services. Check the box "Reload automatically."



Configure Active Directoy


After rebooting the VM, click "Raise this server to the domain controller level" and add a new domain.ru forest.

DHCP server setup


On the top panel of the server manager, click on the exclamation mark to save the changes when installing the DHCP server.

Let's move on to the DHCP server settings.



Create a new area 192.168.1.120-130. We do not change the rest. Select “Configure DHCP settings now” and enter the ws-ad IP address (192.168.1.110) as the gateway and DNS, which will be specified in the settings of the network adapters of virtual machines from the directory.

DNS server setup


Let's move on to the DNS server settings.



Let's create a new zone of direct viewing - primary zone, for all DNS servers in the domain.ru domain. Do not change anything else.

Create a new reverse lookup zone by selecting the same options.

In the properties of the DNS server, in the "Advanced" tab, check the "Disable recursion" checkbox.

Create a test user


Let's go to the "Active Directory Administrative Center"



In the "Users" section on the right, click "Create." Enter a name, for example test, and click OK below.



We’ll select the created user and select “Reset Password” in the vertical menu on the right. Leave the checkmark “Require password change the next time you log on to the system.”

Windows Server with Citrix Delivery Controller


How to download and install Windows Server 2016?
How to download and install Citrix Delivery Controller?
How to install and configure Citrix License Manager?
How to install and configure NVIDIA License Manager?


Windows server 2016


Since a virtual machine (VM) with Windows Server does not need a GPU, we will use a server without a GPU as a hypervisor.

Download Windows Server 2016 from the Microsoft website . It is better to follow the link using Internet Explorer.



Using XenCenter, we will create a virtual machine. In the “VM” tab, click “New VM”.



Select the necessary parameters:

VM template - Windows Server 2016 (64-bit)
Name - ws-dc
Install from ISO library - WindowsServer2016.iso, select from the mounted NFS ISO storage.
Number of vCPUs - 4
Topology - 1 socket with 4 cores per socket
Memory - 20 Gb
GPU type - none
Use this virtual disk - 100 Gb
Network

After creation, the virtual machine will appear in the vertical list on the left. Click on it and go to the "Console" tab. We will wait for the Windows Server installer to load and complete the necessary steps to install the OS.

Install in XenTools VM. Right-click on VM, then "Install Citrix VM Tools ...". After that, the image that you need to run and install XenTools will be mounted. At the end of the installation, a reboot of the VM will be required.

Configure the network adapter:

IP address - 192.168.1.111
Mask - 255.255.255.0
Gateway - 192.168.1.1
DNS1 - 8.8.8.8
DNS2 - 8.8.4.4

If Windows Server is not activated, we will activate it. The key can be taken in the same place where the image was downloaded.

[PowerShell]$ slmgr -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx

Set up the computer name. In my case, this is ws-dc.

Add the VM to the domain domen.ru, reboot and log in under the domain administrator account DOMEN \ Administrator.

Citrix delivery controller


Download Citrix Virtual Apps and Desktops 1811 at ws-dc.domain.com. The Citrix Virtual Apps and Desktops download link is available after logging in to the Citrix website .



Mount the downloaded iso and run. Choose Citrix Virtual Apps and Desktops 7. Next, click "Get started". A reboot may be required.



In my case, it is enough to select the following components for installation:

Delivery Controller
Studio
License Server
StoreFront

Do not change anything else and click "Install." A reboot will be required more than once, after which the installation will continue.

As soon as the installation is complete, Citrix Studio, the Citrix farm management environment, will start.



Citrix Site Setup


Choose the first section of the three - Site setup. When setting, specify the Site Name - domain.

In the “Connection” section, we specify the data for connecting the hypervisor with the GPU:

Connection address - 192.168.1.100
User name - root
Password - yourpassword
Connection Name - m60

Store management - Use storage local to the hypervisor.

Name for these resources - m60.

Select networks.

Select a GPU type and group - GRID M60-4Q.

Tuning Citrix Machine Catalogs


When setting up the second section - Machine Catalogs, select Single-session OS (Desktop OS).

Master Image - select the prepared image of the virtual machine and the version of Citrix Virtual Apps and Desktops - 1811.

Choose the number of virtual machines in the directory, for example 4.

Let us indicate the scheme by which the virtual machines will be named, in my case this is desktop ##. In this case, 4 VMs with the names desktop01-04 will be created.

Machine Catalog name - m60.

Machine Catalog description - m60.

After creating the Machine Catalog with four VMs, they can be found in the XenCenter vertical list on the left.

Citrix Delivery Group


The third section begins by selecting the number of VMs to which access should be granted. I will indicate all four.

In the "Desktops" section, click "Add" to add the VM group to which we will provide access. Display name - m60.

Delivery group name - m60.

After setting up the three main sections, the main window of Citrix Studio will look something like this



Citrix license manager


Download the license file through your personal account on the Citrix website .

In the vertical list on the left, select All Licensing Tools (Legacy). Go to the tab "Activate and Allocate Licenses". Select Citrix VDA licenses and click Continue. Specify the name of our Delivery Controllera - ws-dc.domain.ru and the number of licenses - 4. Click "Continue". Download the generated license file for ws-dc.domain.ru.



In the left vertical list of Citrix Studio, select the "Licensing" section. In the right vertical list, click "License Management Console". In the browser window that opens, enter the data for authorization of the domain user DOMEN \ Administrator.

In Citrix Licensing Manager, go to the “Install License” tab. To add a license file, select "Use downloaded license file".



Installation of Citrix components involves the use of several virtual machines, one component - one VM. In my case, all Citrix system services operate within the same VM. In this regard, I note one bug, the correction of which was especially difficult for me.

If after rebooting ws-dc there are problems of a different nature, then I recommend that you check the running services first. Here is a list of Citrix services that should automatically start after a VM reboot:

SQL Server (SQLEXPRESS)
Citrix Configuration Service
Citrix Delegated Administration Service
Citrix Analytics
Citrix Broker Service
Citrix Configuration Logging Service
Citrix AD Identity Service
Citrix Host Service
Citrix App Library
Citrix Machine Creation Service
Citrix Monitor Service
Citrix Storefront Service
Citrix Trust Service
Citrix Environment Test Service
Citrix Orchestration Service
FlexNet License Server -nvidia

I encountered a problem that occurs when installing various Citrix services on a single VM. After a reboot, not all services start. One by one to launch the entire chain was laziness. The solution was googled hard, so I bring it here - two parameters should be changed in the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
Name : ServicesPipeTimeout
Value :240000

Name : WaitToKillServiceTimeout
Value : 20000

Nvidia license manager


Download the NVIDIA License Manager for Windows through your personal account on nvid.nvidia.com . It’s better to go through Internet Explorer.



Install it on ws-dc. To do this, you first need to install JAVA and add the environment variable JAVA_HOME. After that, you can run setup.exe to install the NVIDIA License Manager.



Let's create a server, generate and download the license file in your personal account on the site nvid.nvidia.com . Let's transfer the license file for ws-dc.



Using a browser, we log in to the NVIDIA license manager web interface, available at localhost : 8080 / licserver and add a license file.



Active sessions using vGPU can be viewed in the Licensed Clients section.

Remote access to the Citrix machine catalog



How to install Citrix Receiver?
How to connect to a virtual desktop?


On the working computer, open a browser, in my case it’s Chrome, and go to the address of the web interface of Citrix StoreWeb

http://192.168.1.111/Citrix/StoreWeb

If Citrix Recever is not already installed, then click “Discover Receiver”. We



carefully read the license agreement, download and install Citrix Receiver.



After installation, go back to the browser and click “Continue.”



Next, a notification opens in the Chrome browser, click “Open Citrix Receiver Launcher application” , and then “Detect again” or “Already installed”.



For the first connection, we will use the data of the test user test. Change the temporary password to a permanent one.



After authorization, go to the “Applications” tab and select the “M60”



directory . Download the proposed file with the extension .ica. After double-clicking on it, a window opens in Desktop Veiwer with the Centos 7 desktop


All Articles