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

GPU PythonFunction operator #1655

Merged
merged 3 commits into from
Jan 15, 2020
Merged

Conversation

banasraf
Copy link
Collaborator

@banasraf banasraf commented Jan 14, 2020

Why we need this PR?

Pick one, remove the rest

  • It adds GPU python operator

What happened in this PR?

Fill relevant points, put NA otherwise. Replace anything inside []

  • What solution was applied:
    It was implemented as wrapper around DLTensorPythonFunctionOperator
  • Affected modules and functionalities:
    Operator added in ops.py
  • Key points relevant for the review:
    ops.py
  • Validation and testing:
    New tests added
  • Documentation (including examples):
    Updated the operator docs

JIRA TASK: [DALI-1189]

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@banasraf
Copy link
Collaborator Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1071819]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1071819]: BUILD PASSED

@@ -27,6 +27,13 @@
import nvidia.dali.libpython_function_plugin


cupy = None
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed. Bellow global is creating cupy variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When i remove this line, it ends up with:

  File "/home/rafal/mydali/build/venv/lib/python3.6/site-packages/nvidia/dali/ops.py", line 33, in _setup_cupy
    if cupy is None:
NameError: name 'cupy' is not defined

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@banasraf banasraf changed the title [WiP] GPU PythonFunction operator GPU PythonFunction operator Jan 14, 2020
Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@banasraf
Copy link
Collaborator Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1073791]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1073791]: BUILD PASSED

.DocStr("Executes a python function. \n"
"The operator can be used to execute custom python code within the DALI pipeline. "
"The called function will get tensors' data as numpy arrays for CPU operators"
" or as cupy arrays for GPU operators and should return results in the same format."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
" or as cupy arrays for GPU operators and should return results in the same format."
" or as CuPy arrays for GPU operators and should return results in the same format."

maybe?

Copy link
Collaborator Author

@banasraf banasraf Jan 15, 2020

Choose a reason for hiding this comment

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

Will fix in the next PR (GPU Torch operator)

class PythonFunctionPipeline(Pipeline):
def __init__(self, function, device, num_outputs=1):
super(PythonFunctionPipeline, self).__init__(BATCH_SIZE, NUM_WORKERS, DEVICE_ID,
seed=SEED,
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: You don't need to set the seed if you just want it to be a random number

@@ -5,6 +5,7 @@ target_dir=./dali/test/python

test_body() {
nosetests --verbose -m '(?:^|[\b_\./-])[Tt]est.*cupy' test_dltensor_operator.py
nosetests --verbose test_gpu_python_function_operator.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: If you name your file as test_operator_*.py it is picked automatically by oython self test (not sure if that is what you want)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't want to, because i cannot import cupy in python self test

@banasraf banasraf merged commit 94a3146 into NVIDIA:master Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants