Skip to content

Commit 0c7cd81

Browse files
committed
enforce pytorch-mutex cpu like torchvision.
1 parent a2f1860 commit 0c7cd81

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

packaging/pkg_helpers.bash

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,21 @@ setup_pip_pytorch_version() {
179179
#
180180
# You MUST have populated PYTORCH_VERSION_SUFFIX before hand.
181181
setup_conda_pytorch_constraint() {
182-
CONDA_CHANNEL_FLAGS=${CONDA_CHANNEL_FLAGS:-}
183182
if [[ -z "$PYTORCH_VERSION" ]]; then
184-
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch-nightly"
185-
export PYTORCH_VERSION="$(conda search --json 'pytorch[channel=pytorch-nightly]' | python -c "import sys, json, re; print(re.sub(r'\\+.*$', '', json.load(sys.stdin)['pytorch'][-1]['version']))")"
183+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch-nightly -c pytorch"
184+
export PYTORCH_VERSION="$(conda search --json 'pytorch[channel=pytorch-nightly]' | \
185+
python -c "import os, sys, json, re; cuver = os.environ.get('CU_VERSION'); \
186+
cuver_1 = cuver.replace('cu', 'cuda') if cuver != 'cpu' else cuver; \
187+
cuver_2 = (cuver[:-1] + '.' + cuver[-1]).replace('cu', 'cuda') if cuver != 'cpu' else cuver; \
188+
print(re.sub(r'\\+.*$', '', \
189+
[x['version'] for x in json.load(sys.stdin)['pytorch'] \
190+
if (x['platform'] == 'darwin' or cuver_1 in x['fn'] or cuver_2 in x['fn']) \
191+
and 'py' + os.environ['PYTHON_VERSION'] in x['fn']][-1]))")"
192+
if [[ -z "$PYTORCH_VERSION" ]]; then
193+
echo "PyTorch version auto detection failed"
194+
echo "No package found for CU_VERSION=$CU_VERSION and PYTHON_VERSION=$PYTHON_VERSION"
195+
exit 1
196+
fi
186197
else
187198
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch -c pytorch-${UPLOAD_CHANNEL}"
188199
fi
@@ -193,15 +204,39 @@ setup_conda_pytorch_constraint() {
193204
export CONDA_PYTORCH_BUILD_CONSTRAINT="- pytorch==${PYTORCH_VERSION}${PYTORCH_VERSION_SUFFIX}"
194205
export CONDA_PYTORCH_CONSTRAINT="- pytorch==${PYTORCH_VERSION}${PYTORCH_VERSION_SUFFIX}"
195206
fi
207+
if [[ "$OSTYPE" == msys && "$CU_VERSION" == cu92 ]]; then
208+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c defaults -c numba/label/dev"
209+
fi
196210
}
197211

198212
# Translate CUDA_VERSION into CUDA_CUDATOOLKIT_CONSTRAINT
199213
setup_conda_cudatoolkit_constraint() {
200-
export CONDA_CPUONLY_FEATURE=""
214+
export CONDA_BUILD_VARIANT="cuda"
201215
if [[ "$(uname)" == Darwin ]]; then
202-
export CONDA_CUDATOOLKIT_CONSTRAINT=""
216+
export CONDA_BUILD_VARIANT="cpu"
203217
else
204218
case "$CU_VERSION" in
219+
cu115)
220+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.5,<11.6 # [not osx]"
221+
;;
222+
cu113)
223+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.3,<11.4 # [not osx]"
224+
;;
225+
cu112)
226+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.2,<11.3 # [not osx]"
227+
;;
228+
cu111)
229+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.1,<11.2 # [not osx]"
230+
;;
231+
cu110)
232+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.0,<11.1 # [not osx]"
233+
;;
234+
cu102)
235+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=10.2,<10.3 # [not osx]"
236+
;;
237+
cu101)
238+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=10.1,<10.2 # [not osx]"
239+
;;
205240
cu100)
206241
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=10.0,<10.1 # [not osx]"
207242
;;
@@ -210,7 +245,7 @@ setup_conda_cudatoolkit_constraint() {
210245
;;
211246
cpu)
212247
export CONDA_CUDATOOLKIT_CONSTRAINT=""
213-
export CONDA_CPUONLY_FEATURE="- cpuonly"
248+
export CONDA_BUILD_VARIANT="cpu"
214249
;;
215250
*)
216251
echo "Unrecognized CU_VERSION=$CU_VERSION"

packaging/torchtext/meta.yaml

Lines changed: 11 additions & 1 deletion
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: torchtext
34
version: "{{ environ.get('BUILD_VERSION') }}"
@@ -14,15 +15,24 @@ requirements:
1415
host:
1516
- python
1617
- setuptools
17-
- cpuonly
18+
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
1819
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
1920

2021
run:
2122
- python
2223
- requests
2324
- tqdm
25+
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
2426
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
2527

28+
{% if build_variant == 'cpu' %}
29+
run_constrained:
30+
- cpuonly
31+
{% elif not osx %}
32+
run_constrained:
33+
- cpuonly <0
34+
{% endif %}
35+
2636
build:
2737
string: py{{py}}
2838
script_env:

0 commit comments

Comments
 (0)