-
Notifications
You must be signed in to change notification settings - Fork 79
Fix permissions causing vulkan failures #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In order for Vulkan to work the modelrunner user needs to be a member of the video and render groups (needed to access nodes in /dev/dri). So add modelrunner to video when creating the user. Unfortunately render does not have a fixed GID currently, so we'll have to deal with this another way. Signed-off-by: Piotr Stankiewicz <[email protected]>
The modelrunner user needs to be a member of the render group for Vulkan to work. Unfortunately render does not have a fixed GID, so we can't reliably handle this in the Dockerfile. So have the CLI query the hosts render GID and add it when starting the DMR container. Signed-off-by: Piotr Stankiewicz <[email protected]>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideOn Linux hosts, this PR retrieves the host 'render' group GID at runtime and adds it to container permissions in both the Go container setup and the docker-run script; it simplifies the Vulkan installation by using the libvulkan1 package; and it adjusts the Dockerfile to add the modelrunner user to the video group and remove obsolete Vulkan environment settings. Sequence diagram for adding host 'render' group to container permissions on LinuxsequenceDiagram
participant Controller as "CreateControllerContainer()"
participant OS as "Linux Host OS"
participant Docker as "Docker Container"
Controller->>OS: exec getent group render
OS-->>Controller: return group info (GID)
Controller->>Docker: append GID to GroupAdd
Docker-->>Controller: container runs with host 'render' group permissions
Sequence diagram for docker-run.sh adding host 'render' groupsequenceDiagram
actor User
participant Script as "docker-run.sh"
participant OS as "Linux Host OS"
participant Docker as "Docker Container"
User->>Script: Run docker-run.sh
Script->>OS: getent group render | cut -d: -f3
OS-->>Script: return GID
Script->>Docker: --group-add <GID>
Docker-->>Script: container runs with host 'render' group permissions
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Signed-off-by: Piotr Stankiewicz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Consider using Go’s os/user.LookupGroup instead of shelling out to getent for more portable and testable group lookups.
- Add error handling or a fallback in docker-run.sh around the getent render lookup so the script won’t fail if the render group is absent.
- You’ve duplicated the render GID lookup logic in both Go and bash—consider centralizing it into a shared utility or function to reduce maintenance overhead.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using Go’s os/user.LookupGroup instead of shelling out to getent for more portable and testable group lookups.
- Add error handling or a fallback in docker-run.sh around the getent render lookup so the script won’t fail if the render group is absent.
- You’ve duplicated the render GID lookup logic in both Go and bash—consider centralizing it into a shared utility or function to reduce maintenance overhead.
## Individual Comments
### Comment 1
<location> `scripts/docker-run.sh:10-11` </location>
<code_context>
args+=("--device" "$i")
fi
done
+ args+=("--group-add" "$(getent group render | cut -d: -f3)")
}
</code_context>
<issue_to_address>
**suggestion (bug_risk):** No error handling if 'render' group is missing could lead to runtime failures.
Add a check to verify the 'render' group exists before using its ID to prevent passing an invalid value to docker.
```suggestion
render_gid="$(getent group render | cut -d: -f3)"
if [ -n "$render_gid" ]; then
args+=("--group-add" "$render_gid")
fi
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| args+=("--group-add" "$(getent group render | cut -d: -f3)") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): No error handling if 'render' group is missing could lead to runtime failures.
Add a check to verify the 'render' group exists before using its ID to prevent passing an invalid value to docker.
| args+=("--group-add" "$(getent group render | cut -d: -f3)") | |
| } | |
| render_gid="$(getent group render | cut -d: -f3)" | |
| if [ -n "$render_gid" ]; then | |
| args+=("--group-add" "$render_gid") | |
| fi | |
| } |
Summary by Sourcery
Simplify Vulkan setup and ensure containers run with appropriate group permissions to fix Vulkan failures
Enhancements: