Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pkg 6001 win cf #53

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6392ecb
Build for windows
ELundby45 Dec 22, 2024
5cb7864
Add win specific missing_dso_whitelist
ELundby45 Dec 22, 2024
72bacd7
Pin setuptools
ELundby45 Dec 22, 2024
fb490d4
Try to fix test command on windows
ELundby45 Dec 22, 2024
618fbd3
Stage channel no longer needed.
ELundby45 Dec 22, 2024
74258de
Cleanup libgtorch files when building torch
ELundby45 Dec 22, 2024
2781c34
Update bld.bat
ELundby45 Dec 22, 2024
177e4a2
Fix patches on windows.
ELundby45 Dec 23, 2024
5fd2413
Remove pins, causing resolution error on windows,
ELundby45 Dec 23, 2024
f163074
Temporarily disable pip check on windows.
ELundby45 Dec 27, 2024
325177c
Simplify bld.bat
ELundby45 Jan 3, 2025
3a1044c
Re-enable pip check
ELundby45 Jan 3, 2025
d6e5b8f
Try to build in parallel
ELundby45 Jan 3, 2025
ac741b2
White space.
ELundby45 Jan 3, 2025
a4c7fb1
Temporarily skip non windows.
ELundby45 Jan 3, 2025
f3d270c
Stick with single job
ELundby45 Jan 4, 2025
6a25649
Re-vendor protobuf for now.
ELundby45 Jan 4, 2025
6a7ebc1
Fix windows split build.
ELundby45 Jan 6, 2025
fc109ce
Address overlinking and fix several tests.
ELundby45 Jan 6, 2025
e17fbc2
Test other platforms too.
ELundby45 Jan 6, 2025
14bf984
Fix typo in path.
ELundby45 Jan 7, 2025
121378a
Revert "Test other platforms too."
ELundby45 Jan 7, 2025
ed9022b
Unvendor protobuf
ELundby45 Jan 7, 2025
7b53796
Unvendor sleef
ELundby45 Jan 7, 2025
e02b47d
Remove unneeded flags.
ELundby45 Jan 7, 2025
7bfde6d
Clean between runs.
ELundby45 Jan 8, 2025
58b281e
Try more aggressive clean.
ELundby45 Jan 9, 2025
fe50aa4
Grammer
ELundby45 Jan 11, 2025
0662f6a
Try removing build command
ELundby45 Jan 11, 2025
a3d51b2
Build all architectures.
ELundby45 Jan 11, 2025
c3cb07a
Revert "Try removing build command"
ELundby45 Jan 12, 2025
b80bc5a
Fix version string.
ELundby45 Jan 15, 2025
f4ae843
Bring over conda-forge differences.
ELundby45 Jan 15, 2025
3b4ecad
Remove split flags.
ELundby45 Jan 16, 2025
fdc02de
Skip non-win
ELundby45 Jan 16, 2025
0a4e590
🐌 Do full clean between builds. Fix for partial 3.12 build.
ELundby45 Jan 17, 2025
0fba526
Remove Skip.
ELundby45 Jan 21, 2025
397b2dc
Cleanup, add comment.
ELundby45 Jan 23, 2025
4c27ef7
Remove hack add back og run_test cmd
ELundby45 Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions abs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
# variant, so it's specified for both.
extra_labels_for_os:
osx-arm64: [ventura]
aggregate_check: false

channels:
- https://staging.continuum.io/prefect/fs/sympy-feedstock/pr10/3afd78c
aggregate_check: false
ELundby45 marked this conversation as resolved.
Show resolved Hide resolved
90 changes: 82 additions & 8 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
@echo On
setlocal enabledelayedexpansion

:: The PyTorch test suite includes some symlinks, which aren't resolved on Windows, leading to packaging errors.
:: ATTN! These change and have to be updated manually, often with each release.
:: (no current symlinks being packaged. Leaving this information here as it took some months to find the issue. Look out
:: for a failure with error message: "conda_package_handling.exceptions.ArchiveCreationError: <somefile> Cannot stat
:: while writing file")

set TH_BINARY_BUILD=1
danpetry marked this conversation as resolved.
Show resolved Hide resolved
set PYTORCH_BUILD_VERSION=%PKG_VERSION%
set PYTORCH_BUILD_NUMBER=%PKG_BUILDNUM%
:: Always pass 0 to avoid appending ".post" to version string.
:: https://github.com/conda-forge/pytorch-cpu-feedstock/issues/315
set PYTORCH_BUILD_NUMBER=0

:: uncomment to debug cmake build
:: set CMAKE_VERBOSE_MAKEFILE=1
Expand All @@ -21,6 +23,12 @@ if "%pytorch_variant%" == "gpu" (
set USE_CUDA=0
)

:: KINETO seems to require CUPTI and will look quite hard for it.
:: CUPTI seems to cause trouble when users install a version of
:: cudatoolkit different than the one specified at compile time.
:: https://github.com/conda-forge/pytorch-cpu-feedstock/issues/135
set "USE_KINETO=OFF"

:: =============================== CUDA FLAGS> ======================================
if "%build_with_cuda%" == "" goto cuda_flags_end

Expand All @@ -41,6 +49,7 @@ set USE_MKLDNN=1
set USE_TENSORPIPE=0
set DISTUTILS_USE_SDK=1
set BUILD_TEST=0
set INSTALL_TEST=0
:: Don't increase MAX_JOBS to NUMBER_OF_PROCESSORS, as it will run out of heap
set CPU_COUNT=1
set MAX_JOBS=%CPU_COUNT%
danpetry marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -64,9 +73,12 @@ set CUDNN_INCLUDE_DIR=%LIBRARY_PREFIX%\include
:: =============================== CUDA< ======================================

set CMAKE_GENERATOR=Ninja
set "CMAKE_GENERATOR_TOOLSET="
set "CMAKE_GENERATOR_PLATFORM="
set "CMAKE_PREFIX_PATH=%LIBRARY_PREFIX%"
set CMAKE_BUILD_TYPE=Release
set "CMAKE_INCLUDE_PATH=%LIBRARY_INC%"
set "CMAKE_LIBRARY_PATH=%LIBRARY_LIB%"
set "CMAKE_BUILD_TYPE=Release"
:: This is so that CMake finds the environment's Python, not another one
set Python_EXECUTABLE=%PYTHON%
set Python3_EXECUTABLE=%PYTHON%
Expand All @@ -81,10 +93,72 @@ set BLAS=MKL
set INTEL_MKL_DIR=%LIBRARY_PREFIX%

set "libuv_ROOT=%LIBRARY_PREFIX%"
set "USE_SYSTEM_SLEEF=OFF"
:: Note that BUILD_CUSTOM_PROTOBUF=OFF (which would use our protobuf) doesn't work properly as of last testing, and results in
:: duplicate symbols at link time.
:: set "BUILD_CUSTOM_PROTOBUF=OFF"
set "USE_SYSTEM_SLEEF=ON"

:: Use our protobuf
set "BUILD_CUSTOM_PROTOBUF=OFF"
set "USE_LITE_PROTO=ON"

:: Here we split the build into two parts.
::
:: Both the packages libtorch and pytorch use this same build script.
:: - The output of the libtorch package should just contain the binaries that are
:: not related to Python.
:: - The output of the pytorch package contains everything except for the
:: non-python specific binaries.
::
:: This ensures that a user can quickly switch between python versions without the
:: need to redownload all the large CUDA binaries.

if "%PKG_NAME%" == "libtorch" (
:: For the main script we just build a wheel for libtorch so that the C++/CUDA
:: parts are built. Then they are reused in each python version.

%PYTHON% setup.py bdist_wheel
danpetry marked this conversation as resolved.
Show resolved Hide resolved
:: Extract the compiled wheel into a temporary directory
if not exist "%SRC_DIR%/dist" mkdir %SRC_DIR%/dist
pushd %SRC_DIR%/dist
for %%f in (../torch-*.whl) do (
wheel unpack %%f
)

:: Navigate into the unpacked wheel
pushd torch-*

:: Move the binaries into the packages site-package directory
robocopy /NP /NFL /NDL /NJH /E torch\bin %SP_DIR%\torch\bin\
robocopy /NP /NFL /NDL /NJH /E torch\lib %SP_DIR%\torch\lib\
robocopy /NP /NFL /NDL /NJH /E torch\share %SP_DIR%\torch\share\
for %%f in (ATen caffe2 torch c10) do (
robocopy /NP /NFL /NDL /NJH /E torch\include\%%f %SP_DIR%\torch\include\%%f\
)

:: Remove the python binary file, that is placed in the site-packages
:: directory by the specific python specific pytorch package.
del %SP_DIR%\torch\lib\torch_python.*

popd
popd
) else (
:: NOTE: Passing --cmake is necessary here since the torch frontend has its
:: own cmake files that it needs to generate
%PYTHON% setup.py clean
%PYTHON% setup.py bdist_wheel --cmake
%PYTHON% -m pip install --find-links=dist torch --no-build-isolation --no-deps
rmdir /s /q %SP_DIR%\torch\bin
rmdir /s /q %SP_DIR%\torch\share
for %%f in (ATen caffe2 torch c10) do (
rmdir /s /q %SP_DIR%\torch\include\%%f
)

:: Delete all files from the lib directory that do not start with torch_python
for %%f in (%SP_DIR%\torch\lib\*) do (
set "FILENAME=%%~nf"
if "!FILENAME:~0,12!" neq "torch_python" (
del %%f
)
)
)

%PYTHON% -m pip install . --no-deps --no-build-isolation -vv
if errorlevel 1 exit /b 1

4 changes: 4 additions & 0 deletions recipe/build_pytorch.bat
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
@echo On
setlocal enabledelayedexpansion

call %RECIPE_DIR%\bld.bat
if errorlevel 1 exit /b 1
58 changes: 40 additions & 18 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ source:
{% endif %}
- url: https://raw.githubusercontent.com/pytorch/builder/{{ smoke_test_commit }}/test/smoke_test/smoke_test.py
folder: smoke_test

# The .gitignore is needed in order to run upstreams `setup.py clean`
- url: https://raw.githubusercontent.com/pytorch/pytorch/refs/tags/v{{ version }}/.gitignore

build:
number: {{ build }}
Expand All @@ -75,7 +76,6 @@ build:
- python * # [megabuild]
- numpy * # [megabuild]
skip: True # [py<39]
skip: True # [win]

requirements:
# Keep this list synchronized (except for python*, numpy*) in outputs
Expand Down Expand Up @@ -114,12 +114,13 @@ requirements:
# This has a strong run_export so we don't need to put it in `host` or `run`
# We use llvm-openmp for openblas variants on osx.
- llvm-openmp 14.0.6 # [osx and not (blas_impl == "mkl")]
- libuv # [win]
- cmake
- ninja-base
# Keep libprotobuf here so that a compatibile version
# of protobuf is installed between build and host
- libprotobuf # [not win]
- protobuf # [not win]
- libprotobuf
- protobuf
- make # [linux]
# Uncomment to use ccache, see README and build_pytorch.sh
# - ccache
Expand Down Expand Up @@ -147,15 +148,15 @@ requirements:
# other requirements
- python 3.12 # [megabuild]
- python # [not megabuild]
- numpy 2.*
- numpy 2
- pip
- setuptools
- setuptools <=72.1.0
ELundby45 marked this conversation as resolved.
Show resolved Hide resolved
- wheel
- pyyaml
- requests
- future
- six
- mkl-devel {{ mkl }}.* # [blas_impl == "mkl"]
- mkl-devel {{ mkl }} # [blas_impl == "mkl"]
- openblas-devel {{ openblas }} # [blas_impl == "openblas"]
# - libcblas * *_mkl # [blas_impl == "mkl"]
# - libcblas # [blas_impl != "mkl"]
Expand All @@ -167,8 +168,8 @@ requirements:
- intel-openmp {{ mkl }} # [blas_impl == "mkl"]
- llvm-openmp 14.0.6 # [osx and not (blas_impl == "mkl")]
- libabseil
- libprotobuf {{ libprotobuf }} # [not win]
- sleef 3.5.1 # [not win]
- libprotobuf {{ libprotobuf }}
- sleef 3.5.1
- typing
- libuv
- pkg-config # [unix]
Expand All @@ -180,6 +181,7 @@ requirements:
# satisfy overlinking checks
run:
- {{ pin_compatible('intel-openmp') }} # [blas_impl == "mkl"]
- libuv # [win]

# these tests are for the libtorch output below, but due to
# a particularity of conda-build, that output is defined in
Expand All @@ -199,6 +201,13 @@ outputs:
- name: libtorch
build:
missing_dso_whitelist:
# The are dynamically loaded from %SP_DIR%\torch\lib\
- "**/asmjit.dll" # [win]
- "**/c10.dll" # [win]
- "**/fbgemm.dll" # [win]
- "**/shm.dll" # [win]
- "**/torch_cpu.dll" # [win]
- "**/torch_python.dll" # [win]
- $RPATH/ld64.so.1 # [s390x]
- name: pytorch
build:
Expand All @@ -210,13 +219,19 @@ outputs:
ignore_run_exports: # [osx]
- libuv # [osx]
missing_dso_whitelist:
# The are dynamically loaded from %SP_DIR%\torch\lib\
- "**/asmjit.dll" # [win]
- "**/c10.dll" # [win]
- "**/fbgemm.dll" # [win]
- "**/shm.dll" # [win]
- "**/torch_cpu.dll" # [win]
- "**/torch_python.dll" # [win]
- $RPATH/ld64.so.1 # [s390x]
detect_binary_files_with_prefix: false
run_exports:
- {{ pin_subpackage('pytorch', max_pin='x.x') }}
- {{ pin_subpackage('libtorch', max_pin='x.x') }}
skip: True # [py<39]
skip: True # [win]

script: build_pytorch.sh # [unix]
script: build_pytorch.bat # [win]
Expand Down Expand Up @@ -256,8 +271,8 @@ outputs:
- ninja-base
# Keep libprotobuf here so that a compatibile version
# of protobuf is installed between build and host
- libprotobuf # [not win]
- protobuf # [not win]
- libprotobuf
- protobuf
- make # [linux]
# Uncomment to use ccache, see README and build_pytorch.sh
# - ccache
Expand All @@ -283,15 +298,15 @@ outputs:
{% endif %}
# other requirements
- python
- numpy 2.*
- numpy 2
- pip
- setuptools
- setuptools <=72.1.0
- wheel
- pyyaml
- requests
- future
- six
- mkl-devel {{ mkl }}.* # [blas_impl == "mkl"]
- mkl-devel {{ mkl }} # [blas_impl == "mkl"]
- openblas-devel {{ openblas }} # [blas_impl == "openblas"]
# - libcblas * *_mkl # [blas_impl == "mkl"]
# - libcblas # [blas_impl != "mkl"]
Expand All @@ -303,8 +318,8 @@ outputs:
- intel-openmp {{ mkl }} # [blas_impl == "mkl"]
- llvm-openmp 14.0.6 # [osx and not (blas_impl == "mkl")]
- libabseil
- libprotobuf {{ libprotobuf }} # [not win]
- sleef 3.5.1 # [not win]
- libprotobuf {{ libprotobuf }}
- sleef 3.5.1
- typing
- libuv
- pkg-config # [unix]
Expand Down Expand Up @@ -371,6 +386,8 @@ outputs:
- pytest-rerunfailures
- pytest-flakefinder
- pytest-xdist
# Needed for test_autograd.py
- pybind11
imports:
- torch
source_files:
Expand All @@ -379,6 +396,8 @@ outputs:
# as of pytorch=2.0.0, there is a bug when trying to run tests without the tools
- tools
- smoke_test
# See files needed: https://github.com/pytorch/pytorch/blob/main/test/test_ops.py#L271-L274
- aten/src/ATen/native
commands:
# the smoke test script takes a bunch of env variables, defined below
- set MATRIX_GPU_ARCH_VERSION="{{ '.'.join(cudatoolkit.split('.')[:2]) }}" # [(gpu_variant == "cuda-11") and (win)]
Expand Down Expand Up @@ -411,7 +430,10 @@ outputs:
# Note that the `|| true` expression will make the build continue even if the whole script falls over completely
# (for example, in the case of missing imports). There doesn't seem to be a way of making a script exception return
# non-zero but failing tests return zero.
- python ./test/run_test.py --core --continue-through-error || true
- python ./test/run_test.py --core --continue-through-error || true # [not win]
# Hack to fix test_autograd.py so it can find pybind11
danpetry marked this conversation as resolved.
Show resolved Hide resolved
- mv %PREFIX%/include/pybind11_global/pybind11 %PREFIX%/include # [win]
- cmd.exe /c "python ./test/run_test.py --core --continue-through-error" || ver > nul 2> nul # [win]
ELundby45 marked this conversation as resolved.
Show resolved Hide resolved
# The inductor tests test the torch.compile backend. Using the options below avoids running distributed tests,
# which would be run if we used the --inductor option. (Distributed tests would only be correctly run on a multi-gpu test platform,
# which we don't have.)
Expand Down