File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,20 @@ if ! which conda; then
81
81
export USE_MKLDNN=0
82
82
fi
83
83
else
84
- export CMAKE_PREFIX_PATH=/opt/conda
84
+ # CMAKE_PREFIX_PATH precedences
85
+ # 1. $CONDA_PREFIX, if defined. This follows the pytorch official build instructions.
86
+ # 2. /opt/conda/envs/py_${ANACONDA_PYTHON_VERSION}, if ANACONDA_PYTHON_VERSION defined.
87
+ # This is for CI, which defines ANACONDA_PYTHON_VERSION but not CONDA_PREFIX.
88
+ # 3. $(conda info --base). The fallback value of pytorch official build
89
+ # instructions actually refers to this.
90
+ # Commonly this is /opt/conda/
91
+ if [[ -v CONDA_PREFIX ]]; then
92
+ export CMAKE_PREFIX_PATH=${CONDA_PREFIX}
93
+ elif [[ -v ANACONDA_PYTHON_VERSION ]]; then
94
+ export CMAKE_PREFIX_PATH=" /opt/conda/envs/py_${ANACONDA_PYTHON_VERSION} "
95
+ else
96
+ export CMAKE_PREFIX_PATH=" $( conda info --base) "
97
+ fi
85
98
fi
86
99
87
100
if [[ " $BUILD_ENVIRONMENT " == * libtorch* ]]; then
Original file line number Diff line number Diff line change @@ -1232,9 +1232,19 @@ if(USE_ROCM)
1232
1232
# Currently only active for Ubuntu 20.04 and greater versions.
1233
1233
if (UNIX AND EXISTS "/etc/os-release" )
1234
1234
file (STRINGS /etc/os-release OS_RELEASE )
1235
- string (REGEX REPLACE ".*NAME=\" ([A-Za-z]+).*" "\\ 1" OS_DISTRO ${OS_RELEASE} )
1236
- string (REGEX REPLACE ".*VERSION_ID=\" ([0-9\. ]+).*" "\\ 1" OS_VERSION ${OS_RELEASE} )
1237
- if (OS_DISTRO STREQUAL "Ubuntu" AND OS_VERSION VERSION_GREATER_EQUAL "20.04" )
1235
+ set (DISTRO_NAME "" )
1236
+ set (DISTRO_VERSION "" )
1237
+ foreach (line ${OS_RELEASE} )
1238
+ string (REGEX MATCH "^NAME=" DISTRO_NAME_MATCH ${line} )
1239
+ if (NOT DISTRO_NAME_MATCH STREQUAL "" )
1240
+ string (REGEX REPLACE "^NAME=\" (.*)\" " "\\ 1" DISTRO_NAME ${line} )
1241
+ endif ()
1242
+ string (REGEX MATCH "^VERSION_ID=" DISTRO_VERSION_MATCH ${line} )
1243
+ if (NOT DISTRO_VERSION_MATCH STREQUAL "" )
1244
+ string (REGEX REPLACE "^VERSION_ID=\" (.*)\" " "\\ 1" DISTRO_VERSION ${line} )
1245
+ endif ()
1246
+ endforeach ()
1247
+ if (DISTRO_NAME STREQUAL "Ubuntu" AND DISTRO_VERSION VERSION_GREATER_EQUAL "20.04" )
1238
1248
find_library (LIBTINFO_LOC tinfo NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH )
1239
1249
if (LIBTINFO_LOC )
1240
1250
get_filename_component (LIBTINFO_LOC_PARENT ${LIBTINFO_LOC} DIRECTORY )
You can’t perform that action at this time.
0 commit comments