Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ktransformers
Commits
1d9d3975
Commit
1d9d3975
authored
Aug 08, 2024
by
chenxl
Committed by
Atream
Aug 08, 2024
Browse files
fix some bug in compile in linux
parent
0a2fd52c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
11 deletions
+30
-11
ktransformers/ktransformers_ext/CMakeLists.txt
ktransformers/ktransformers_ext/CMakeLists.txt
+11
-2
ktransformers/ktransformers_ext/cpu_backend/task_queue.h
ktransformers/ktransformers_ext/cpu_backend/task_queue.h
+5
-5
pyproject.toml
pyproject.toml
+2
-1
setup.py
setup.py
+12
-3
No files found.
ktransformers/ktransformers_ext/CMakeLists.txt
View file @
1d9d3975
...
...
@@ -205,7 +205,12 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/pybind11 ${CMAKE_
add_subdirectory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../third_party/llama.cpp
${
CMAKE_CURRENT_BINARY_DIR
}
/third_party/llama.cpp
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../third_party
)
include_directories
(
"D:/CUDA/v12.5/include"
)
if
(
WIN32
)
include_directories
(
"$ENV{CUDA_PATH}/include"
)
elseif
(
UNIX
)
find_package
(
CUDA REQUIRED
)
include_directories
(
"
${
CUDA_INCLUDE_DIRS
}
"
)
endif
()
aux_source_directory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
SOURCE_DIR1
)
aux_source_directory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpu_backend SOURCE_DIR2
)
...
...
@@ -216,4 +221,8 @@ message(STATUS "ALL_SOURCES: ${ALL_SOURCES}")
pybind11_add_module
(
${
PROJECT_NAME
}
MODULE
${
ALL_SOURCES
}
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE llama
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
"D:/CUDA/v12.5/lib/x64/cudart.lib"
)
#CUDA::cudart
\ No newline at end of file
if
(
WIN32
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
"$ENV{CUDA_PATH}/lib/x64/cudart.lib"
)
#CUDA::cudart
elseif
(
UNIX
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
"$ENV{CUDA_HOME}/lib64/libcudart.so"
)
endif
()
\ No newline at end of file
ktransformers/ktransformers_ext/cpu_backend/task_queue.h
View file @
1d9d3975
...
...
@@ -3,8 +3,8 @@
* @Author : chenht2022
* @Date : 2024-07-16 10:43:18
* @Version : 1.0.0
* @LastEditors : chen
ht2022
* @LastEditTime : 2024-0
7-25 10:33:47
* @LastEditors : chen
xl
* @LastEditTime : 2024-0
8-08 04:23:51
* @Copyright (c) 2024 by KVCache.AI, All Rights Reserved.
**/
#ifndef CPUINFER_TASKQUEUE_H
...
...
@@ -25,7 +25,7 @@ class custom_mutex {
private:
#ifdef _WIN32
HANDLE
global_mutex
;
#el
if
#el
se
std
::
mutex
global_mutex
;
#endif
...
...
@@ -41,7 +41,7 @@ public:
{
#ifdef _WIN32
WaitForSingleObject
(
global_mutex
,
INFINITE
);
#el
if
#el
se
global_mutex
.
lock
();
#endif
}
...
...
@@ -50,7 +50,7 @@ public:
{
#ifdef _WIN32
ReleaseMutex
(
global_mutex
);
#el
if
#el
se
global_mutex
.
lock
();
#endif
}
...
...
pyproject.toml
View file @
1d9d3975
...
...
@@ -3,7 +3,8 @@ requires = [
"setuptools"
,
"torch >= 2.3.0"
,
"ninja"
,
"packaging"
"packaging"
,
"cpufeature"
]
build-backend
=
"setuptools.build_meta"
...
...
setup.py
View file @
1d9d3975
...
...
@@ -6,7 +6,7 @@ Author : chenxl
Date : 2024-07-27 16:15:27
Version : 1.0.0
LastEditors : chenxl
LastEditTime : 2024-0
7-31
0
9
:4
4:46
LastEditTime : 2024-0
8-08
0
2
:4
5:15
Adapted from:
https://github.com/Dao-AILab/flash-attention/blob/v2.6.3/setup.py
Copyright (c) 2023, Tri Dao.
...
...
@@ -19,6 +19,7 @@ import re
import
ast
import
subprocess
import
platform
import
shutil
import
http.client
import
urllib.request
import
urllib.error
...
...
@@ -27,6 +28,7 @@ from packaging.version import parse
import
torch.version
from
wheel.bdist_wheel
import
bdist_wheel
as
_bdist_wheel
from
setuptools
import
setup
,
Extension
from
cpufeature.extension
import
CPUFeature
from
torch.utils.cpp_extension
import
BuildExtension
,
CUDAExtension
,
CUDA_HOME
class
CpuInstructInfo
:
...
...
@@ -100,7 +102,14 @@ class VersionInfo:
raise
ValueError
(
"Unsupported cpu Instructions: {}"
.
format
(
flags_line
))
elif
sys
.
platform
==
"win32"
:
return
'native'
if
CPUFeature
.
get
(
"AVX512bw"
,
False
):
return
'fancy'
if
CPUFeature
.
get
(
"AVX512f"
,
False
):
return
'avx512'
if
CPUFeature
.
get
(
"AVX2"
,
False
):
return
'avx2'
raise
ValueError
(
"Unsupported cpu Instructions: {}"
.
format
(
str
(
CPUFeature
)))
else
:
raise
ValueError
(
"Unsupported platform: {}"
.
format
(
sys
.
platform
))
...
...
@@ -158,7 +167,7 @@ class BuildWheelsCommand(_bdist_wheel):
wheel_path
=
os
.
path
.
join
(
self
.
dist_dir
,
archive_basename
+
".whl"
)
print
(
"Raw wheel path"
,
wheel_path
)
os
.
renam
e
(
wheel_filename
,
wheel_path
)
shutil
.
mov
e
(
wheel_filename
,
wheel_path
)
except
(
urllib
.
error
.
HTTPError
,
urllib
.
error
.
URLError
,
http
.
client
.
RemoteDisconnected
):
print
(
"Precompiled wheel not found. Building from source..."
)
# If the wheel could not be downloaded, build from source
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment