-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfastgpu
More file actions
34 lines (33 loc) · 1.2 KB
/
fastgpu
File metadata and controls
34 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
module="nvidia" #Module we're checking against to determine if an accelerator is available.
gpu_id="0000:00:00.0"
basepath="/sys/bus/pci/drivers"
if [[ "$1" == *"="* ]];
then
for var in "$@"; do
if [[ "$var" == "$1" ]]; then
IFS=$'\n' ENVVARS=( $(xargs -n1 <<< $1) )
#parse out the first var as args
else
new_args+=($var)
#yeet the environment variables
fi
done
for key in ${ENVVARS[@]}
do
#export the environment variables
export $key
done
else
new_args=$@
fi
if [ -d "$basepath/$module/$gpu_id" ]
then
printf "Faster GPU is available, setting environment variables to use it.\n"
#Export nvidia requirements
export __NV_PRIME_RENDER_OFFLOAD=1 __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_nvidia.json DRI_PRIME=pci-0000_01_00_0 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia
else
printf "Faster GPU is not available. Check if you're passing it through to your VM or if you remembered to use the GPU swap script.\n"
fi
#run the program
"${new_args[@]}"