mirror of
https://github.com/turboderp-org/exllamav2.git
synced 2026-05-01 11:41:47 +00:00
improve installation experience (#666)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
recursive-include exllamav2 *
|
||||
global-include *.typed
|
||||
global-exclude *.pyc
|
||||
global-exclude dni_*
|
||||
0
exllamav2/py.typed
Normal file
0
exllamav2/py.typed
Normal file
40
setup.py
40
setup.py
@@ -1,15 +1,23 @@
|
||||
from setuptools import setup, Extension
|
||||
from torch.utils import cpp_extension
|
||||
from torch import version as torch_version
|
||||
import importlib.util
|
||||
import os
|
||||
|
||||
if torch := importlib.util.find_spec("torch") is not None:
|
||||
from torch.utils import cpp_extension
|
||||
from torch import version as torch_version
|
||||
|
||||
extension_name = "exllamav2_ext"
|
||||
verbose = False
|
||||
ext_debug = False
|
||||
precompile = "EXLLAMA_NOCOMPILE" not in os.environ
|
||||
verbose = "EXLLAMA_VERBOSE" in os.environ
|
||||
ext_debug = "EXLLAMA_EXT_DEBUG" in os.environ
|
||||
|
||||
precompile = 'EXLLAMA_NOCOMPILE' not in os.environ
|
||||
if precompile and not torch:
|
||||
print(
|
||||
"cannot precompile unless torch is installed \
|
||||
To explicitly JIT install run EXLLAMA_NOCOMPILE= pip install <xyz>"
|
||||
)
|
||||
|
||||
windows = (os.name == "nt")
|
||||
windows = os.name == "nt"
|
||||
|
||||
extra_cflags = ["/Ox"] if windows else ["-O3"]
|
||||
|
||||
@@ -18,7 +26,7 @@ if ext_debug:
|
||||
|
||||
extra_cuda_cflags = ["-lineinfo", "-O3"]
|
||||
|
||||
if torch_version.hip:
|
||||
if torch and torch_version.hip:
|
||||
extra_cuda_cflags += ["-DHIPBLAS_USE_HIP_HALF"]
|
||||
|
||||
extra_compile_args = {
|
||||
@@ -26,7 +34,8 @@ extra_compile_args = {
|
||||
"nvcc": extra_cuda_cflags,
|
||||
}
|
||||
|
||||
setup_kwargs = {
|
||||
setup_kwargs = (
|
||||
{
|
||||
"ext_modules": [
|
||||
cpp_extension.CUDAExtension(
|
||||
extension_name,
|
||||
@@ -81,9 +90,13 @@ setup_kwargs = {
|
||||
],
|
||||
extra_compile_args=extra_compile_args,
|
||||
libraries=["cublas"] if windows else [],
|
||||
)],
|
||||
"cmdclass": {"build_ext": cpp_extension.BuildExtension}
|
||||
} if precompile else {}
|
||||
)
|
||||
],
|
||||
"cmdclass": {"build_ext": cpp_extension.BuildExtension},
|
||||
}
|
||||
if precompile and torch
|
||||
else {}
|
||||
)
|
||||
|
||||
version_py = {}
|
||||
with open("exllamav2/version.py", encoding="utf8") as fp:
|
||||
@@ -120,9 +133,12 @@ setup(
|
||||
"websockets",
|
||||
"regex",
|
||||
"numpy",
|
||||
"rich"
|
||||
"rich",
|
||||
],
|
||||
include_package_data=True,
|
||||
package_data={
|
||||
"": ["py.typed"],
|
||||
},
|
||||
verbose=verbose,
|
||||
**setup_kwargs,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user