ヴィチャとかいうゲーム

ヴィチャ内で真剣にPvEしたり、PvPしたり、高難易度ゲームに挑戦したりする人がいる。

PvEするには無限弾薬などギミックがチープすぎる。 みんなでプレイするから難易度低めに設定するし、頭使わなくても力技で攻略できるからつまんない。

PvPするには個人の環境差(回線強度、視野角、部屋の広さ)が酷くて環境強者が環境弱者をボコって気持ちよくなるだけ。 FPSとか酔いが酷すぎ。 VCがないと意思疎通取れないから戦術もクソもないし。

高難易度への挑戦は、あなたの貴重な人生の時間をそのスキルアップに注ぎ込む価値はありますか?と問いただしたくなる。 PvEと言ってる事が矛盾したな。

義務感で遊んだらそれは遊びじゃないんだ。 いつでも自分の意思でやめられるから趣味なんだ。

私はおしゃべりがしたい。 以上。





無意味だから苦行とか知名度とか動画投稿を「すごい!」って褒めてる。 皮肉にも、その賞賛が承認要求を満たして気持ち良くさせちゃってるけど。 その勘違いを指摘したら怒らせちゃうかな。 ここなら言ってもバレへんか。 全く何も凄くないです。 お笑い種です。

上見たっていくらでも上がいるから無意味なのはその通りだけど、だからってハミ出し者同士でどっちが下かの勝負してどうすんだよ。 下の世界でこんな発言すると逆に馬鹿にされるから言わないけど、下の世界で成り上がろうとするのは冷静になった方が良いよ。 普通にYouTuberとかInstagramerとかTikTokerとしてインフルエンサーを目指したほうが何倍もリターンがある。

俺が存在を認めてやるからこれ以上進み続けるのやめてくんねーかな、ほんとに。

Be careful when you use pipx in GitHub Actions!

I ran tests with wrong Python version when I used pipx to install Hatch for a testing environment in GitHub Actions.

GitHub Actions でテスト環境作成用の Hatch を pipx でインストールしてたら、誤ったバージョンの Python でテストをしていたので、その失敗について記す。

GitHub Actions workflow file with the problem

---
name: Test

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version:
          - "3.10"
          - "3.11"
          - "3.12"
      fail-fast: false
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install hatch
        run: pipx install hatch
      - name: Lint
        run: hatch run lint:lint
      - name: Check type
        run: hatch run check-type
      - name: Test
        run: hatch run test --cov-report=xml
      - name: Upload coverage
        uses: codecov/codecov-action@v3

The problem is the following part.

- name: Install hatch
  run: pipx install hatch

By default, pipx uses the default Python in the runner, which is ubuntu-latest in this case. It doesn't use Python setup by actions/setup-python@v4.

Therefore, your virtual environment created with Hatch has the same Python version as the runner's.

The matrix strategy of python-version is totally useless, and your CI testing is no longer functional.

デフォルトで pipx はランナー(この場合ではubuntu-latest)の Python を使用する。 これはactions/setup-python@v4でセットアップした Python とは異なる。 そのため、Hatch で作成した仮想環境はランナーの Python と同じバージョンになる。 これは、ストラテジーで設定したpython-versionは全くの無意味であり、CI テストはもはや機能していないことを意味する。

To fix this, add PIPX_DEFAULT_PYTHON environment variable to the step as the following shows.

これを修正するには下記が示すように環境変数PIPX_DEFAULT_PYTHONをそのステップに加える。

- name: Install hatch
  run: pipx install hatch
  env:
    PIPX_DEFAULT_PYTHON: python

Refrection

I hadn't noticed the problem for 6 months because I didn't fully check the result of CI. As a result, all the tests during the period had come to nothing.

Fortunately, nothing wrong has happened with my project. I feel scared when I think an huge modification could be demanded.

6 ヵ月間もその問題に気づけなかったのは CI の結果を十分にチェックしていなかったからだ。 その結果、その間の全てのテストは無に帰してしまった。 幸運にもプロジェクトには何も悪いことは起こっていない。 莫大な修正が発生しえたことを考えると恐ろしくなる。

みんなも CI の結果には注意を配ろう!

Snapパッケージの問題

Snappyを使って落としてきたソフトで発生した種々の問題についてまとめる。

Snapとは

Ubuntuディストリビューションを開発・管理しているCanonical社が開発している パッケージマネージャである。

snapcraft.io

snapというコマンドを通してLinuxシステムを一元管理できるのが売りである。

しかしながら、問題が発生した際に調査してみると、それが「Snap版のパッケージだから」ということが多い。

Snap版パッケージは系を楽に管理できる点で優秀だが、こういった微妙な使いづらさが目立つ。

VSCode

お馴染みのMicrosoft社製コードエディタである。

$ sudo snap install code

日本語入力ができない

Google日本語入力オープンソースMozcIBus環境で使用しているが、VSCodeで何故か日本語に切り替えることができない。

ソースコードを書くときには問題ないが、日本語のドキュメントを書くこともあるので困る。

解決法は公式セットアップに従い、aptリポジトリを追加してしまうことである。

code.visualstudio.com

もしかしたらIBusのほうに問題があって、Fcitxを使えば問題ないかもしれない。

Docker

お馴染みのコンテナ仮想化アプリケーションである。

$ sudo snap install docker

Buildxが存在しない

デフォルトで含まれていないので、別途バイナリを落としてきて/usr/local/lib/docker/cli-pluginsに配置する必要がある(ぱっと見た感じではSnap版のbuildxパッケージは存在しない)。 バージョン管理がひたすら面倒くさい。

DEBパッケージならデフォルトで搭載されている。

docs.docker.com

解決策は公式のインストールスクリプトを使ってインストールすることである。

$ curl -fsSL https://get.docker.com | bash

DNS problem of Job on Kubernetes

KubernetesでWeb APIを叩くジョブを作ろうとしたらDNS名前解決で3日詰まったのでメモ。

問題の概要

以下のマニフェストのようなJobをKubernetesで動かしたところ、curl: (6) Could not resolve Host: github.com; Name or service not knownのエラーが出てジョブを完了できなかった。

apiVersion: batch/v1
kind: Job
metadata:
  name: curl-test
spec:
  parallelism: 1
  completions: 1
  backoffLimit: 3
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
        - name: curl
          image: curlimages/curl:7.85.0
          command:
            - curl
            - -I
            - https://github.com
      restartPolicy: Never

実行環境

漁った資料

Kubernetes + curl + DNS をキーワードにGoogleして以下の資料を得たが、解決には至らなかった。

トラブルシューティング

/etc/resolv.confの確認

$ kubectl run curl --image=curlimages/curl:7.85.0 -- cat /etc/resolv.conf
pod/curl created
$ kubeclt logs curl
search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.152.183.10
options ndots:5

optionsndotsの値が原因でalpineベースのイメージには意図しない動作があったらしいが、結論から言えばcurlimages/curl:7.85.0では解決済みのようである。

curlimages/curlのダウングレード

Issueで述べられていた7.77.0まで落としてみたが直らず。

別の人がビルドしたcurlイメージも試してみたが手ごたえなし。

デプロイしたPod内からcurl

以下のマニフェストを適用して、kubectl execcurlを叩いた。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: curl-test
spec:
  selector:
    matchLabels:
      app: curl-test
  template:
    metadata:
      labels:
        app: curl-test
    spec:
      containers:
        - name: curl-test
          image: curlimages/curl:7.85.0
          resources:
            limits:
              memory: "128Mi"
              cpu: "500m"
          command:
            - sleep
            - "3600"
$ kubectl exec -it curl-test-<id> -- curl -I https://github.com
HTTP/2 200
server: GitHub.com
date: Tue, 04 Oct 2022 15:14:23 GMT
content-type: text/html; charset=utf-8
...

なぜか通り困惑。 Job特有のバクかと当たりをつけGoogleするが、それらしき情報は見当たらず。 未報告のバグだとしても、どのレイヤー(MicroK8s? Kubernetes? CoreDNS? cURL?)で起こっているバグか特定できない限りコントリビュートできないので半ば諦め状態。

解決編

同様にしばらくスリープするcurlコンテナのJobを作って、kubectl execcurlを叩いたら通ったり通らなかったりしたので以下のJobを作成。

apiVersion: batch/v1
kind: Job
metadata:
  name: curl-test
spec:
  parallelism: 1
  completions: 1
  backoffLimit: 3
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
        - name: curl
          image: curlimages/curl:7.85.0
          command:
            - sh
            - -c
            - |
              while (true); do
                curl -I https://github.com
                if [ ! $? -eq 6 ]; then  # Exit code 6 is the DNS error
                  break
                fi
                sleep 1
              done 
      restartPolicy: Never

無事JobがComplete状態になってトラブルシューティング終了。

どうやらいろいろデプロイしたせいか、システムに負荷がかかっていてDNS周りのリソース割り当てに1分以上かかっていたらしい。

反省

未知のバグじゃなくて良かったけど、Googleするときはできるだけ新しい情報を漁らないと既に解決済みの問題の解決法まで試すことになって良くないと思った。

今回の問題の本質は、新技術に触ったときにありがちな「実は単純な問題をGoogleした結果、複雑な問題まで深追いしてしまう」ってやつ。 触りたての時期は知識も技量も浅いから手あたり次第解決策を試すしかないんだけど、頭を冷やして系の挙動をじっくり観察するというのも大切ね。

Markdown Cheet Sheet

はじめに

Markdown 記法とは?

文書を簡潔かつスタイリッシュに記述できる記法。

元々は HTML を楽に記述するために考案されたため、ほとんどのウェブサービス(GitHub, Slack, ブログサービス)では Markdown で書かれた文書をそれぞれの CSS を使ってスタイリッシュな HTML に変換して表示してくれる。

Markdown の良い所

  1. 構造化された文書を素早く書ける
  2. 特別なソフトは必要ない
  3. 普遍的な技術であるため、どんな場でも使える
  4. 内容とスタイルが分離されている
  5. HTML を埋め込める

Word のようなソフトを使って見た目と内容を同時に意識しながら編集する必要はない。 1つのソースから複数の見た目の文書を生成できる。

この文書もまた Markdown で書かれている。

チートシート

改行・パラグラフ

改行は
半角スペース二つです。  
ここは次の文章です。

次のパラグラフです。

改行は 半角スペース二つです。
ここは次の文章です。

次のパラグラフです。

ヘッディング

# ヘッダー 1

## ヘッダー 2

### ヘッダー 3

#### ヘッダー 4

##### ヘッダー 5

ヘッダー 1

ヘッダー 2

ヘッダー 3

ヘッダー 4

ヘッダー 5

斜体・太字

_斜体_

斜体

**太字**

太字

**_斜体太字_**

斜体太字

箇条書き

- いちご
- りんご
- メロン

* アジ
* サバ
* マグロ
  • いちご
  • りんご
  • メロン

  • アジ

  • サバ
  • マグロ
1. コーヒー
2. 牛乳
3. お茶
  1. コーヒー
  2. 牛乳
  3. お茶

リンク

詳しくは[こちら](https://daringfireball.net/projects/markdown/syntax)を参照してください。

URL のみ: <https://daringfireball.net/projects/markdown/syntax>

ID を使って参照: [Google][google]

[google]: https://google.com

詳しくはこちらを参照してください。

URL のみ: https://daringfireball.net/projects/markdown/syntax

ID を使って参照: Google

画像

![ひまわり畑の写真](https://free-materials.com/adm/wp-content/uploads/2016/07/51a7ce858aa46d0165c6dfdfa4684f72-750x499.jpg)

ひまわり畑の写真

大きさを調整したい時などは<img>タグを使う。

<img src="https://free-materials.com/adm/wp-content/uploads/2016/07/51a7ce858aa46d0165c6dfdfa4684f72-750x499.jpg" alt="ひまわり畑の写真" width="50%" ></img>

ひまわり畑の写真

| 番号 | 数学 | 国語 | 英語 |
| ---- | ---- | ---- | ---- |
| 1    | 67   | 49   | 24   |
| 2    | 43   | 68   | 92   |
| 3    | 89   | 45   | 62   |
番号 数学 国語 英語
1 67 49 24
2 43 68 92
3 89 45 62

区切り線

---

ブロック引用

> この部分は引用です。
>
> - Markdown もそのまま適用されます。
>   > ネストすることもできます。

この部分は引用です。

  • Markdown もそのまま適用されます。

    ネストすることもできます。

コード・コードブロック

テキストを標準出力に表示するには`echo <text>`を実行してください。

テキストを標準出力に表示するにはecho <text>を実行してください。

````markdown

write your code here

````

write your code here

シンタックスハイライトも使用可能。

````markdown

import math

def cosh(x):
    return (math.exp(x) + math.exp(-x)) / 2

````

import math

def cosh(x):
    return (math.exp(x) + math.exp(-x)) / 2

LaTeX

レンダラーがあれば LaTeXレンダリングできる。 よく使われるレンダラーはMathJaxKaTeXである。

文章に埋め込む場合は$a = 1$のように`$`で囲みます。

$$
\begin{align}
y &= A_1 \exp{(-\frac{t}{\tau_1})} + A_2 \exp{(-\frac{t}{\tau_2})} \\
\frac{dy}{dt} &= - \frac{A_1}{\tau_1} \exp{(-\frac{t}{\tau_1})} - \frac{A_2}{\tau_2} \exp{(-\frac{t}{\tau_2})}
\end{align}
$$

文章に埋め込む場合は$a = 1$のように$で囲みます。

$$ \begin{align} y &= A_1 \exp{(-\frac{t}{\tau_1})} + A_2 \exp{(-\frac{t}{\tau_2})} \\ \frac{dy}{dt} &= - \frac{A_1}{\tau_1} \exp{(-\frac{t}{\tau_1})} - \frac{A_2}{\tau_2} \exp{(-\frac{t}{\tau_2})} \end{align} $$

VSCode 拡張機能

Markdown All in One

yzhang.markdown-all-in-one

全部入りの拡張機能(keyboard shortcut, ToC, preview and more)

Markdown PDF

yzane.markdown-pdf

Markdown を PDF に変換

Markdown Emoji

bierner.markdown-emoji

preview で絵文字構文をサポート

参考

daringfireball.net (accessed on 2022/09/02)

www.markdownguide.org (accessed on 2022/09/02)

HTTP proxy on Debian

Linux Debianディストリビューション(主な対象は Ubuntu)における主要なコマンドの HTTP プロキシ設定についてのメモ。

apt

設定ファイル: /etc/environment

http_proxy=<scheme>://<host>:<port>
https_proxy=<scheme>://<host>:<port>

設定ファイル: /etc/apt/conf.d/proxy.conf

Aquire::http::Proxy "<scheme>://<host>:<port>";
Aquire::https::Proxy "<scheme>://<host>:<port>";

manpages.debian.org (accessed on 2022/09/02) manpages.debian.org (accessed on 2022/09/02)

git

設定ファイル: /etc/environment

http_proxy=<scheme>://<host>:<port>
https_proxy=<scheme>://<host>:<port>

コマンドから変更する場合,

$ git config --global http.proxy <scheme>://<host>:<port>

git-scm.com (accessed on 2022/09/02)

https://gist.github.com/evantoli/f8c23a37eb3558ab8765 (accessed on 2022/09/02)

docker

ホスト用 (イメージをプルする場合など)

設定ファイル: /etc/environment

HTTP_PROXY=<scheme>://<host>:<port>
HTTPS_PROXY=<scheme>://<host>:<port>

Then, restart dockerd.

コンテナ用 (イメージをビルドする場合など)

設定ファイル: ~/.docker/config.json

{
 "proxies":
 {
   "default":
   {
     "httpProxy": "<scheme>://<host>:<port>",
     "httpsProxy": "<scheme>://<host>:<port>"
     "noProxy": "127.0.0.1"
   }
 }
}

docs.docker.com (accessed on 2022/09/02) docs.docker.com (accessed on 2022/09/02)

kubernetes(microk8s)

設定ファイル: /etc/environment

http_proxy=<scheme>://<host>:<port>
https_proxy=<scheme>://<host>:<port>
no_proxy=127.0.0.1,192.168.0.0/24,10.0.0.0/8
HTTP_PROXY=<scheme>://<host>:<port>
HTTPS_PROXY=<scheme>://<host>:<port>
NO_PROXY=127.0.0.1,192.168.0.0/24,10.0.0.0/8

microk8s.io (accessed on 2022/09/02)

curl

設定ファイル: /etc/environment

http_proxy=<scheme>://<host>:<port>
https_proxy=<scheme>://<host>:<port>

everything.curl.dev (accessed on 2022/09/02)

wget

設定ファイル: /etc/environment

http_proxy=<scheme>://<host>:<port>
https_proxy=<scheme>://<host>:<port>

www.gnu.org (accessed on 2022/09/02)

TensorFlow + AMD GPU + Docker + WSL2

I got stucked for the first time in a long time when I tried to set up my ML environment. I hope this will help someone.

ML環境を整えようとしたら久しぶりに詰まったのでメモ。

Executed Commands

TensorFlow with DirectML

$ pip install tensorflow-cpu>=2.9 tensorflow-directml-plugin

docs.microsoft.com (accessed on 2022/07/31) github.com (accessed on 2022/07/31)

Docker

$ docker run -it --device /dev/dxg --mount type=bind,src=/usr/lib/wsl,dst/usr/lib/wsl -e LD_LIBRARY_PATH=/usr/lib/wsl/lib
python:3.10 /bin/bash

How to solve it

I'm going to talk about my trouble shooting and how to find the solution.

The Problem and What I want

The problem I faced with is that "TensorFlow doesn't use GPU for calculation".

So I googled how to build a ML environment, and found some helpful information but not compatible with my environment.

I don't feel bad when Google doesn't give me any answers because it is a good chance to test my ability of problem-solving. But I had a hard time of half a day as the problem was more difficult than I expected.

The followings are ML environment examples I found on Google.

  • TensorFlow + CUDA
  • TensorFlow + CUDA + Docker
  • TensorFlow + ROCm + (Ubuntu)
  • TensorFlow + DirectML

TensorFlow with DirectML

TensorFlow DirectML is a Python library that allows your DirectX 12-compatible hardwares to be used for operations in TensorFlow. Though it supports TensorFlow<=1.15 for production, TensorFlow DirectML Plugin, which is still in early development, can be used with TensorFlow 2.

github.com (accessed on 2022/07/31)

github.com (accessed on 2022/07/31)

Architecture

My assumptive case is to use GPU acceleration of TensorFlow on Docker of WSL2 backend.

Layer Application
Library TensorFlow
Container Virtualization Docker
Linux Environment WSL2
OS Windows10/11
Hardware AMD GPU

DirectX on WSL

First, you need to make DirectX available on WSL. Maybe you have nothing to do if you use the latest driver.

devblogs.microsoft.com (accessed on 2022/07/31)

www.amd.com (accessed on 2022/07/31)

/dev/dxg is the interface to DirectX. Make sure it exists on your WSL of any distribution.

$ ls -l /dev | grep dxg
crw-rw-rw- 1 root root  10,  63 Jul 31 02:55 dxg

TensorFlow on WSL

Next, you are going to check TensorFlow recognizes your GPU.

Create a Python virtual environment as you like on WSL and install libraries.

$ pip install tensorflow-cpu>=2.9 tensorflow-directml-plugin

For your information, you will get the following error if you install tensorflow instead of tensorflow-cpu.

stackoverflow.com (accessed on 2022/07/31)

Now your GPU is recognized by TensorFlow.

>>> from tensorflow.python.client import device_lib
 I tensorflow/c/logging.cc:34] Successfully opened dynamic library libdirectml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.so
 I tensorflow/c/logging.cc:34] Successfully opened dynamic library libdxcore.so
 I tensorflow/c/logging.cc:34] Successfully opened dynamic library libd3d12.so
 I tensorflow/c/logging.cc:34] DirectML device enumeration: found 1 compatible adapters.
>>> device_lib.list_local_devices()
 I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
 I tensorflow/c/logging.cc:34] DirectML: creating device on adapter 0 (AMD Radeon(TM) Graphics)
 I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
 W tensorflow/core/common_runtime/pluggable_device/pluggable_device_bfc_allocator.cc:28] Overriding allow_growth setting because force_memory_growth was requested by the device.
 I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/device:GPU:0 with 10995 MB memory) -> physical PluggableDevice (device: 0, name: DML, pci bus id: <undefined>)
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 16873716271696621736
xla_global_id: -1
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 11529922944
locality {
  bus_id: 1
}
incarnation: 7266701298382521906
physical_device_desc: "device: 0, name: DML, pci bus id: <undefined>"
xla_global_id: -1
]

Make sure the GPU is really used during calculation.

>>> import tensorflow as tf
>>> tf.debugging.set_log_device_placement(True)
>>> tf.add([1.0, 2.0], [3.0, 4.0])
 I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
 I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10995 MB memory) -> physical PluggableDevice (device: 0, name: DML, pci bus id: <undefined>)
 I tensorflow/core/common_runtime/eager/execute.cc:1323] Executing op _EagerConst in device /job:localhost/replica:0/task:0/device:GPU:0
 I tensorflow/core/common_runtime/eager/execute.cc:1323] Executing op _EagerConst in device /job:localhost/replica:0/task:0/device:GPU:0
 I tensorflow/core/common_runtime/eager/execute.cc:1323] Executing op AddV2 in device /job:localhost/replica:0/task:0/device:GPU:0
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([4., 6.], dtype=float32)>

TensorFlow with DirectML on Docker

Create an image.

FROM python:3.10
RUN pip install -U pip \
 && pip install tensorflow-cpu>=2.9 tensorflow-directml-plugin
$ docker build -t tensorflow .

Tentatively, I created a container with /dev/dxg mounted.

$ docker run -it --rm --device /dev/dxg tensorflow
>>> import tensorflow as tf
 W tensorflow/c/logging.cc:37] Could not load dynamic library 'libdirectml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.so'; dlerror: libd3d12.so: cannot open shared object file: No such file or directory
 W tensorflow/c/logging.cc:37] Could not load DirectML.
2022-07-30 18:39:38.308633: I tensorflow/c/logging.cc:34] DirectML device enumeration: found 0 compatible adapters.

TensorFlow tells me a shared library libd3d12.so could not be loaded. Then seach WSL for it.

$ which libd3d12.so
/usr/lib/wsl/lib/libd3d12.so

Start a container with /usr/lib/wsl mounted and with LD_LIBRARY_PATH set to /usr/lib/wsl/lib in order to be loaded by Python.

$ docker run -it --rm --device /dev/dxg --mount type=bind,src=/usr/lib/wsl,dst=/usr/lib/wsl -e LD_LIBRARY_PATH=/usr/lib/wsl/lib tensorflow
>>> import tensorflow as tf
 I tensorflow/c/logging.cc:34] Successfully opened dynamic library libdirectml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.so
 I tensorflow/c/logging.cc:34] Successfully opened dynamic library libdxcore.so
 I tensorflow/c/logging.cc:34] Successfully opened dynamic library libd3d12.so
 I tensorflow/c/logging.cc:34] DirectML device enumeration: found 1 compatible adapters.

Now you are finished building your ML environment.

Known Issues

OOM when training over hours

W tensorflow/core/common_runtime/pluggable_device/pluggable_device_bfc_allocator.cc:28] Overriding allow_growth setting because force_memory_growth was requested by the device.

As warning in log, the device demands as much memory as possible, which means your program will be down because of OOM if running for hours.

Reflections

今回嵌った原因は、いきなり TensorFlow から GPU を認識する方法を探したからであろう。 一度アーキテクチャを整理して、WSL+TensorFlow で調査を進めたら上手くいった。 複雑な問題は部分問題に分割して解くという、基本的な問題解決手法を思い出させてくれた。

CUDA であれば、TensorFlow + CUDA と Docker + CUDA が公式にサポートされているので環境構築はより楽だろうが、特定の企業のデバイスに依存しているのが気に入らない。 DirectML も DirectX という時点で Windows(Microsoft)依存ではあるが、デバイスのほうは Nvidia でも Intel でも AMD でも良い。

ハードウェア依存性を吸収するのがソフトウェアの役目なのだから、CUDA(Nvidia)には規格整備などを頑張ってもらいたいものである。