From 35cba955b122aa9c0c29c93019be6d132e8ce8ae Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Sun, 3 Nov 2024 14:13:25 -0800 Subject: [PATCH 1/4] Fix pytorch-cpu/gpu build only for single python version --- recipe/meta.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index b5ab68a6..e8d5d060 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,5 +1,5 @@ {% set version = "2.5.1" %} -{% set build = 1 %} +{% set build = 2 %} {% if cuda_compiler_version != "None" %} {% set build = build + 200 %} @@ -338,8 +338,10 @@ outputs: {% set pytorch_cpu_gpu = "pytorch-gpu" %} # [cuda_compiler_version != "None"] - name: {{ pytorch_cpu_gpu }} build: - string: cuda{{ cuda_compiler_version | replace('.', '') }}py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda_compiler_version != "None"] - string: cpu_{{ blas_impl }}_py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda_compiler_version == "None"] + string: cuda{{ cuda_compiler_version | replace('.', '') }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] + string: cpu_{{ blas_impl }}_h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version == "None"] + string: cuda{{ cuda_compiler_version | replace('.', '') }}py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [not megabuild and cuda_compiler_version != "None"] + string: cpu_{{ blas_impl }}_py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [not megabuild and cuda_compiler_version == "None"] detect_binary_files_with_prefix: false skip: true # [cuda_compiler_version != "None" and linux64 and blas_impl != "mkl"] # weigh down cpu implementation and give cuda preference @@ -347,7 +349,11 @@ outputs: - pytorch-cpu # [cuda_compiler_version == "None"] requirements: run: - - {{ pin_subpackage("pytorch", exact=True) }} + - pytorch {{ version }}=cuda_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] + - pytorch {{ version }}=cpu_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version == "None"] + - pytorch {{ version }}=cuda_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] + - pytorch {{ version }}=cpu_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version == "None"] + - {{ pin_subpackage("pytorch", exact=True) }} # [not megabuild] test: imports: - torch From 620569feb806e973b39f193dcde28e47147c7827 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Sun, 3 Nov 2024 19:54:50 -0800 Subject: [PATCH 2/4] Fix copy-paste error --- recipe/meta.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index e8d5d060..5f56a913 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -349,8 +349,6 @@ outputs: - pytorch-cpu # [cuda_compiler_version == "None"] requirements: run: - - pytorch {{ version }}=cuda_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] - - pytorch {{ version }}=cpu_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version == "None"] - pytorch {{ version }}=cuda_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] - pytorch {{ version }}=cpu_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version == "None"] - {{ pin_subpackage("pytorch", exact=True) }} # [not megabuild] From 55f61d4f49ae1a50df21bab5f6bb435019e8527d Mon Sep 17 00:00:00 2001 From: "Jeongseok (JS) Lee" <142548112+jeongseok-meta@users.noreply.github.com> Date: Sun, 3 Nov 2024 20:02:46 -0800 Subject: [PATCH 3/4] Update recipe/meta.yaml Co-authored-by: Mark Harfouche --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 5f56a913..0ddaa8ca 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -349,7 +349,7 @@ outputs: - pytorch-cpu # [cuda_compiler_version == "None"] requirements: run: - - pytorch {{ version }}=cuda_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] + - pytorch {{ version }}=cuda*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version != "None"] - pytorch {{ version }}=cpu_{{ blas_impl }}*{{ PKG_BUILDNUM }} # [megabuild and cuda_compiler_version == "None"] - {{ pin_subpackage("pytorch", exact=True) }} # [not megabuild] test: From 08042f6d8810e27a13de04eb5f352f1b9d7b902f Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Mon, 4 Nov 2024 08:04:47 -0800 Subject: [PATCH 4/4] Add patch for pickler error --- recipe/meta.yaml | 2 ++ recipe/patches/0008-Fix-pickler-error.patch | 34 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 recipe/patches/0008-Fix-pickler-error.patch diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 0ddaa8ca..cc0261e6 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -32,6 +32,8 @@ source: # https://github.com/pytorch/pytorch/pull/133235 - patches/0006-Update-sympy-version.patch - patches/0007-Fix-duplicate-linker-script.patch # [cuda_compiler_version != "None" and aarch64] + # https://github.com/pytorch/pytorch/pull/136034 + - patches/0008-Fix-pickler-error.patch # https://github.com/pytorch/pytorch/pull/137331 - patches/137331.patch diff --git a/recipe/patches/0008-Fix-pickler-error.patch b/recipe/patches/0008-Fix-pickler-error.patch new file mode 100644 index 00000000..aaf88d39 --- /dev/null +++ b/recipe/patches/0008-Fix-pickler-error.patch @@ -0,0 +1,34 @@ +diff --git a/torch/serialization.py b/torch/serialization.py +index d936d31d6f5..d937680c031 100644 +--- a/torch/serialization.py ++++ b/torch/serialization.py +@@ -1005,8 +1005,12 @@ def _legacy_save(obj, f, pickle_module, pickle_protocol) -> None: + pickle_module.dump(MAGIC_NUMBER, f, protocol=pickle_protocol) + pickle_module.dump(PROTOCOL_VERSION, f, protocol=pickle_protocol) + pickle_module.dump(sys_info, f, protocol=pickle_protocol) +- pickler = pickle_module.Pickler(f, protocol=pickle_protocol) +- pickler.persistent_id = persistent_id ++ ++ class PyTorchLegacyPickler(pickle_module.Pickler): ++ def persistent_id(self, obj): ++ return persistent_id(obj) ++ ++ pickler = PyTorchLegacyPickler(f, protocol=pickle_protocol) + pickler.dump(obj) + + serialized_storage_keys = sorted(serialized_storages.keys()) +@@ -1083,8 +1087,12 @@ def _save( + + # Write the pickle data for `obj` + data_buf = io.BytesIO() +- pickler = pickle_module.Pickler(data_buf, protocol=pickle_protocol) +- pickler.persistent_id = persistent_id ++ ++ class PyTorchPickler(pickle_module.Pickler): # type: ignore[name-defined] ++ def persistent_id(self, obj): ++ return persistent_id(obj) ++ ++ pickler = PyTorchPickler(data_buf, protocol=pickle_protocol) + pickler.dump(obj) + data_value = data_buf.getvalue() + zip_file.write_record("data.pkl", data_value, len(data_value))