mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Back out "[pytorch][PR] Move thnvrtc and DynamicLibrary to ATen" (#22749)
Summary: Original commit changeset: add2ee8a8865 Pull Request resolved: https://github.com/pytorch/pytorch/pull/22749 ghstack-source-id: 86323899 Differential Revision: D16203552 fbshipit-source-id: 227df3b85316315c15d2cb7b6a5c884096a82e9e
This commit is contained in:
committed by
Facebook Github Bot
parent
8bdda03ae1
commit
ac78a86e1d
@ -19,17 +19,17 @@ if not TEST_CUDA:
|
||||
TestCase = object # noqa: F811
|
||||
|
||||
|
||||
_caffe2_nvrtc = None
|
||||
_thnvrtc = None
|
||||
|
||||
|
||||
def get_is_primary_context_created(device):
|
||||
flags = ctypes.cast((ctypes.c_uint * 1)(), ctypes.POINTER(ctypes.c_uint))
|
||||
active = ctypes.cast((ctypes.c_int * 1)(), ctypes.POINTER(ctypes.c_int))
|
||||
global _caffe2_nvrtc
|
||||
if _caffe2_nvrtc is None:
|
||||
path = glob.glob('{}/lib/libcaffe2_nvrtc.*'.format(os.path.dirname(torch.__file__)))[0]
|
||||
_caffe2_nvrtc = ctypes.cdll.LoadLibrary(path)
|
||||
result = _caffe2_nvrtc.cuDevicePrimaryCtxGetState(ctypes.c_int(device), flags, active)
|
||||
global _thnvrtc
|
||||
if _thnvrtc is None:
|
||||
path = glob.glob('{}/lib/libthnvrtc.*'.format(os.path.dirname(torch.__file__)))[0]
|
||||
_thnvrtc = ctypes.cdll.LoadLibrary(path)
|
||||
result = _thnvrtc.cuDevicePrimaryCtxGetState(ctypes.c_int(device), flags, active)
|
||||
assert result == 0, 'cuDevicePrimaryCtxGetState failed'
|
||||
return bool(active[0])
|
||||
|
||||
|
Reference in New Issue
Block a user