diff --git a/conda/README.md b/conda/README.md index 7b2594e07..4c1b719f6 100644 --- a/conda/README.md +++ b/conda/README.md @@ -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 \ diff --git a/conda/build_pytorch.sh b/conda/build_pytorch.sh index 972b1acf5..3a0418191 100755 --- a/conda/build_pytorch.sh +++ b/conda/build_pytorch.sh @@ -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 diff --git a/conda/cpuonly/meta.yaml b/conda/cpuonly/meta.yaml index c158aaf5c..c7d5a54dc 100644 --- a/conda/cpuonly/meta.yaml +++ b/conda/cpuonly/meta.yaml @@ -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 diff --git a/conda/pytorch-mutex/conda_build_config.yaml b/conda/pytorch-mutex/conda_build_config.yaml new file mode 100644 index 000000000..e18e53eb4 --- /dev/null +++ b/conda/pytorch-mutex/conda_build_config.yaml @@ -0,0 +1,3 @@ +build_variant: + - cpu + - cuda diff --git a/conda/pytorch-mutex/meta.yaml b/conda/pytorch-mutex/meta.yaml new file mode 100644 index 000000000..fa7f916ec --- /dev/null +++ b/conda/pytorch-mutex/meta.yaml @@ -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. diff --git a/conda/pytorch-nightly/meta.yaml b/conda/pytorch-nightly/meta.yaml index ec5075035..a24781ed1 100644 --- a/conda/pytorch-nightly/meta.yaml +++ b/conda/pytorch-nightly/meta.yaml @@ -1,3 +1,5 @@ +{% set build_variant = environ.get('PYTORCH_BUILD_VARIANT', 'cuda') %} + package: name: pytorch version: "{{ environ.get('PYTORCH_BUILD_VERSION') }}" @@ -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