diff --git a/.ci_support/migrations/fmt12_spdlog116.yaml b/.ci_support/migrations/fmt12_spdlog116.yaml deleted file mode 100644 index 87c31a2ba..000000000 --- a/.ci_support/migrations/fmt12_spdlog116.yaml +++ /dev/null @@ -1,10 +0,0 @@ -__migrator: - build_number: 1 - commit_message: Rebuild for fmt 12.0 and spdlog 1.16 - kind: version - migration_number: 1 -migrator_ts: 1760196591.995821 -fmt: -- '12.0' -spdlog: -- '1.16' diff --git a/recipe/activate.bat b/recipe/activate.bat new file mode 100644 index 000000000..d90905064 --- /dev/null +++ b/recipe/activate.bat @@ -0,0 +1,9 @@ +@echo off + +if not defined CF_TORCH_CUDA_ARCH_LIST ( + set "CF_TORCH_CUDA_ARCH_LIST=@cf_torch_cuda_arch_list@" + :: "NOT_SET" is used as the value because it is clearer (explicit) that the activation + :: script was run and found no previous value for "CF_TORCH_CUDA_ARCH_LIST". + set "CF_TORCH_CUDA_ARCH_LIST_BACKUP=NOT_SET" +) + diff --git a/recipe/activate.sh b/recipe/activate.sh new file mode 100644 index 000000000..ab2c78059 --- /dev/null +++ b/recipe/activate.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [[ ! -v CF_TORCH_CUDA_ARCH_LIST ]] +then + export CF_TORCH_CUDA_ARCH_LIST="@cf_torch_cuda_arch_list@" + # "NOT_SET" is used as the value because it is clearer (explicit) that the activation + # script was run and found no previous value for "CF_TORCH_CUDA_ARCH_LIST". + export CF_TORCH_CUDA_ARCH_LIST_BACKUP="NOT_SET" +fi diff --git a/recipe/bld.bat b/recipe/bld.bat index c4750dc48..5124f7a9f 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -108,6 +108,7 @@ if not "%cuda_compiler_version%" == "None" ( @REM MKLDNN is an Apache-2.0 licensed library for DNNs and is used @REM for CPU builds. Not to be confused with MKL. set "USE_MKLDNN=1" + set "TORCH_CUDA_ARCH_LIST=" @REM On windows, env vars are case-insensitive and setup.py @REM passes all env vars starting with CUDA_*, CMAKE_* to @@ -221,6 +222,21 @@ if "%PKG_NAME%" == "libtorch" ( @REM Keep the original backed up to sed later copy build\CMakeCache.txt build\CMakeCache.txt.orig if %ERRORLEVEL% neq 0 exit 1 + + if not "%cuda_compiler_version%" == "None" ( + sed -e "s/@cf_torch_cuda_arch_list@/%TORCH_CUDA_ARCH_LIST%/g" ^ + %RECIPE_DIR%\activate.bat > %RECIPE_DIR%\activate-replaced.bat + if %ERRORLEVEL% neq 0 exit 1 + + mkdir %PREFIX%\etc\conda\activate.d + copy %RECIPE_DIR%\activate-replaced.bat %PREFIX%\etc\conda\activate.d\libtorch_activate.bat + if %ERRORLEVEL% neq 0 exit 1 + + mkdir %PREFIX%\etc\conda\deactivate.d + copy %RECIPE_DIR%\deactivate.bat %PREFIX%\etc\conda\deactivate.d\libtorch_deactivate.bat + if %ERRORLEVEL% neq 0 exit 1 + ) + ) else if "%PKG_NAME%" == "pytorch" ( @REM Move libtorch_python and remove the other directories afterwards. robocopy /NP /NFL /NDL /NJH /E %SP_DIR%\torch\bin\ %LIBRARY_BIN%\ torch_python.dll diff --git a/recipe/build.sh b/recipe/build.sh index dd24fc2d9..0b8e3e068 100644 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -254,6 +254,7 @@ else # for CPU builds. Not to be confused with MKL. export USE_MKLDNN=1 export USE_CUDA=0 + export TORCH_CUDA_ARCH_LIST="" fi echo '${CXX}'=${CXX} @@ -279,6 +280,16 @@ case ${PKG_NAME} in # Keep the original backed up to sed later cp build/CMakeCache.txt build/CMakeCache.txt.orig + + if [[ "${cuda_compiler_version}" != "None" ]]; then + for CHANGE in "activate" "deactivate" + do + mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d" + sed -e "s/@cf_torch_cuda_arch_list@/${TORCH_CUDA_ARCH_LIST}/g" \ + "${RECIPE_DIR}/${CHANGE}.sh" > "${PREFIX}/etc/conda/${CHANGE}.d/libtorch_${CHANGE}.sh" + done + fi + ;; pytorch) $PREFIX/bin/python -m pip install . --no-deps --no-build-isolation -v --no-clean --config-settings=--global-option=-q \ diff --git a/recipe/deactivate.bat b/recipe/deactivate.bat new file mode 100644 index 000000000..de789f075 --- /dev/null +++ b/recipe/deactivate.bat @@ -0,0 +1,6 @@ +@echo off + +if "%CF_TORCH_CUDA_ARCH_LIST_BACKUP%" == "NOT_SET" ( + set "CF_TORCH_CUDA_ARCH_LIST=" + set "CF_TORCH_CUDA_ARCH_LIST_BACKUP=" +) diff --git a/recipe/deactivate.sh b/recipe/deactivate.sh new file mode 100644 index 000000000..5723b3298 --- /dev/null +++ b/recipe/deactivate.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ "${CF_TORCH_CUDA_ARCH_LIST_BACKUP}" == "NOT_SET" ]] +then + unset CF_TORCH_CUDA_ARCH_LIST + unset CF_TORCH_CUDA_ARCH_LIST_BACKUP +fi