Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 3c062cb

Browse files
author
Sheng Zha
committed
remove data.mxnet.io usage in tests
1 parent d4ef667 commit 3c062cb

File tree

10 files changed

+27
-95
lines changed

10 files changed

+27
-95
lines changed

docs/python_docs/python/tutorials/deploy/run-on-aws/use_sagemaker.rst

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Run on Amazon SageMaker
1919
-----------------------
2020

21-
This chapter will give a high level overview about Amazon SageMaker,
21+
This chapter will give a high level overview about running MXNet on Amazon SageMaker,
2222
in-depth tutorials can be found on the `Sagemaker
2323
website <https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html>`__.
2424

@@ -29,16 +29,7 @@ charged by time. Within this notebook you can `fetch, explore and
2929
prepare training
3030
data <https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-notebooks-instances.html>`__.
3131

32-
::
33-
34-
import mxnet as mx
35-
import sagemaker
36-
mx.test_utils.get_cifar10() # Downloads Cifar-10 dataset to ./data
37-
sagemaker_session = sagemaker.Session()
38-
inputs = sagemaker_session.upload_data(path='data/cifar',
39-
key_prefix='data/cifar10')
40-
41-
Once the data is ready, you can easily launch training via the SageMaker
32+
With your own data on the notebook instance, you can easily launch training via the SageMaker
4233
SDK. So there is no need to manually configure and log into EC2
4334
instances. You can either bring your own model or use SageMaker's
4435
`built-in
@@ -51,11 +42,11 @@ instance:
5142
::
5243

5344
from sagemaker.mxnet import MXNet as MXNetEstimator
54-
estimator = MXNetEstimator(entry_point='train.py',
45+
estimator = MXNetEstimator(entry_point='train.py',
5546
role=sagemaker.get_execution_role(),
56-
train_instance_count=1,
47+
train_instance_count=1,
5748
train_instance_type='local',
58-
hyperparameters={'batch_size': 1024,
49+
hyperparameters={'batch_size': 1024,
5950
'epochs': 30})
6051
estimator.fit(inputs)
6152

docs/static_site/src/pages/api/faq/cloud.md

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,16 @@ and maintain the resources for precisely the amount of time needed.
3737
In this document, we provide a step-by-step guide that will teach you
3838
how to set up an AWS cluster with _MXNet_. We show how to:
3939

40-
- [Use Amazon S3 to host data](#use-amazon-s3-to-host-data)
41-
- [Set up an EC2 GPU instance with all dependencies installed](#set-up-an-ec2-gpu-instance)
40+
- [Use Pre-installed EC2 GPU Instance](#use-pre-installed-ec2-gpu-instance)
4241
- [Build and run MXNet on a single computer](#build-and-run-mxnet-on-a-gpu-instance)
4342
- [Set up an EC2 GPU cluster for distributed training](#set-up-an-ec2-gpu-cluster-for-distributed-training)
4443

45-
### Use Amazon S3 to Host Data
46-
47-
Amazon S3 provides distributed data storage which proves especially convenient for hosting large datasets.
48-
To use S3, you need [AWS credentials](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html),
49-
including an `ACCESS_KEY_ID` and a `SECRET_ACCESS_KEY`.
50-
51-
To use _MXNet_ with S3, set the environment variables `AWS_ACCESS_KEY_ID` and
52-
`AWS_SECRET_ACCESS_KEY` by adding the following two lines in
53-
`~/.bashrc` (replacing the strings with the correct ones):
54-
55-
```bash
56-
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
57-
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
58-
```
59-
60-
There are several ways to upload data to S3. One simple way is to use
61-
[s3cmd](https://s3tools.org/s3cmd). For example:
62-
63-
```bash
64-
wget http://data.mxnet.io/mxnet/data/mnist.zip
65-
unzip mnist.zip && s3cmd put t*-ubyte s3://dmlc/mnist/
66-
```
67-
6844
### Use Pre-installed EC2 GPU Instance
6945
The [Deep Learning AMIs](https://aws.amazon.com/marketplace/search/results?x=0&y=0&searchTerms=Deep+Learning+AMI)
7046
are a series of images supported and maintained by Amazon Web Services for use
7147
on Amazon Elastic Compute Cloud (Amazon EC2) and contain the latest MXNet release.
7248

73-
Now you can launch _MXNet_ directly on an EC2 GPU instance.
49+
Now you can launch _MXNet_ directly on an EC2 GPU instance.
7450
You can also use [Jupyter](https://jupyter.org) notebook on EC2 machine.
7551
Here is a [good tutorial](https://github.com/dmlc/mxnet-notebooks)
7652
on how to connect to a Jupyter notebook running on an EC2 instance.
@@ -81,7 +57,7 @@ on how to connect to a Jupyter notebook running on an EC2 instance.
8157
provide a foundational image with NVIDIA CUDA, cuDNN, GPU drivers, Intel
8258
MKL-DNN, Docker and Nvidia-Docker, etc. for deploying your own custom deep
8359
learning environment. You may follow the [MXNet Build From Source
84-
instructions](<https://mxnet.apache.org/get_started/build_from_source easily on
60+
instructions](https://mxnet.apache.org/get_started/build_from_source) easily on
8561
the Deep Learning Base AMIs.
8662

8763
### Set Up an EC2 GPU Cluster for Distributed Training
@@ -146,7 +122,7 @@ Put all of the record files into a folder, and point the data path to the folder
146122

147123
#### Use YARN and SGE
148124
Although using SSH can be simple when you don't have a cluster scheduling framework,
149-
_MXNet_ is designed to be portable to various platforms.
125+
_MXNet_ is designed to be portable to various platforms.
150126
We provide scripts available in [tracker](https://github.com/dmlc/dmlc-core/tree/master/tracker)
151127
to allow running on other cluster frameworks, including Hadoop (YARN) and SGE.
152128
We welcome contributions from the community of examples of running _MXNet_ on your favorite distributed platform.

example/gluon/image_classification.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def train(opt, ctx):
193193
ctx = [ctx]
194194

195195
train_data, val_data = get_data_iters(dataset, batch_size, opt)
196-
net.collect_params().reset_ctx(ctx)
196+
for p in net.collect_params().values():
197+
p.reset_ctx(ctx)
197198
trainer = gluon.Trainer(net.collect_params(), 'sgd',
198199
optimizer_params={'learning_rate': opt.lr,
199200
'wd': opt.wd,

python/mxnet/test_utils.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,9 +1806,11 @@ def get_mnist_ubyte(path='data'):
18061806
if not all(os.path.exists(os.path.join(path, f)) for f in files):
18071807
get_mnist(path)
18081808
for f in files:
1809-
zip_file_path = os.path.join(path, f) + '.gz'
1809+
ubyte_file_path = os.path.join(path, f)
1810+
zip_file_path = ubyte_file_path + '.gz'
18101811
with gzip.GzipFile(zip_file_path) as zf:
1811-
zf.extractall(path)
1812+
with open(ubyte_file_path, 'wb') as ubyte_file:
1813+
ubyte_file.write(zf.read())
18121814

18131815
def get_cifar10(path='data'):
18141816
"""Downloads CIFAR10 dataset into a directory in the current directory with the name `data`,
@@ -1820,23 +1822,23 @@ def get_cifar10(path='data'):
18201822
(not os.path.exists(os.path.join(path, 'cifar', 'test.rec'))) or \
18211823
(not os.path.exists(os.path.join(path, 'cifar', 'train.lst'))) or \
18221824
(not os.path.exists(os.path.join(path, 'cifar', 'test.lst'))):
1823-
url = 'http://data.mxnet.io/mxnet/data/cifar10.zip'
1825+
url = 'https://repo.mxnet.io/gluon/dataset/mnist/cifar10-b9ac2870.zip'
18241826
sha1 = 'b9ac287012f2dad9dfb49d8271c39ecdd7db376c'
18251827
zip_file_path = mx.gluon.utils.download(url, path=path, sha1_hash=sha1,
18261828
verify_ssl=False)
18271829
with zipfile.ZipFile(zip_file_path) as zf:
18281830
zf.extractall(path)
18291831

1830-
def get_mnist_iterator(batch_size, input_shape, num_parts=1, part_index=0):
1832+
def get_mnist_iterator(batch_size, input_shape, num_parts=1, part_index=0, path='data'):
18311833
"""Returns training and validation iterators for MNIST dataset
18321834
"""
18331835

1834-
get_mnist_ubyte()
1836+
get_mnist_ubyte(path)
18351837
flat = len(input_shape) != 3
18361838

18371839
train_dataiter = mx.io.MNISTIter(
1838-
image="data/train-images-idx3-ubyte",
1839-
label="data/train-labels-idx1-ubyte",
1840+
image=os.path.join(path, "train-images-idx3-ubyte"),
1841+
label=os.path.join(path, "train-labels-idx1-ubyte"),
18401842
input_shape=input_shape,
18411843
batch_size=batch_size,
18421844
shuffle=True,
@@ -1845,8 +1847,8 @@ def get_mnist_iterator(batch_size, input_shape, num_parts=1, part_index=0):
18451847
part_index=part_index)
18461848

18471849
val_dataiter = mx.io.MNISTIter(
1848-
image="data/t10k-images-idx3-ubyte",
1849-
label="data/t10k-labels-idx1-ubyte",
1850+
image=os.path.join(path, "t10k-images-idx3-ubyte"),
1851+
label=os.path.join(path, "t10k-labels-idx1-ubyte"),
18501852
input_shape=input_shape,
18511853
batch_size=batch_size,
18521854
flat=flat,

tests/nightly/download.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/python/gpu/test_gluon_model_zoo_gpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def eprint(*args, **kwargs):
3636
VAL_DATA='data/val-5k-256.rec'
3737
def download_data():
3838
return mx.test_utils.download(
39-
'http://data.mxnet.io/data/val-5k-256.rec', VAL_DATA)
39+
'https://repo.mxnet.io/gluon/dataset/test/val-5k-256-9e70d85e0.rec', VAL_DATA)
4040

4141
@with_seed()
4242
@pytest.mark.serial

tests/python/unittest/test_contrib_gluon_data_vision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _generate_objects():
5151

5252

5353
class TestImage(unittest.TestCase):
54-
IMAGES_URL = "http://data.mxnet.io/data/test_images.tar.gz"
54+
IMAGES_URL = "https://repo.mxnet.io/gluon/dataset/test/test_images-9cebe48a.tar.gz"
5555

5656
def setUp(self):
5757
self.IMAGES_DIR = tempfile.mkdtemp()

tests/python/unittest/test_gluon_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_array_dataset():
5252
def prepare_record(tmpdir_factory):
5353
test_images = tmpdir_factory.mktemp("test_images")
5454
test_images_tar = test_images.join("test_images.tar.gz")
55-
gluon.utils.download("http://data.mxnet.io/data/test_images.tar.gz", str(test_images_tar))
55+
gluon.utils.download("https://repo.mxnet.io/gluon/dataset/test/test_images-9cebe48a.tar.gz", str(test_images_tar))
5656
tarfile.open(test_images_tar).extractall(str(test_images))
5757
imgs = os.listdir(str(test_images.join("test_images")))
5858
record = mx.recordio.MXIndexedRecordIO(str(test_images.join("test.idx")), str(test_images.join("test.rec")), 'w')

tests/python/unittest/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _test_imageiter_last_batch(imageiter_list, assert_data_shape):
110110

111111

112112
class TestImage(unittest.TestCase):
113-
IMAGES_URL = "http://data.mxnet.io/data/test_images.tar.gz"
113+
IMAGES_URL = "https://repo.mxnet.io/gluon/dataset/test/test_images-9cebe48a.tar.gz"
114114

115115
def setUp(self):
116116
self.IMAGES_DIR = tempfile.mkdtemp()

tests/python/unittest/test_numpy_contrib_gluon_data_vision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _generate_objects():
5151

5252

5353
class TestImage(unittest.TestCase):
54-
IMAGES_URL = "http://data.mxnet.io/data/test_images.tar.gz"
54+
IMAGES_URL = "https://repo.mxnet.io/gluon/dataset/test/test_images-9cebe48a.tar.gz"
5555

5656
def setUp(self):
5757
self.IMAGES_DIR = tempfile.mkdtemp()

0 commit comments

Comments
 (0)