[sgd] Semantic Segmentation Example (#7825)

* better_example

* test

* improve some usability things

* submit

* fix

* making a segmentation example

* segmentation_example

* segmentation

* device

* flake

* Update python/ray/util/sgd/torch/training_operator.py

* uti

* finished_example

* block

* format

* locationg

* fix

* ok

* revert

* segmentation

* lint_and_test

* address_comments
This commit is contained in:
Richard Liaw
2020-04-10 20:35:45 -07:00
committed by GitHub
parent 0b4e09da76
commit dd63178e91
13 changed files with 783 additions and 71 deletions
+31 -2
View File
@@ -610,8 +610,8 @@ You can see more details in the `benchmarking README <https://github.com/ray-pro
DISCLAIMER: RaySGD does not provide any custom communication primitives. If you see any performance issues, you may need to file them on the PyTorch github repository.
Debugging
---------
Debugging/Tips
--------------
Here's some simple tips on how to debug the TorchTrainer.
@@ -657,6 +657,32 @@ Try using a profiler. Either use:
or use `Python profiling <https://docs.python.org/3/library/debug.html>`_.
**My creator functions download data, and I don't want multiple processes downloading to the same path at once.**
Use ``filelock`` within the creator functions to create locks for critical regions. For example:
.. code-block:: python
import os
import tempfile
from filelock import FileLock
def create_dataset(config):
dataset_path = config["dataset_path"]
# Create a critical region of the code
# This will take a longer amount of time to download the data at first.
# Other processes will block at the ``with`` statement.
# After downloading, this code block becomes very fast.
with FileLock(os.path.join(tempfile.gettempdir(), "download_data.lock")):
if not os.path.exists(dataset_path):
download_data(dataset_path)
# load_data is assumed to safely support concurrent reads.
data = load_data(dataset_path)
return DataLoader(data)
**I get a 'socket timeout' error during training.**
Try increasing the length of the NCCL timeout. The current timeout is 10 seconds.
@@ -688,6 +714,9 @@ to contribute an example, feel free to create a `pull request here <https://gith
- `TorchTrainer and RayTune example <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/torch/examples/tune_example.py>`__:
Simple example of hyperparameter tuning with Ray's TorchTrainer.
- `Semantic Segmentation example <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/torch/examples/segmentation/train_segmentation.py>`__:
Fine-tuning a ResNet50 model on VOC with Batch Norm.
- `CIFAR10 example <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/torch/examples/cifar_pytorch_example.py>`__:
Training a ResNet18 model on CIFAR10.