WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Tensorflow DirectML - ImportError: libd3d12.so: cannot open shared object file: No such file or directory

Open penavincent opened this issue 6 years ago • 3 comments

Specs

Edition Windows 10 Pro Version 20H2 Installed on ‎9/‎6/‎2020 OS build 19042.572 Experience Windows Feature Experience Pack 120.2212.31.0

CPU: Intel i7-9850H GPU: Nvidia Quadro RTX3000

Summary

I've tried following this documentation in order to test GPU support on WSL2.

I've also followed the Enable NVIDIA CUDA in WSL2 docs in order to install everything needed:

The Nvidia CUDA enabled driver from here

And my current kernel version is Linux version 4.19.128-microsoft-standard.

The issue occurs within my python environment, I'm using pyenv and pipenv to do so:

makedir directml && cd directml pipenv install -python 3.6

Like in the docs, the environment starts with Python version 3.6.

I then activate the environment and install tensorflow-directml:

pipenv shell pipenv install tensorflow-directml

The install is successful, however once I get to this part of the documentation, I get a different result within the interactive python shell when I run this command:

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]))

Expected behavior (According to documentation)


Copy
2020-06-15 11:27:18.235973: I tensorflow/core/common_runtime/dml/dml_device_factory.cc:45] DirectML device enumeration: found 1 compatible adapters. 

2020-06-15 11:27:18.240065: I tensorflow/core/common_runtime/dml/dml_device_factory.cc:32] DirectML: creating device on adapter 0 (AMD Radeon VII) 

2020-06-15 11:27:18.323949: I tensorflow/stream_executor/platform/default/dso_loader.cc:60] Successfully opened dynamic library libdirectml.so.ba106a7c621ea741d21598708ee581c11918380 

2020-06-15 11:27:18.337830: I tensorflow/core/common_runtime/eager/execute.cc:571] Executing op Add in device /job:localhost/replica:0/task:0/device:DML:0 

tf.Tensor([4. 6.], shape=(2,), dtype=float32) 

Actual behavior

This is the response I get to that command:

>>> import tensorflow.compat.v1 as tf
Traceback (most recent call last):
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/joe/.pyenv/versions/3.6.12/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/joe/.pyenv/versions/3.6.12/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libd3d12.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow/__init__.py", line 110, in <module>
    from tensorflow_core import *
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow/__init__.py", line 58, in __getattr__
    module = self._load()
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow/__init__.py", line 52, in _load
    module = _importlib.import_module(self.__name__)
  File "/home/joe/.pyenv/versions/3.6.12/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/__init__.py", line 55, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/joe/.local/share/virtualenvs/directml-vqbEJTwL/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/joe/.pyenv/versions/3.6.12/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/joe/.pyenv/versions/3.6.12/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libd3d12.so: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

I was able to find this issue as well as this one which mentioned the same error, however, without any resolution.

penavincent avatar Oct 15 '20 05:10 penavincent

OS build 19042.572

For this preview, you need Build 20150 or higher. https://docs.microsoft.com/en-us/windows/win32/direct3d12/gpu-cuda-in-wsl

0xbadfca11 avatar Oct 15 '20 07:10 0xbadfca11

OS build 19042.572

As 0xbadfca11 mentioned, you have to participate in Windows insider Program, and recommend to update your system to [OS build 20236] Its the latest one and issue presented on build 20226, 20231 has resolved. Then try things again. Why dont try to use docker for your ML works? You can set up your environment much easier. Also, don`t forget to get a (preview) WDDM 2.9

keenranger avatar Oct 16 '20 07:10 keenranger

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!