Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 4d84b21

Browse files
IvanYashchukmalfet
andauthored
Remove "track_features" from cpuonly conda package (#823)
* Add pytorch-mutex metapackage to choose PyTorch build variant * Use run_constrained with cpuonly * Fix missing \ and remove OVERRIDE_PACKAGE_VERSION * Restore track_features in cpuonly/meta.yaml Co-authored-by: Nikita Shulga <[email protected]>
1 parent 1c4c239 commit 4d84b21

File tree

6 files changed

+50
-5
lines changed

6 files changed

+50
-5
lines changed

conda/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ docker run --rm -it \
2424
-e DESIRED_PYTHON=3.8 \
2525
-e PYTORCH_BUILD_VERSION=1.5.0 \
2626
-e PYTORCH_BUILD_NUMBER=1 \
27-
-e OVERRIDE_PACKAGE_VERSION=1.5.0
2827
-e TORCH_CONDA_BUILD_FOLDER=pytorch-nightly \
2928
-v /path/to/pytorch:/pytorch \
3029
-v /path/to/builder:/builder \

conda/build_pytorch.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,12 @@ if [[ -n "$cpu_only" ]]; then
254254
if [[ "$OSTYPE" != "darwin"* ]]; then
255255
build_string_suffix="cpu_${build_string_suffix}"
256256
fi
257-
# on Linux, advertise that the package sets the cpuonly feature
258-
export CONDA_CPU_ONLY_FEATURE=" - cpuonly # [not osx]"
257+
export PYTORCH_BUILD_VARIANT="cpu"
259258
else
260259
# Switch the CUDA version that /usr/local/cuda points to. This script also
261260
# sets CUDA_VERSION and CUDNN_VERSION
262261
echo "Switching to CUDA version $desired_cuda"
263-
export CONDA_CPU_ONLY_FEATURE=""
262+
export PYTORCH_BUILD_VARIANT="cuda"
264263
. ./switch_cuda_version.sh "$desired_cuda"
265264
# TODO, simplify after anaconda fixes their cudatoolkit versioning inconsistency.
266265
# see: https://github.com/conda-forge/conda-forge.github.io/issues/687#issuecomment-460086164

conda/cpuonly/meta.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package:
22
name: cpuonly
3-
version: 1.0
3+
version: 2.0
44

55
build:
66
track_features:
77
- cpuonly
88
noarch: generic
9+
10+
requirements:
11+
run:
12+
- pytorch-mutex 1.0 cpu
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build_variant:
2+
- cpu
3+
- cuda

conda/pytorch-mutex/meta.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% set version = "1.0" %}
2+
{% set build = 0 %}
3+
4+
{% if build_variant == 'cuda' %}
5+
# prefer cuda builds via a build number offset
6+
{% set build = build + 100 %}
7+
{% endif %}
8+
9+
package:
10+
name: pytorch-mutex
11+
version: {{ version }}
12+
build:
13+
number: {{ build }}
14+
string: {{ build_variant }}
15+
noarch: generic
16+
# also lower cpu priority with track_features
17+
{% if build_variant == 'cpu' %}
18+
track_features:
19+
- pytorch-mutex
20+
{% endif %}
21+
run_exports:
22+
- {{ pin_subpackage('pytorch-mutex', exact=True) }}
23+
requirements: {}
24+
# None, pytorch should depend on pytorch-mutex
25+
test:
26+
commands:
27+
- echo "pytorch-mutex metapackage is created."
28+
about:
29+
summary: Metapackage to select the PyTorch variant. Use conda's pinning mechanism in your environment to control which variant you want.

conda/pytorch-nightly/meta.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% set build_variant = environ.get('PYTORCH_BUILD_VARIANT', 'cuda') %}
2+
13
package:
24
name: pytorch
35
version: "{{ environ.get('PYTORCH_BUILD_VERSION') }}"
@@ -36,8 +38,17 @@ requirements:
3638
- intel-openmp # [win]
3739
- typing_extensions
3840
- blas * mkl
41+
- pytorch-mutex 1.0 {{ build_variant }}
3942
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
4043

44+
{% if build_variant == 'cpu' %}
45+
run_constrained:
46+
- cpuonly
47+
{% else %}
48+
run_constrained:
49+
- cpuonly <0
50+
{% endif %}
51+
4152
build:
4253
number: {{ environ.get('PYTORCH_BUILD_NUMBER', '1') }}
4354
detect_binary_files_with_prefix: False

0 commit comments

Comments
 (0)