File tree Expand file tree Collapse file tree 7 files changed +32
-38
lines changed Expand file tree Collapse file tree 7 files changed +32
-38
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ jobs:
102
102
- name : Run pip install with conda for 3.8+
103
103
run : |
104
104
set -eux
105
- if [[ ${{ matrix.python-minor-version }} -gt 7 ]]; then \
106
- pip install -e .
105
+ if [[ ${{ matrix.python-minor-version }} -gt 7 ]]; then
106
+ source /opt/conda/bin/activate
107
+ pip install -e .
107
108
fi
Original file line number Diff line number Diff line change @@ -143,12 +143,13 @@ pip install -e . --install-option="--cmakeoff"
143
143
144
144
cd multipy/runtime
145
145
146
- # build runtime
147
- mkdir build
148
- cd build
149
- # use cmake -DABI_EQUALS_1=ON .. instead if you want ABI=1
150
- cmake ..
151
- cmake --build . --config Release
146
+ # configure runtime to build/
147
+ cmake -S . -B build
148
+ # if you need to override the ABI setting you can pass
149
+ cmake -S . -B build -D_GLIBCXX_USE_CXX11_ABI=< 0/1>
150
+
151
+ # compile the files in build/
152
+ cmake --build build --config Release -j
152
153
```
153
154
154
155
### Running unit tests for ` multipy::runtime `
@@ -271,9 +272,6 @@ set(MULTIPY_PATH ".." CACHE PATH "The repo where multipy is built or the PYTHONP
271
272
# include the multipy utils to help link against
272
273
include(${MULTIPY_PATH}/multipy/runtime/utils.cmake)
273
274
274
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
275
- set(TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0")
276
-
277
275
# add headers from multipy
278
276
include_directories(${MULTIPY_PATH})
279
277
Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ set(MULTIPY_PATH ".." CACHE PATH "The repo where multipy is built or the PYTHONP
6
6
# include the multipy utils to help link against
7
7
include (${MULTIPY_PATH} /multipy/runtime/utils.cmake )
8
8
9
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0" )
10
- set (TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0" )
11
-
12
9
# add headers from multipy
13
10
include_directories (${MULTIPY_PATH} )
14
11
Original file line number Diff line number Diff line change @@ -9,38 +9,26 @@ project(MultipyRuntime)
9
9
10
10
# set ABI by default to 0
11
11
12
- option (ABI_EQUALS_1 "Set ABI value to 1, by default it is set to 0. Pytorch by default builds with ABI set to 1." OFF )
13
12
option (BUILD_CUDA_TESTS "Set to ON in order to build cuda tests. By default we do not" OFF )
14
13
option (GDB_ON "Sets to debug mode (for gdb), defaults to OFF" OFF )
15
14
16
15
OPTION (LEGACY_PYTHON_PRE_3_8 "Whether to use Python 3.7 codepaths." OFF )
17
16
18
- if (ABI_EQUALS_1 )
19
- set (ABI_VALUE 1 )
20
- else ()
21
- set (ABI_VALUE 0 )
22
- endif ()
23
-
24
17
if (GDB_ON )
25
18
set (CMAKE_BUILD_TYPE Debug )
26
19
endif ()
27
20
28
21
message (STATUS "CMAKE_BUILD_TYPE - ${CMAKE_BUILD_TYPE} " )
29
22
30
- add_definitions (-D_GLIBCXX_USE_CXX11_ABI=${ABI_VALUE} )
31
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${ABI_VALUE} -fabi-version=11 -fno-lto" )
32
-
33
- SET (INTERPRETER_DIR "${DEPLOY_DIR} /interpreter" )
34
- SET (INTERPRETER_DIR "${DEPLOY_DIR} /interpreter" PARENT_SCOPE )
35
-
36
23
set (DEPLOY_DIR "${CMAKE_CURRENT_SOURCE_DIR} " )
37
24
get_filename_component (MULTIPY_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY )
38
25
26
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fabi-version=11 -fno-lto" )
27
+ include (${DEPLOY_DIR} /utils.cmake )
28
+
39
29
add_subdirectory (interpreter )
40
30
add_subdirectory (third-party/fmt )
41
31
42
- include (${DEPLOY_DIR} /utils.cmake )
43
-
44
32
45
33
# we do not want to have torch_deployinterpreter linked against libstdc++ or libc because
46
34
# when loading it with RTLD_DEEPBIND it will resolve std::cout/stdout to the copy in libc++/libc instead of the
Original file line number Diff line number Diff line change @@ -9,8 +9,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
9
9
SET (INTERPRETER_DIR "${DEPLOY_DIR} /interpreter" )
10
10
SET (INTERPRETER_DIR "${DEPLOY_DIR} /interpreter" PARENT_SCOPE )
11
11
12
- include (${DEPLOY_DIR} /utils.cmake )
13
-
14
12
SET (MULTIPY_UTILS "${CMAKE_CURRENT_SOURCE_DIR} /../../utils" )
15
13
16
14
OPTION (LEGACY_PYTHON_PRE_3_8 "Whether to use Python 3.7 codepaths." OFF )
Original file line number Diff line number Diff line change 7
7
# prefer the active Python version instead of the latest -- only works on cmake
8
8
# 3.15+
9
9
# https://cmake.org/cmake/help/latest/module/FindPython3.html#hints
10
+ if (NOT DEFINED _GLIBCXX_USE_CXX11_ABI )
11
+ # infer the ABI setting from the installed version of PyTorch
12
+ execute_process (
13
+ COMMAND python -c "import torch; print(1 if torch._C._GLIBCXX_USE_CXX11_ABI else 0)"
14
+ OUTPUT_VARIABLE _GLIBCXX_USE_CXX11_ABI
15
+ OUTPUT_STRIP_TRAILING_WHITESPACE
16
+ RESULT_VARIABLE ret
17
+ )
18
+ if (ret EQUAL "1" )
19
+ message (FATAL_ERROR "Failed to detect ABI version" )
20
+ endif ()
21
+ endif ()
22
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${_GLIBCXX_USE_CXX11_ABI} " )
23
+ add_definitions (-D_GLIBCXX_USE_CXX11_ABI=${_GLIBCXX_USE_CXX11_ABI} )
24
+ message (STATUS "_GLIBCXX_USE_CXX11_ABI - ${_GLIBCXX_USE_CXX11_ABI} " )
25
+
10
26
set (Python3_FIND_STRATEGY LOCATION )
11
27
12
28
find_package (Python3 COMPONENTS Interpreter Development )
Original file line number Diff line number Diff line change @@ -37,20 +37,19 @@ class MultipyRuntimeDevelop(MultipyRuntimeCmake, develop):
37
37
def initialize_options (self ):
38
38
develop .initialize_options (self )
39
39
self .cmakeoff = None
40
+
41
+ # TODO(tristanr): remove once unused
40
42
self .abicxx = None
41
43
42
44
def finalize_options (self ):
43
45
develop .finalize_options (self )
44
46
if self .cmakeoff is not None :
45
47
self .distribution .get_command_obj ("build_ext" ).cmake_off = True
46
- if self .abicxx is not None :
47
- self .distribution .get_command_obj ("build_ext" ).abicxx = True
48
48
49
49
50
50
class MultipyRuntimeBuild (MultipyRuntimeCmake , build_ext ):
51
51
user_options = build_ext .user_options + MultipyRuntimeCmake .user_options
52
52
cmake_off = False
53
- abicxx = False
54
53
55
54
def run (self ):
56
55
if self .cmake_off :
@@ -71,14 +70,11 @@ def run(self):
71
70
if not os .path .exists (build_dir_abs ):
72
71
os .makedirs (build_dir_abs )
73
72
legacy_python_cmake_flag = "OFF" if sys .version_info .minor > 7 else "ON"
74
- cxx_abi_flag = "ON" if self .abicxx else "OFF"
75
73
76
74
print (f"-- Running multipy runtime makefile in dir { build_dir_abs } " )
77
75
try :
78
76
subprocess .run (
79
- [
80
- f"cmake -DLEGACY_PYTHON_PRE_3_8={ legacy_python_cmake_flag } -DABI_EQUALS_1={ cxx_abi_flag } .."
81
- ],
77
+ [f"cmake -DLEGACY_PYTHON_PRE_3_8={ legacy_python_cmake_flag } .." ],
82
78
cwd = build_dir_abs ,
83
79
shell = True ,
84
80
check = True ,
You can’t perform that action at this time.
0 commit comments