Skip to content

Commit a38396f

Browse files
datumboxseemethere
authored andcommitted
[fbsync] Move TorchVision to conda package to use pytorch-mutex (#4661)
Summary: * Move TorchVision conda package to use pytorch-mutex This is follow up after pytorch/builder#823 that gets rids of `feature` and migrate it to `run_constrained` * Update packaging/torchvision/meta.yaml * Update packaging/torchvision/meta.yaml Reviewed By: NicolasHug Differential Revision: D31916325 fbshipit-source-id: 47589017b333948caee5b0412c30afaeb6eed4f8 Co-authored-by: Eli Uriegas <[email protected]> Co-authored-by: Eli Uriegas <[email protected]> Co-authored-by: Eli Uriegas <[email protected]>
1 parent 54672b8 commit a38396f

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

packaging/build_cmake.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ else
3636
MKL_CONSTRAINT=''
3737
fi
3838

39-
conda install -yq \pytorch=$PYTORCH_VERSION $CONDA_CUDATOOLKIT_CONSTRAINT $CONDA_CPUONLY_FEATURE $MKL_CONSTRAINT -c "pytorch-${UPLOAD_CHANNEL}"
39+
if [[ $CONDA_BUILD_VARIANT == "cpu" ]]; then
40+
PYTORCH_MUTEX_CONSTRAINT='pytorch-mutex=1.0=cpu'
41+
else
42+
PYTORCH_MUTEX_CONSTRAINT=''
43+
fi
44+
45+
conda install -yq \pytorch=$PYTORCH_VERSION $CONDA_CUDATOOLKIT_CONSTRAINT $PYTORCH_MUTEX_CONSTRAINT $MKL_CONSTRAINT -c "pytorch-${UPLOAD_CHANNEL}"
4046
TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)"))
4147

4248
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then

packaging/pkg_helpers.bash

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ setup_conda_pytorch_constraint() {
287287

288288
# Translate CUDA_VERSION into CUDA_CUDATOOLKIT_CONSTRAINT
289289
setup_conda_cudatoolkit_constraint() {
290-
export CONDA_CPUONLY_FEATURE=""
290+
export CONDA_BUILD_VARIANT="cuda"
291291
if [[ "$(uname)" == Darwin ]]; then
292-
export CONDA_CUDATOOLKIT_CONSTRAINT=""
292+
export CONDA_BUILD_VARIANT="cpu"
293293
else
294294
case "$CU_VERSION" in
295295
cu113)
@@ -318,7 +318,7 @@ setup_conda_cudatoolkit_constraint() {
318318
;;
319319
cpu)
320320
export CONDA_CUDATOOLKIT_CONSTRAINT=""
321-
export CONDA_CPUONLY_FEATURE="- cpuonly"
321+
export CONDA_BUILD_VARIANT="cpu"
322322
;;
323323
*)
324324
echo "Unrecognized CU_VERSION=$CU_VERSION"
@@ -329,10 +329,10 @@ setup_conda_cudatoolkit_constraint() {
329329
}
330330

331331
setup_conda_cudatoolkit_plain_constraint() {
332-
export CONDA_CPUONLY_FEATURE=""
332+
export CONDA_BUILD_VARIANT="cuda"
333333
export CMAKE_USE_CUDA=1
334334
if [[ "$(uname)" == Darwin ]]; then
335-
export CONDA_CUDATOOLKIT_CONSTRAINT=""
335+
export CONDA_BUILD_VARIANT="cpu"
336336
export CMAKE_USE_CUDA=0
337337
else
338338
case "$CU_VERSION" in
@@ -359,7 +359,7 @@ setup_conda_cudatoolkit_plain_constraint() {
359359
;;
360360
cpu)
361361
export CONDA_CUDATOOLKIT_CONSTRAINT=""
362-
export CONDA_CPUONLY_FEATURE="cpuonly"
362+
export CONDA_BUILD_VARIANT="cpu"
363363
export CMAKE_USE_CUDA=0
364364
;;
365365
*)

packaging/torchvision/meta.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% set build_variant = environ.get('CONDA_BUILD_VARIANT', 'cpu') %}
12
package:
23
name: torchvision
34
version: "{{ environ.get('BUILD_VERSION') }}"
@@ -16,9 +17,9 @@ requirements:
1617
host:
1718
- python
1819
- setuptools
20+
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
1921
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
20-
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
21-
{{ environ.get('CONDA_CPUONLY_FEATURE') }}
22+
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
2223

2324
run:
2425
- python
@@ -27,8 +28,17 @@ requirements:
2728
- ffmpeg >=4.2 # [not win]
2829
- jpeg
2930
- pillow >=5.3.0
31+
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
3032
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
31-
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
33+
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
34+
35+
{% if build_variant == 'cpu' %}
36+
run_constrained:
37+
- cpuonly
38+
{% elif not osx %}
39+
run_constrained:
40+
- cpuonly <0
41+
{% endif %}
3242

3343
build:
3444
string: py{{py}}_{{ environ['CU_VERSION'] }}
@@ -38,8 +48,6 @@ build:
3848
- FORCE_CUDA
3949
- BUILD_VERSION
4050
- TORCH_CUDA_ARCH_LIST
41-
features:
42-
{{ environ.get('CONDA_CPUONLY_FEATURE') }}
4351

4452
test:
4553
imports:

0 commit comments

Comments
 (0)