kasmtech / workspaces-issues

18 stars 4 forks source link

[Question] How can I use my discrete GPU inside of a KASM container? #629

Open BrandonShega opened 1 day ago

BrandonShega commented 1 day ago

I am running Proxmox on an old gaming PC and I am running KSAM in an unprivileged LXC. I think I finally got to the point that KASM can see and use the video card but any containers that I set up don't seem to be using it. I feel like I'm so close but am just missing the last step to get everything working. Here are the steps that I've taken so far:

  1. Disable passthrough for VM (disable vfio and nouveau modules and enable nvidia module)
  2. Install nvidia drivers on host, nvidia-smi shows the correct card
  3. Install nvidia drivers without kernel on the LXC
  4. Mount video card and renderD128 on the container in the .conf and give permissions to video and render groups
  5. nvidia-smi in container correctly shows my GPU
  6. Installed nvidia-container-toolkit on the container and configure Docker
  7. KASM shows the video card in the agent and even shows fan speed

Inside of KASM workspace I have tried the following:

Adding the first set of overrides from the manual AMD/Intel GPU documentation gives me this error message:

Processing of device (/dev/dri/card0,/dev/dri/renderD128) for container (b05947e1a856bcccf6a350d1747963d37b56950d91770ae04ddea0d224068803) failed + DEVICES=/dev/dri/card0,/dev/dri/renderD128
+ TARGET_UID=1000
+ for i in ${DEVICES//,/ }
++ stat -c %u /host_root//dev/dri/card0
+ DEV_UID=65534
+ '[' 65534 '!=' 1000 ']'
+ echo 'Device does not belong to user, changing ownership.'
+ chown 1000 /host_root//dev/dri/card0
Device does not belong to user, changing ownership.
chown: changing ownership of '/host_root//dev/dri/card0': Operation not permitted

When I add the new kasm-user using the last set of JSON I don't get any errors but inside of an Ubuntu focal workspace if I do glxinfo -b or glxgears I get:

default:~$ glxgears
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.

Any help is greatly appreciated. I'm really just trying to get the smoothest framerate that I can when using a workspace.

BrandonShega commented 1 day ago

Realized that I was typing the glxinfo command wrong. Here is some more output from within an Ubuntu focal workspace:

lspci -k

01:00.0 VGA compatible controller: NVIDIA Corporation GM200 [GeForce GTX 980 Ti] (rev a1)
    Subsystem: eVga.com. Corp. GM200 [GeForce GTX 980 Ti]
    Kernel driver in use: nvidia
01:00.1 Audio device: NVIDIA Corporation GM200 High Definition Audio (rev a1)
    Subsystem: eVga.com. Corp. GM200 High Definition Audio
    Kernel driver in use: snd_hda_intel

glxinfo -B

name of display: :1.0
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.
display: :1  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: llvmpipe (LLVM 15.0.7, 256 bits) (0xffffffff)
    Version: 24.1.7
    Accelerated: no
    Video memory: 32037MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 0 MB, largest block: 0 MB
    VBO free aux. memory - total: 27580 MB, largest block: 27580 MB
    Texture free memory - total: 0 MB, largest block: 0 MB
    Texture free aux. memory - total: 27580 MB, largest block: 27580 MB
    Renderbuffer free memory - total: 0 MB, largest block: 0 MB
    Renderbuffer free aux. memory - total: 27580 MB, largest block: 27580 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 0 MB
    Total available memory: 32037 MB
    Currently available dedicated video memory: 0 MB
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 15.0.7, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 24.1.7 - kisak-mesa PPA
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 24.1.7 - kisak-mesa PPA
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.1.7 - kisak-mesa PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20