How do I make my AMD GPU available within a docker image based on python:3.9.10



  • I'd like to do some machine learning on my AMD 6800 XT gpu within a python image based on python:3.9.10. I can confirm that https://superuser.com/questions/1737193/amd-radeon-rx-6800-xt-not-visible-within-debian-wsl2/1737384 (in a wsl2 instance). However, if I do docker run -it python:3.9.10 /bin/bash and then complete the same tutorial ( https://docs.microsoft.com/en-us/windows/ai/directml/gpu-tensorflow-wsl#install-the-tensorflow-with-directml-package ) it doesn't work:

    (directml) root@8a8274e5337f:/# python
    Python 3.6.13 |Anaconda, Inc.| (default, Jun  4 2021, 14:25:59)
    [GCC 7.5.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 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]))
    2022-08-18 12:29:39.540717: W tensorflow/stream_executor/platform/default/dso_loader.cc:108] Could not load dynamic library 'libdirectml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.so'; dlerror: libd3d12.so: cannot open shared object file: No such file or directory
    2022-08-18 12:29:39.540760: W tensorflow/core/common_runtime/dml/dml_device_cache.cc:137] Could not load DirectML.
    2022-08-18 12:29:39.540793: I tensorflow/core/common_runtime/dml/dml_device_cache.cc:250] DirectML device enumeration: found 0 compatible adapters.
    2022-08-18 12:29:39.541010: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
    2022-08-18 12:29:39.545145: I tensorflow/core/common_runtime/eager/execute.cc:571] Executing op Add in device /job:localhost/replica:0/task:0/device:CPU:0
    tf.Tensor([4. 6.], shape=(2,), dtype=float32)
    

    This article has led me to think that perhaps docker doesn't support AMD GPUs at all: https://docs.docker.com/desktop/windows/wsl/

    Can anyone suggest what I might be able to do to get this to work?

    Note that the reason I have picked this image is that my environment is based on a rather lengthy Dockerfile inheriting from python:3.9.10, and I'd like to keep using that image on the PC with the GPU as well as other (nvidia) environments, so I'm after a portable solution as far as the image is concerned, although I'd be grateful for any solution at this point.



  • Tensorflow doesn't have access to libd3d12.so file:

    2022-08-18 12:29:39.540717: >tensorflow/stream_executor/platform/default/dso_loader.cc:108] Could not load dynamic library 'libdirectml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.so'; dlerror: libd3d12.so: cannot open shared object file: No such file or directory

    Here is an article solving this issue: https://nnt339es.hatenablog.com/entry/2022/07/31/045059

    Shortly said, use this line instead:

    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 python:3.9.10
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2