torch-memory-saver 0.0.3__tar.gz → 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {torch_memory_saver-0.0.3/torch_memory_saver.egg-info → torch_memory_saver-0.0.5}/PKG-INFO +1 -1
- torch_memory_saver-0.0.5/setup.py +41 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/torch_memory_saver/__init__.py +6 -1
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5/torch_memory_saver.egg-info}/PKG-INFO +1 -1
- torch_memory_saver-0.0.3/setup.py +0 -19
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/LICENSE +0 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/README.md +0 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/csrc/torch_memory_saver.cpp +0 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/setup.cfg +0 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/torch_memory_saver.egg-info/SOURCES.txt +0 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/torch_memory_saver.egg-info/dependency_links.txt +0 -0
- {torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/torch_memory_saver.egg-info/top_level.txt +0 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
import os
|
2
|
+
import glob
|
3
|
+
import shutil
|
4
|
+
import logging
|
5
|
+
import setuptools
|
6
|
+
from pathlib import Path
|
7
|
+
from setuptools import setup
|
8
|
+
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
|
11
|
+
# copy & modify from torch/utils/cpp_extension.py
|
12
|
+
def _find_cuda_home():
|
13
|
+
"""Find the CUDA install path."""
|
14
|
+
# Guess #1
|
15
|
+
cuda_home = os.environ.get('CUDA_HOME') or os.environ.get('CUDA_PATH')
|
16
|
+
if cuda_home is None:
|
17
|
+
# Guess #2
|
18
|
+
nvcc_path = shutil.which("nvcc")
|
19
|
+
if nvcc_path is not None:
|
20
|
+
cuda_home = os.path.dirname(os.path.dirname(nvcc_path))
|
21
|
+
else:
|
22
|
+
# Guess #3
|
23
|
+
cuda_home = '/usr/local/cuda'
|
24
|
+
return cuda_home
|
25
|
+
|
26
|
+
cuda_home = Path(_find_cuda_home())
|
27
|
+
include_dirs = [
|
28
|
+
str(cuda_home.resolve() / 'targets/x86_64-linux/include'),
|
29
|
+
]
|
30
|
+
setup(
|
31
|
+
name='torch_memory_saver',
|
32
|
+
version='0.0.5',
|
33
|
+
ext_modules=[setuptools.Extension(
|
34
|
+
'torch_memory_saver_cpp',
|
35
|
+
['csrc/torch_memory_saver.cpp'],
|
36
|
+
include_dirs=include_dirs,
|
37
|
+
libraries=['cuda']
|
38
|
+
)],
|
39
|
+
python_requires=">=3.9",
|
40
|
+
packages=['torch_memory_saver'],
|
41
|
+
)
|
@@ -13,13 +13,14 @@ logger = logging.getLogger(__name__)
|
|
13
13
|
|
14
14
|
class TorchMemorySaver:
|
15
15
|
def __init__(self):
|
16
|
-
self._mem_pool =
|
16
|
+
self._mem_pool = None
|
17
17
|
self._id = _global_info.next_id()
|
18
18
|
assert self._id == 1, 'Only support one single instance yet (multi-instance will be implemented later)'
|
19
19
|
|
20
20
|
@contextmanager
|
21
21
|
def region(self):
|
22
22
|
if _global_info.binary_info.enabled:
|
23
|
+
self._ensure_mem_pool()
|
23
24
|
with torch.cuda.use_mem_pool(self._mem_pool):
|
24
25
|
_global_info.binary_info.cdll.tms_region_enter()
|
25
26
|
try:
|
@@ -41,6 +42,10 @@ class TorchMemorySaver:
|
|
41
42
|
def enabled(self):
|
42
43
|
return _global_info.binary_info.enabled
|
43
44
|
|
45
|
+
def _ensure_mem_pool(self):
|
46
|
+
if self._mem_pool is None:
|
47
|
+
self._mem_pool = torch.cuda.MemPool()
|
48
|
+
|
44
49
|
|
45
50
|
@dataclass
|
46
51
|
class _BinaryInfo:
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
|
3
|
-
import setuptools
|
4
|
-
from setuptools import setup
|
5
|
-
|
6
|
-
logger = logging.getLogger(__name__)
|
7
|
-
|
8
|
-
setup(
|
9
|
-
name='torch_memory_saver',
|
10
|
-
version='0.0.3',
|
11
|
-
ext_modules=[setuptools.Extension(
|
12
|
-
'torch_memory_saver_cpp',
|
13
|
-
['csrc/torch_memory_saver.cpp'],
|
14
|
-
extra_compile_args=['-I/usr/local/cuda/include'],
|
15
|
-
extra_link_args=['-lcuda'],
|
16
|
-
)],
|
17
|
-
python_requires=">=3.9",
|
18
|
-
packages=['torch_memory_saver'],
|
19
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/torch_memory_saver.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
{torch_memory_saver-0.0.3 → torch_memory_saver-0.0.5}/torch_memory_saver.egg-info/top_level.txt
RENAMED
File without changes
|