Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion conda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ docker run --rm -it \
-e DESIRED_PYTHON=3.8 \
-e PYTORCH_BUILD_VERSION=1.5.0 \
-e PYTORCH_BUILD_NUMBER=1 \
-e OVERRIDE_PACKAGE_VERSION=1.5.0
-e TORCH_CONDA_BUILD_FOLDER=pytorch-nightly \
-v /path/to/pytorch:/pytorch \
-v /path/to/builder:/builder \
Expand Down
5 changes: 2 additions & 3 deletions conda/build_pytorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,12 @@ if [[ -n "$cpu_only" ]]; then
if [[ "$OSTYPE" != "darwin"* ]]; then
build_string_suffix="cpu_${build_string_suffix}"
fi
# on Linux, advertise that the package sets the cpuonly feature
export CONDA_CPU_ONLY_FEATURE=" - cpuonly # [not osx]"
export PYTORCH_BUILD_VARIANT="cpu"
else
# Switch the CUDA version that /usr/local/cuda points to. This script also
# sets CUDA_VERSION and CUDNN_VERSION
echo "Switching to CUDA version $desired_cuda"
export CONDA_CPU_ONLY_FEATURE=""
export PYTORCH_BUILD_VARIANT="cuda"
. ./switch_cuda_version.sh "$desired_cuda"
# TODO, simplify after anaconda fixes their cudatoolkit versioning inconsistency.
# see: https://github.com/conda-forge/conda-forge.github.io/issues/687#issuecomment-460086164
Expand Down
6 changes: 5 additions & 1 deletion conda/cpuonly/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package:
name: cpuonly
version: 1.0
version: 2.0

build:
track_features:
- cpuonly
noarch: generic

requirements:
run:
- pytorch-mutex 1.0 cpu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative option to pytorch-mutex 1.0 cpu is to use pytorch=*=*cpu*. However, running

conda install -c nvidia -c pytorch pytorch=*=*cpu*

prefers the main channel

pytorch            pkgs/main/linux-64::pytorch-1.8.1-cpu_py38h60491be_0

So I think using pytorch=*=*cpu* for cpuonly package could break conda.

mamba chooses the pytorch channel

  + pytorch               1.9.0  py3.8_cpu_0    pytorch/linux-64        73 MB

3 changes: 3 additions & 0 deletions conda/pytorch-mutex/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build_variant:
- cpu
- cuda
29 changes: 29 additions & 0 deletions conda/pytorch-mutex/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% set version = "1.0" %}
{% set build = 0 %}

{% if build_variant == 'cuda' %}
# prefer cuda builds via a build number offset
{% set build = build + 100 %}
{% endif %}

package:
name: pytorch-mutex
version: {{ version }}
build:
number: {{ build }}
string: {{ build_variant }}
noarch: generic
# also lower cpu priority with track_features
{% if build_variant == 'cpu' %}
track_features:
- pytorch-mutex
{% endif %}
run_exports:
- {{ pin_subpackage('pytorch-mutex', exact=True) }}
requirements: {}
# None, pytorch should depend on pytorch-mutex
test:
commands:
- echo "pytorch-mutex metapackage is created."
about:
summary: Metapackage to select the PyTorch variant. Use conda's pinning mechanism in your environment to control which variant you want.
11 changes: 11 additions & 0 deletions conda/pytorch-nightly/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set build_variant = environ.get('PYTORCH_BUILD_VARIANT', 'cuda') %}

package:
name: pytorch
version: "{{ environ.get('PYTORCH_BUILD_VERSION') }}"
Expand Down Expand Up @@ -36,8 +38,17 @@ requirements:
- intel-openmp # [win]
- typing_extensions
- blas * mkl
- pytorch-mutex 1.0 {{ build_variant }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}

{% if build_variant == 'cpu' %}
run_constrained:
- cpuonly
{% else %}
run_constrained:
- cpuonly <0
{% endif %}

build:
number: {{ environ.get('PYTORCH_BUILD_NUMBER', '1') }}
detect_binary_files_with_prefix: False
Expand Down