allow_gpu_acceleration

in cookbooks/aws-parallelcluster-config/recipes/dcv.rb [21:64]


def allow_gpu_acceleration
  
  
  nvidia_xconfig_command = "nvidia-xconfig --preserve-busid --enable-all-gpus"
  nvidia_xconfig_command += " --use-display-device=none" if node['ec2']['instance_type'].start_with?("g2.")
  execute "Set up Nvidia drivers for X configuration" do
    user 'root'
    command nvidia_xconfig_command
  end

  
  
  dcv_gl = "#{node['cluster']['sources_dir']}/#{node['cluster']['dcv']['package']}/#{node['cluster']['dcv']['gl']}"
  case node['platform']
  when 'centos', 'amazon'
    package dcv_gl do
      action :install
      source dcv_gl
    end
  when 'ubuntu'
    execute 'apt install dcv-gl' do
      command "apt -y install #{dcv_gl}"
    end
  end

  
  bash 'Launch X' do
    user 'root'
    code <<-SETUPX
      set -e
      systemctl set-default graphical.target
      systemctl isolate graphical.target &
    SETUPX
  end

  
  execute 'Wait for X to start' do
    user 'root'
    command "pidof X || pidof Xorg"
    retries 5
    retry_delay 5
  end
end