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
86
99
# Workaround required for MKL library linkage
87
100
# https://github.com/pytorch/pytorch/issues/119557
Original file line number Diff line number Diff line change @@ -1244,9 +1244,19 @@ if(USE_ROCM)
1244
1244
# Currently only active for Ubuntu 20.04 and greater versions.
1245
1245
if (UNIX AND EXISTS "/etc/os-release" )
1246
1246
file (STRINGS /etc/os-release OS_RELEASE )
1247
- string (REGEX REPLACE ".*NAME=\" ([A-Za-z]+).*" "\\ 1" OS_DISTRO ${OS_RELEASE} )
1248
- string (REGEX REPLACE ".*VERSION_ID=\" ([0-9\. ]+).*" "\\ 1" OS_VERSION ${OS_RELEASE} )
1249
- if (OS_DISTRO STREQUAL "Ubuntu" AND OS_VERSION VERSION_GREATER_EQUAL "20.04" )
1247
+ set (DISTRO_NAME "" )
1248
+ set (DISTRO_VERSION "" )
1249
+ foreach (line ${OS_RELEASE} )
1250
+ string (REGEX MATCH "^NAME=" DISTRO_NAME_MATCH ${line} )
1251
+ if (NOT DISTRO_NAME_MATCH STREQUAL "" )
1252
+ string (REGEX REPLACE "^NAME=\" (.*)\" " "\\ 1" DISTRO_NAME ${line} )
1253
+ endif ()
1254
+ string (REGEX MATCH "^VERSION_ID=" DISTRO_VERSION_MATCH ${line} )
1255
+ if (NOT DISTRO_VERSION_MATCH STREQUAL "" )
1256
+ string (REGEX REPLACE "^VERSION_ID=\" (.*)\" " "\\ 1" DISTRO_VERSION ${line} )
1257
+ endif ()
1258
+ endforeach ()
1259
+ if (DISTRO_NAME STREQUAL "Ubuntu" AND DISTRO_VERSION VERSION_GREATER_EQUAL "20.04" )
1250
1260
find_library (LIBTINFO_LOC tinfo NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH )
1251
1261
if (LIBTINFO_LOC )
1252
1262
get_filename_component (LIBTINFO_LOC_PARENT ${LIBTINFO_LOC} DIRECTORY )
You can’t perform that action at this time.
0 commit comments