Repository navigation
[python] Support find_libraries and preload_libraries on Windows. - #898
Conversation
Note: probably requires adding `amd_comgr` preload to pytorch (can amend that patch)
| LibraryEntry("roctx64", "core", "libroctx64.so.4", "") | ||
| LibraryEntry("rocprofiler-sdk-roctx", "core", "librocprofiler-sdk-roctx.so.1", "") | ||
|
|
||
| LibraryEntry("amd_comgr", "core", "libamd_comgr.so.3", "amd_comgr0605.dll") |
There was a problem hiding this comment.
This adds the
amd_comgrlibrary definition, since MIOpen.dll depends onhiprtc0605.dll(already added) andamd_comgr0605.dll(was missing).
I tested with a Python program modeled after the pytorch init code:
import rocm_sdk
rocm_sdk.find_libraries("amdhip64")
rocm_sdk.preload_libraries(
"amdhip64",
# Enable once aqlprofiler is available.
"rocprofiler-sdk-roctx",
"hiprtc",
"hipblas",
"hipfft",
"hiprand",
"hipsparse",
"hipsolver",
"rccl",
"hipblaslt",
# "amd_comgr", # required for miopen
"miopen",
)Output:
Preloading paths:
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_core\bin\amdhip64_6.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_core\bin\hiprtc0605.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\hipfft.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\hiprand.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\hipsparse.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\hipsolver.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\hipblaslt.dll
D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\MIOpen.dll
Traceback (most recent call last):
File "D:\scratch\check_rocmsdk.py", line 5, in <module>
rocm_sdk.preload_libraries(
File "D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\rocm_sdk\__init__.py", line 106, in preload_libraries
cdll = ctypes.CDLL(str(path), mode=mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\ctypes\__init__.py", line 379, in __init__
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'D:\scratch\therock\python_rocm_2\.venv\Lib\site-packages\_rocm_sdk_libraries_gfx110X_dgpu\bin\MIOpen.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Here's the GUI view of Dependencies for MIOpen.dll:

There was a problem hiding this comment.
Actually I need to double check this. I had been building from incomplete artifacts fetched by https://github.com/ROCm/TheRock/blob/main/build_tools/fetch_artifacts.py instead of a complete artifacts list from a source build (or cloud download command). Really need to fix that script or at least give it a --all-yes-really-everything mode.
There was a problem hiding this comment.
It seems plausible. It is legal for people to depend directly on comgr, although most people get it via hip APIs. So fine to add.
There was a problem hiding this comment.
(ideally, such internal dependencies should happen happen automatically... but windows and I know you aren't there yet)
There was a problem hiding this comment.
Nit: I'd love to extend this at some point to inspect the COFF file and display a nicer error message and give the information that the depends gui does. These errors are deadly in the field to debug...
There was a problem hiding this comment.
Agreed. I'll flush what I can to get the wheels working and building with automation then we can go back and widen the support path (famous last words...).
| LibraryEntry("roctx64", "core", "libroctx64.so.4", "") | ||
| LibraryEntry("rocprofiler-sdk-roctx", "core", "librocprofiler-sdk-roctx.so.1", "") | ||
|
|
||
| LibraryEntry("amd_comgr", "core", "libamd_comgr.so.3", "amd_comgr0605.dll") |
There was a problem hiding this comment.
It seems plausible. It is legal for people to depend directly on comgr, although most people get it via hip APIs. So fine to add.
| LibraryEntry("roctx64", "core", "libroctx64.so.4", "") | ||
| LibraryEntry("rocprofiler-sdk-roctx", "core", "librocprofiler-sdk-roctx.so.1", "") | ||
|
|
||
| LibraryEntry("amd_comgr", "core", "libamd_comgr.so.3", "amd_comgr0605.dll") |
There was a problem hiding this comment.
(ideally, such internal dependencies should happen happen automatically... but windows and I know you aren't there yet)
| LibraryEntry("roctx64", "core", "libroctx64.so.4", "") | ||
| LibraryEntry("rocprofiler-sdk-roctx", "core", "librocprofiler-sdk-roctx.so.1", "") | ||
|
|
||
| LibraryEntry("amd_comgr", "core", "libamd_comgr.so.3", "amd_comgr0605.dll") |
There was a problem hiding this comment.
Nit: I'd love to extend this at some point to inspect the COFF file and display a nicer error message and give the information that the depends gui does. These errors are deadly in the field to debug...
| if not lib_entry.dllname: | ||
|
|
||
| if is_windows and not lib_entry.dllname: |
There was a problem hiding this comment.
Oops, almost merged with a bug. We need to start testing these packages on PRs, not just with nightly jobs.
…dows-python-find-libraries
Progress on #827. Latest
rocm-sdk testoutput: https://gist.github.com/ScottTodd/23955d6a89643a1217e2184af09bd17c.This adds the
amd_comgrlibrary definition, since MIOpen.dll depends onhiprtc0605.dll(already added) andamd_comgr0605.dll(was missing).Next, I'll modify
external-builds/pytorch/build_prod_wheels.pyto work on Windows. That might require adding aamd_comgrpreload to pytorch by amending0015-Preload-rocm-sdk-binaries-if-available.patch.We may want to track a dependency graph between these libraries so preloading one library also loads its dependencies. I can either manually snapshot such a graph by running dlls files through https://github.com/lucasg/Dependencies or we can populate dynamically using our existing build system logic somehow.