Skip to content

Instantly share code, notes, and snippets.

@orimanabu
orimanabu / rosetta_ioctl.md
Last active August 30, 2024 17:39
Rosettaがやっている実行環境のチェック方法を確認する

(最新版はこちらをご覧ください: https://zenn.dev/orimanabu/articles/rosetta-libkrun)

はじめに

Appleは、Linux用のRosettaバイナリを提供しています。 これを使うと、Apple Silicon上のmacOS上で稼働するaarch64 Linux仮想マシン上で、x86_64バイナリを実行できるようになります[^1]。

Rosettaは、実行環境がVirtualization.framework(Apple純正のVMM用フレームワーク)を使った仮想環境かをチェックしており、そうでなければ実行できないらしく、 そのチェックは「rosettaバイナリに謎のioctl(2)を発行して、特定の文字列が返ってくること」を確認しているようです[^2]。

以下、その様子を再現してみたメモです。

@orimanabu
orimanabu / podman-with-libkrun-vulkaninfo.txt
Created August 6, 2024 14:49
vulkaninfo output from Podman with libkrun
% podman run --rm --device /dev/dri quay.io/slopezpa/fedora-vgpu-llama vulkaninfo
'DISPLAY' environment variable not set... skipping surface info
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
ERROR: [../src/panfrost/vulkan/panvk_device.c:381] Code 0 : WARNING: panvk is not a conformant vulkan implementation, pass PAN_I_WANT_A_BROKEN_VULKAN_DRIVER=1 if you know what you're doing. (VK_ERROR_INCOMPATIBLE_DRIVER)
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
@orimanabu
orimanabu / podman-with-libkrun-for-containerized-AI-workload-acceleration.txt
Created August 6, 2024 14:46
Podman with libkrun for containerized AI workload acceleration
% podman run --rm -ti --device /dev/dri -v ~/Downloads:/models:Z quay.io/slopezpa/fedora-vgpu-llama main --temp 0 -m models/Llama-3-ELYZA-JP-8B-q4_k_m.gguf -b 512 -ngl 99 -p "Podmanのlibkrun providerについて教えて下さい"
Log start
main: build = 2238 (56d03d92)
main: built with cc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6) for aarch64-redhat-linux
main: seed = 1722955285
ggml_vulkan: Found 1 Vulkan devices:
Vulkan0: Virtio-GPU Venus (Apple M2) | uma: 1 | fp16: 1 | warp size: 32
llama_model_loader: loaded meta data with 22 key-value pairs and 291 tensors from models/Llama-3-ELYZA-JP-8B-q4_k_m.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv 0: general.architecture str = llama
@orimanabu
orimanabu / Podman 5.2 Test Days Log - Container.md
Created July 31, 2024 15:40
Podman 5.2 Test Days Log - Container
ori@asahi-mbp:~$ uname -a
Linux asahi-mbp 6.9.12-400.asahi.fc41.aarch64+16k #1 SMP PREEMPT_DYNAMIC Sun Jul 28 20:21:34 UTC 2024 aarch64 GNU/Linux
ori@asahi-mbp:~$ cat /etc/fedora-release
Fedora Asahi Remix release 41 (Rawhide)
ori@asahi-mbp:~$ rpm -q podman
podman-5.2.0~rc2-1.fc41.aarch64
@orimanabu
orimanabu / Podman 5.2 Test Days Log - Image Pull.md
Created July 31, 2024 15:37
Podman 5.2 Test Days Log - Image Pull
ori@asahi-mbp:~$ uname -a
Linux asahi-mbp 6.9.12-400.asahi.fc41.aarch64+16k #1 SMP PREEMPT_DYNAMIC Sun Jul 28 20:21:34 UTC 2024 aarch64 GNU/Linux
ori@asahi-mbp:~$ cat /etc/fedora-release
Fedora Asahi Remix release 41 (Rawhide)
ori@asahi-mbp:~$ rpm -q podman
podman-5.2.0~rc2-1.fc41.aarch64
@orimanabu
orimanabu / ansible_enable_winrm_with_openssl_self_certificate.md
Last active March 5, 2024 11:48
Enable WinRM for Ansible using self signed certificate generated by OpenSSL

はじめに

これは、AnsibleでWindowsを管理するために、WinRMにHTTPSで接続できるよう設定するためのドキュメントです。 自己証明書は、PowerShellの New-SelfSignedCertificate ではなくLinux上でopensslコマンドで作成したものを使用します。

設定対象のWindows VMを

  • ホスト名: wintest1
  • IPアドレス: 192.168.122.70
@orimanabu
orimanabu / rosa-util.sh
Last active December 22, 2023 13:56
rosa-util.sh
#!/bin/bash
profile=blank
install_mode=hcp
cluster_name=hcp
#install_mode=classic
#cluster_name=classic
if [ x"$#" != x"1" ]; then
@orimanabu
orimanabu / gist:0afed3b956aec2f2c030dc92273bd09f
Created April 28, 2023 15:30
OpenSSL speed benchmark on MacBook Air M2
[ori@fedora linux-6.3]$ cat /sys/firmware/devicetree/base/model | awk '1'
Apple MacBook Air (13-inch, M2, 2022)
[ori@fedora linux-6.3]$ uname -a
Linux fedora 6.2.11-450.asahi.fc38.aarch64 #1 SMP PREEMPT_DYNAMIC Mon Apr 17 00:28:53 UTC 2023 aarch64 GNU/Linux
[ori@fedora linux-6.3]$ time openssl speed 2>&1 | tee log.openssl
Doing md5 for 3s on 16 size blocks: 16773642 md5's in 3.00s
Doing md5 for 3s on 64 size blocks: 10167926 md5's in 3.00s
Doing md5 for 3s on 256 size blocks: 4570146 md5's in 3.00s
Doing md5 for 3s on 1024 size blocks: 1427362 md5's in 3.00s
Doing md5 for 3s on 8192 size blocks: 192390 md5's in 3.00s
@orimanabu
orimanabu / linux_kernel_modules_build_time.md
Last active June 29, 2024 14:10
Time taken to `make -j ${NCORES} modules` of linux-6.3

Time taken to make -j ${NCORES} modules of linux-6.3

Hardware CPU # of cores (A) OS Time spent on make modules (B) 1 / (B) / (A)
Apple MacBook Air M2 Apple Silicon M2 (4 x efficiency cores @2.4GHz, 4 x performance cores @3.5GHz) 8 Fedora Linux Asahi Remix 38 30m4.815s 6.926e-05
Lenovo ThinkPad P1 Gen 2 Intel Core i7 9850H @2.60GHz 12 Fedora Linux 38 44m28.919s 3.122e-05
Dell PowerEdge R640 Intel Xeon Silver 4108 @1.80GHz 32 Fedora Linux 38 18m44.802s 2.778e-05
Lenovo ThinkPad P16v Gen 1 AMD Ryzen 7 PRO 7840HS @3.8GHz 16 Fedora Linux 39 15m2.816s 6.923e-05
Minisforum MS-01 12th Gen Intel(R) Core(TM) i9-12900H 20 Fedora Linux 40 14m28.963s 5.754e-05
Minisforum UM780 AMD Ryzen 7 7840HS w/ Radeon 780M Graphics 16 Fedora Linux 40 13m8.684s 7.922e-05
@orimanabu
orimanabu / install_podman_on_amazon_linux_2023.sh
Last active July 3, 2024 18:04
Install Podman on Amazon Linux 2023
#!/bin/bash
# To build podman, you have enough resource on the instance.
# I tested this script on t2.xlarge.
topdir=${HOME}/work
mkdir -p ${topdir}
# Install prereq rpms
sudo dnf install -y git golang libseccomp-devel gpgme-devel autoconf automake libtool yajl yajl-devel libcap-devel systemd-devel cni-plugins iptables-nft rpm-build meson golang-github-cpuguy83-md2man.x86_64