0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSL2(Fedora40)で生成AIを使おう(podman play kube版)

Last updated at Posted at 2024-08-24

概要

WSL2しかもFedora(RedHat系列)、Podman(Kubernetes)でStable Diffusion WebUIを動かしてる人がなかなか見つからなかったのでそんな人に刺さる:knife:と嬉しいです

なお、Kubernetesを使う理由は当初podman-composeコマンドで作ってたのですが、
我が家の環境だと動かなくなってしまい...泣く泣くKubernetesに移行しました

結果、土曜日が消えましたが動かせました
良かったですね

ではやっていきましょう

検索用ワード

  • podman play kuba 動かない
  • podman generate kube 使えない
  • kube yaml 書き方分からない
  • podman nvidia-smi 動かない

環境

  • Host OS: Windows11 Pro
  • Guest OS: Fedora 40
  • GPU: NVIDIA RTX 4070 Ti Super (16GB)
.wslconfig
[wsl2]
memory=16GB
swap=0
kernelCommandLine = cgroup_no_v1=all
> wsl --version
WSL バージョン: 2.3.17.0
カーネル バージョン: 5.15.153.1-2
WSLg バージョン: 1.0.64
MSRDC バージョン: 1.2.5326
Direct3D バージョン: 1.611.1-81528511
DXCore バージョン: 10.0.26100.1-240331-1435.ge-release
Windows バージョン: 10.0.22635.4010
$ podman info
host:
  arch: amd64
  buildahVersion: 1.37.1
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.10-1.fc40.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: '
  cpuUtilization:
    idlePercent: 99.05
    systemPercent: 0.39
    userPercent: 0.57
  cpus: 16
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "40"
  eventLogger: journald
  freeLocks: 2040
  hostname: SECHS
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 10000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 5.15.153.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 3846848512
  memTotal: 16773378048
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.12.1-1.fc40.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.12.1
    package: netavark-1.12.1-1.fc40.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.12.1
  ociRuntime:
    name: crun
    package: crun-1.15-1.fc40.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.15
      commit: e6eacaf4034e84185fd8780ac9262bbf57082278
      rundir: /run/user/10000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20240821.g1d6142f-1.fc40.x86_64
    version: |
      pasta 0^20240821.g1d6142f-1.fc40.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/10000/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.2-2.fc40.x86_64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.5
  swapFree: 0
  swapTotal: 0
  uptime: 20h 30m 45.00s (Approximately 0.83 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
store:
  configFile: /home/m10i/.config/containers/storage.conf
  containerStore:
    number: 3
    paused: 0
    running: 2
    stopped: 1
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/m10i/.local/share/containers/storage
  graphRootAllocated: 1081101176832
  graphRootUsed: 67782701056
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 53
  runRoot: /run/user/10000/containers
  transientStore: false
  volumePath: /home/m10i/.local/share/containers/storage/volumes
version:
  APIVersion: 5.2.1
  Built: 1723593600
  BuiltTime: Wed Aug 14 09:00:00 2024
  GitCommit: ""
  GoVersion: go1.22.5
  Os: linux
  OsArch: linux/amd64
  Version: 5.2.1

結論

私のgithub.comのリポジトリのREADME.md見てね!

ただ、参照先のリポジトリもアップデートされているので
Python、PyTorch、その他依存ライブラリの変更で動かなくなることがあります!

嵌ったポイント

  1. podman play kube コマンドではコンテナイメージを作成できない
     → あらかじめ podman build コマンドで作成必要
      リポジトリ内の start.sh には必要なコマンドを入れてるので一発で生成
  2. nvidia-container-toolkit をインストールしたタイミングでCDI設定が作られる
     → ドライバ更新した場合は sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml で更新必須
  3. podman run コマンドでは正常にGPUを認識するのに、podman play kube コマンドではGPUを認識しない
    /usr/share/containers/oci/hooks.d/ 配下にJSONファイルの設置が必要
     debugを延々と見てたら分かった
  4. cgroup2にした際は no-cgroups = true 設定が必須
  5. volumeでマウントするときはフルパス指定ではないとダメ
     → dockerだと相対パスで指定できたが、k8sはフルパスしかダメ
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?