Skip to content

Commit

Permalink
Check for apple,arm-platform in /proc
Browse files Browse the repository at this point in the history
In /proc/device-tree/compatible specifically, thanks Asahi Lina!

It's more portable accross Fedora Asahi Remix and Ubuntu Asahi
Remix.

Also added env var to container image.

Co-authored-by: Asahi Lina <lina@asahilina.net>
Co-authored-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Eric Curtin <ecurtin@redhat.com>
  • Loading branch information
3 people committed Feb 4, 2025
1 parent 3a08829 commit afae544
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions container-images/asahi/Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM fedora:41

ENV ASAHI_VISIBLE_DEVICES 1
COPY ../scripts /scripts
RUN chmod +x /scripts/*.sh && \
/scripts/build_llama_and_whisper.sh "asahi"
Expand Down
16 changes: 10 additions & 6 deletions ramalama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,16 @@ def get_gpu():
return

# ASAHI CASE
if os.path.exists('/etc/os-release'):
with open('/etc/os-release', 'r') as file:
if "asahi" in file.read().lower():
# Set Env Var and break
os.environ["ASAHI_VISIBLE_DEVICES"] = "1"
return
if os.path.exists('/proc/device-tree/compatible'):
try:
with open('/proc/device-tree/compatible', 'rb') as f:
content = f.read().split(b"\0")
# Check if "apple,arm-platform" is in the content
if b"apple,arm-platform" in content:
os.environ["ASAHI_VISIBLE_DEVICES"] = "1"
except OSError:
# Handle the case where the file does not exist
pass

# NVIDIA CASE
try:
Expand Down

0 comments on commit afae544

Please sign in to comment.