Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Use python 3.9 on pipeline (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultmaster authored Jul 23, 2021
1 parent f27b874 commit 7d101f8
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 51 deletions.
13 changes: 7 additions & 6 deletions dependencies/recommended.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Recommended because some non-commonly-used modules/examples depend on those packages.

-f https://download.pytorch.org/whl/torch_stable.html
tensorflow
keras
torch == 1.6.0+cpu ; sys_platform != "darwin"
torch == 1.6.0 ; sys_platform == "darwin"
torchvision == 0.7.0+cpu ; sys_platform != "darwin"
torchvision == 0.7.0 ; sys_platform == "darwin"
tensorflow == 2.5.0
keras == 2.4.3
tensorboard == 2.5.0
torch == 1.9.0+cpu ; sys_platform != "darwin"
torch == 1.9.0 ; sys_platform == "darwin"
torchvision == 0.10.0+cpu ; sys_platform != "darwin"
torchvision == 0.10.0 ; sys_platform == "darwin"
pytorch-lightning >= 1.1.1
onnx
peewee
Expand Down
6 changes: 3 additions & 3 deletions dependencies/recommended_gpu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

-f https://download.pytorch.org/whl/torch_stable.html
tensorflow
keras
torch == 1.6.0
torchvision == 0.7.0
keras == 2.4.3
torch == 1.9.0+cu111
torchvision == 0.10.0+cu111
pytorch-lightning >= 1.1.1
onnx
peewee
Expand Down
4 changes: 2 additions & 2 deletions dependencies/recommended_legacy.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-f https://download.pytorch.org/whl/torch_stable.html
tensorflow == 1.15.4
torch == 1.5.1+cpu
torchvision == 0.6.1+cpu
torch == 1.6.0+cpu
torchvision == 0.7.0+cpu

# It will install pytorch-lightning 0.8.x and unit tests won't work.
# Latest version has conflict with tensorboard and tensorflow 1.x.
Expand Down
2 changes: 0 additions & 2 deletions docs/en_US/NAS/QuickStart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ If the built-in model evaluators do not meet your requirement, or you already wr
.. warning:: Mutations on the parameters of model evaluator (known as hyper-parameter tuning) is currently not supported but will be supported in the future.
.. warning:: To use PyTorch-lightning with Retiarii, currently you need to install PyTorch-lightning v1.1.x (v1.2 is not supported).
Launch an Experiment
--------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/nas/oneshot/darts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def accuracy(output, target, topk=(1,)):

res = dict()
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
correct_k = correct[:k].reshape(-1).float().sum(0)
res["acc{}".format(k)] = correct_k.mul_(1.0 / batch_size).item()
return res
2 changes: 1 addition & 1 deletion examples/nas/oneshot/enas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def accuracy(output, target, topk=(1,)):

res = dict()
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
correct_k = correct[:k].reshape(-1).float().sum(0)
res["acc{}".format(k)] = correct_k.mul_(1.0 / batch_size).item()
return res

Expand Down
2 changes: 1 addition & 1 deletion examples/nas/oneshot/proxylessnas/retrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def accuracy(output, target, topk=(1,)):

res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True)
res.append(correct_k.mul_(100.0 / batch_size))
return res

Expand Down
10 changes: 10 additions & 0 deletions nni/algorithms/hpo/dngo_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ def generate_parameters(self, parameter_id, **kwargs):
# random samples and pick best with model
candidate_x = [_random_config(self.searchspace_json, self.random_state) for _ in range(self.sample_size)]

# The model has NaN issue when all the candidates are same
# Also we can save the predict time when this happens
if all(x == candidate_x[0] for x in candidate_x):
return candidate_x[0]

x_test = np.array([np.array(list(xi.values())) for xi in candidate_x])
m, v = self.model.predict(x_test)

# The model has NaN issue when all the candidates are very close
if np.isnan(m).any() or np.isnan(v).any():
return candidate_x[0]

mean = torch.Tensor(m)
sigma = torch.Tensor(v)
u = (mean - torch.Tensor([0.95]).expand_as(mean)) / sigma
Expand Down
2 changes: 1 addition & 1 deletion nni/algorithms/nas/pytorch/proxylessnas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ def accuracy(output, target, topk=(1,)):

res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True)
res.append(correct_k.mul_(100.0 / batch_size))
return res
2 changes: 2 additions & 0 deletions nni/algorithms/nas/tensorflow/enas/trainer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

# pylint: skip-file

import logging

import tensorflow as tf
Expand Down
22 changes: 2 additions & 20 deletions pipelines/fast-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ stages:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.8
versionSpec: 3.9
displayName: Configure Python version

- task: NodeTool@0
Expand Down Expand Up @@ -170,15 +170,9 @@ stages:
- script: |
set -e
python -m pip install -r dependencies/recommended.txt
python -m pip install -e .[SMAC,BOHB,PPOTuner,DNGO]
python -m pip install -e .[PPOTuner,DNGO]
displayName: Install extra dependencies
# Need del later
- script: |
set -e
python interim_vision_patch.py
displayName: Vision MNIST Patch
- script: |
set -e
cd test
Expand Down Expand Up @@ -368,12 +362,6 @@ stages:
python -m pip install -e .[SMAC,BOHB,PPOTuner,DNGO]
displayName: Install extra dependencies
# Need del later
- script: |
set -e
python interim_vision_patch.py
displayName: Vision MNIST Patch
- script: |
cd test
python -m pytest ut
Expand Down Expand Up @@ -434,12 +422,6 @@ stages:
python -m pip install -e .[DNGO]
displayName: Install extra dependencies
# Need del later
- script: |
set -e
python interim_vision_patch.py
displayName: Vision MNIST Patch
- script: |
cd test
python -m pytest ut
Expand Down
6 changes: 0 additions & 6 deletions pipelines/full-test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ jobs:
python3 -m pip install -e .[SMAC,BOHB,PPOTuner,DNGO]
displayName: Install extra dependencies
# Need del later
- script: |
set -e
python3 interim_vision_patch.py
displayName: Vision MNIST Patch
- script: |
set -e
cd examples/tuners/customized_tuner
Expand Down
6 changes: 0 additions & 6 deletions pipelines/full-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ jobs:
python -m pip install -e .[DNGO]
displayName: Install extra dependencies
# Need del later
- script: |
set -e
python interim_vision_patch.py
displayName: Vision MNIST Patch
- script: |
cd examples/tuners/customized_tuner
python setup.py develop --user
Expand Down
6 changes: 4 additions & 2 deletions test/ut/sdk/test_builtin_tuners.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
from nni.algorithms.hpo.regularized_evolution_tuner import RegularizedEvolutionTuner
from nni.runtime.msg_dispatcher import _pack_parameter, MsgDispatcher

if sys.platform != 'win32':
smac_imported = False
if sys.platform != 'win32' and sys.version_info < (3, 9):
from nni.algorithms.hpo.smac_tuner import SMACTuner
smac_imported = True

from nni.tuner import Tuner

Expand Down Expand Up @@ -334,7 +336,7 @@ def test_anneal(self):
self.import_data_test(tuner_fn)

def test_smac(self):
if sys.platform == "win32":
if not smac_imported:
return # smac doesn't work on windows
tuner_fn = lambda: SMACTuner()
self.search_space_test_all(tuner_fn,
Expand Down

0 comments on commit 7d101f8

Please sign in to comment.