Skip to content

Instantly share code, notes, and snippets.

@malfet
Created June 5, 2024 21:04
Show Gist options
  • Save malfet/256da1ae0f35c837953e779de1213e82 to your computer and use it in GitHub Desktop.
Save malfet/256da1ae0f35c837953e779de1213e82 to your computer and use it in GitHub Desktop.
Print shared libraries loaded by PyTorch on MacOS
from ctypes import cdll, c_char_p, c_uint32
libdyld = cdll.LoadLibrary("libSystem.dylib")
libdyld._dyld_image_count.restype = c_uint32
libdyld._dyld_get_image_name.restype = c_char_p
libdyld._dyld_get_image_name.argtypes = [c_uint32]
before_torch = {libdyld._dyld_get_image_name(i).decode("ascii") for i in range(libdyld._dyld_image_count())}
import torch
after_torch = {libdyld._dyld_get_image_name(i).decode("ascii") for i in range(libdyld._dyld_image_count())}
for lib in after_torch.difference(before_torch):
print(lib)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment