Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dali MNIST example #3721

Merged
merged 36 commits into from
Nov 6, 2020
Merged

Conversation

irustandi
Copy link
Contributor

What does this PR do?

Add a modification of the MNIST example using NVIDIA DALI.

Fixes #791

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Sep 29, 2020

Hello @irustandi! Thanks for updating this PR.

Line 87:121: E501 line too long (125 > 120 characters)

Comment last updated at 2020-11-06 13:45:49 UTC

@mergify mergify bot requested a review from a team September 29, 2020 10:59
@codecov
Copy link

codecov bot commented Sep 29, 2020

Codecov Report

Merging #3721 into master will increase coverage by 1%.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           master   #3721   +/-   ##
======================================
+ Coverage      93%     93%   +1%     
======================================
  Files         116     116           
  Lines        8883    8815   -68     
======================================
- Hits         8233    8225    -8     
+ Misses        650     590   -60     

@Borda Borda added feature Is an improvement or enhancement example labels Sep 29, 2020
@carmocca
Copy link
Contributor

Can you run black on it?

pre-commit run --files pl_examples/basic_examples/mnist_dali.py

Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add test as calling this CLI in examples/test_...py

@mergify mergify bot requested a review from a team September 29, 2020 14:10
@irustandi
Copy link
Contributor Author

Changes made as requested. Need to make sure that DALI (with the appropriate CUDA version) is available in the test environment. How can we do this?

@Borda Borda self-requested a review September 29, 2020 15:53
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to add some short docstrings to the class instead of general comments

@mergify mergify bot requested a review from a team September 29, 2020 15:55
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add the package to the requirements
probably it has to be compiled from the source... https://docs.nvidia.com/deeplearning/dali/user-guide/docs/compilation.html

@mergify mergify bot requested a review from a team September 30, 2020 11:02
@irustandi
Copy link
Contributor Author

pls add package to requirements

A couple of questions regarding this. According to DALI doc, I would need to install it like this:

pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda100

How can I add it to requirements in this case? And also, is CUDA 10 OK?

@Borda
Copy link
Member

Borda commented Sep 30, 2020

Collecting nvidia-dali-cuda100
  Downloading nvidia-dali-cuda100-0.0.1.dev4.tar.gz (3.9 kB)
    ERROR: Command errored out with exit status 1:
     command: /Users/jirka/Applications/venv_PL/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c1/fc_9d4b10c1cwmsm0l6cgzxc0000gn/T/pip-install-h606em3s/nvidia-dali-cuda100/setup.py'"'"'; __file__='"'"'/private/var/folders/c1/fc_9d4b10c1cwmsm0l6cgzxc0000gn/T/pip-install-h606em3s/nvidia-dali-cuda100/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/c1/fc_9d4b10c1cwmsm0l6cgzxc0000gn/T/pip-pip-egg-info-g7b2_uvu
         cwd: /private/var/folders/c1/fc_9d4b10c1cwmsm0l6cgzxc0000gn/T/pip-install-h606em3s/nvidia-dali-cuda100/
    Complete output (18 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/c1/fc_9d4b10c1cwmsm0l6cgzxc0000gn/T/pip-install-h606em3s/nvidia-dali-cuda100/setup.py", line 150, in <module>
        raise RuntimeError(open("ERROR.txt", "r").read())
    RuntimeError:
    ###########################################################################################
    The package you are trying to install is only a placeholder project on PyPI.org repository.
    This package is hosted on NVIDIA Python Package Index.
    
    This package can be installed as:
    ```
    $ pip install nvidia-pyindex
    $ pip install nvidia-dali-cuda100
    ```
    
    Please refer to NVIDIA DALI installation guide for instructions:
    https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html
    ###########################################################################################
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

may be linked that I do not have gpu...

@irustandi
Copy link
Contributor Author

With --extra-index-url added to requirements/examples.txt, the CI complete testing can get past the dependency installation step, however, it fails in the actual test since CUDA does not seem to be available (libcuda.so is missing). Also, DALI does not seem to be supported in Windows and Mac. Install pkg fails because the --extra-index-url line is somehow is not the expected format.

@irustandi
Copy link
Contributor Author

To go forward on this, I see the following needs at the very least:

  • Ability to make the DALI example be tested on Linux only (exclude Windows and Mac)
  • Support CUDA in CI

Let me know how I should proceed.

@Borda
Copy link
Member

Borda commented Sep 30, 2020

@irustandi sure, that is what I wanted to suggest, mark the test as GPU needed and then we need to include Dali in our CUDA Docker image

@mergify
Copy link
Contributor

mergify bot commented Sep 30, 2020

This pull request is now in conflict... :(

gym>=0.17.0
nvidia-dali --extra-index-url https://developer.download.nvidia.com/compute/redist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shall install it at least on our Docker image from the source

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/c1/fc_9d4b10c1cwmsm0l6cgzxc0000gn/T/pip-install-xo27f9qp/nvidia-dali-cuda100/setup.py", line 150, in <module>
        raise RuntimeError(open("ERROR.txt", "r").read())
    RuntimeError:
    ###########################################################################################
    The package you are trying to install is only a placeholder project on PyPI.org repository.
    This package is hosted on NVIDIA Python Package Index.
    
    This package can be installed as:
    ```
    $ pip install nvidia-pyindex
    $ pip install nvidia-dali-cuda100
    ```
    
    Please refer to NVIDIA DALI installation guide for instructions:
    https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html
    ###########################################################################################

cc: @ydcjeff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we won't be able to include this as a requirement here, but I think I'll add a note in the docs

@Borda Borda self-requested a review November 4, 2020 22:46
.drone.yml Outdated
@@ -32,6 +32,7 @@ steps:
- pip --version
- nvidia-smi
- pip install -r ./requirements/devel.txt --upgrade-strategy only-if-needed -v --no-cache-dir
- pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing now if the example runs, later we shall add it to the used docker image

@SeanNaren
Copy link
Contributor

Let's wait till all tests are passing, some weirdness with one job...

@awaelchli
Copy link
Contributor

correct me if I'm wrong, this PR does not add any additional support for Dali, it only adds examples. Consider renaming the PR title.

@SeanNaren SeanNaren changed the title Dali support Add Dali MNIST example Nov 5, 2020
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR ! minors changes.

pl_examples/basic_examples/mnist_dali.py Outdated Show resolved Hide resolved
requirements/examples.txt Show resolved Hide resolved
@SeanNaren SeanNaren merged commit 6e5f232 into Lightning-AI:master Nov 6, 2020
@SeanNaren
Copy link
Contributor

Thanks @irustandi for the work, apologies on the delay. NVIDIA DALI is awesome, hoping to see more integration into loaders :)

rohitgr7 pushed a commit that referenced this pull request Nov 21, 2020
* add MNIST DALI example, update README.md

* Fix PEP8 warnings

* reformatted using black

* add mnist_dali to test_examples.py

* Add documentation as docstrings

* add nvidia-pyindex and nvidia-dali-cuda100

* replace nvidia-pyindex with --extra-index-url

* mark mnist_dali test as Linux and GPU only

* adjust CUDA docker and examples.txt, fix import error in test_examples.py

* adjust the GPU check

* Exit when DALI is not available

* remove requirements-examples.txt and DALI pip install

* Refactored example, moved to new logging api, added runtime check for test and dali script

* Patch to reflect the mnist example module

* add req.

* Apply suggestions from code review

* Removed requirement as it breaks CPU install, added note in README to install DALI

* add DALI to Drone

* test examples

* Apply suggestions from code review

* imports

* ABC

* cuda

* cuda

* pip DALI

* Move build into init function

Co-authored-by: SeanNaren <sean@grid.ai>
Co-authored-by: Jirka Borovec <jirka@pytorchlightning.ai>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Sean Naren <sean.narenthiran@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nvidia dali support
10 participants