WSL 2 で DirectML を使用した TensorFlow の有効化 - Himeyama/himeyama GitHub Wiki

DirectML の仮想環境を作成

conda create --name directml python=3.6 
conda activate directml 

DirectML パッケージの Tensorflow をインストール

pip install tensorflow-directml

動作確認

import tensorflow.compat.v1 as tf 

tf.enable_eager_execution(tf.ConfigProto(log_device_placement=True)) 

print(tf.add([1.0, 2.0], [3.0, 4.0]))