non_blocking=True and process the GPU data

Open
#825 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python, pytorch

Research direction

The issue only provides a CUDA-stream code excerpt; start by reviewing the shown non_blocking=True transfers and subsequent normalization in the PyTorch context. Done means documenting whether the ordering is correct and identifying any synchronization change required.

Written by the indexing model from the issue text.

Description

    with torch.cuda.stream(self.stream):
        self.next_input = self.next_input.cuda(non_blocking=True)
        self.next_target = self.next_target.cuda(non_blocking=True)
        # more code for the alternative if record_stream() doesn't work:
        # copy_ will record the use of the pinned source tensor in this side stream.
        # self.next_input_gpu.copy_(self.next_input, non_blocking=True)
        # self.next_target_gpu.copy_(self.next_target, non_blocking=True)
        # self.next_input = self.next_input_gpu
        # self.next_target = self.next_target_gpu

        # With Amp, it isn't necessary to manually convert data to half.
        # if args.fp16:
        #     self.next_input = self.next_input.half()
        # else:
        self.next_input = self.next_input.float()
        self.next_input = self.next_input.sub_(self.mean).div_(self.std) 

In this code, when put data to cuda using non_blocking=True. but after that normalize the data without confirm the uploading data processing is done. Is that correct?
(My language is poor, so I don't know whether the explanation is clear )

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/apex

All issues in NVIDIA/apex

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.