Skip to content

Fix NVRTC versioning for CUDA 11.X (X>=3), CUDA 12 and later #57204

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

Closed
wants to merge 7 commits into from

Conversation

zasdfgbnm
Copy link
Collaborator

@zasdfgbnm zasdfgbnm commented Apr 28, 2021

NVRTC versioning has changed starting 11.3, and will change again for CUDA 12.X. See comment in code for detail. As a result, jit on CUDA 11.3 is broken.

Also, the error message is misleading: When both libname and alt_libname are non-empty, the error message is only reporting alt_libname, it should report both.

To reproduce the error, you can use:

import torch

torch._C._jit_set_profiling_mode(False)
torch._C._jit_set_profiling_executor(False)
torch._C._jit_override_can_fuse_on_cpu(True)
torch._C._jit_override_can_fuse_on_gpu(True)

@torch.jit.script
def jit_relu_dropout(x, prob) :
    # type: (Tensor, float) -> Tensor
    x = torch.nn.functional.relu(x)
    x = torch.nn.functional.dropout(x, p=prob, training=True)
    return x

x = torch.randn((64, 40, 12, 1024), device="cuda:0", dtype=torch.float16, requires_grad=True)
y = jit_relu_dropout(x, 0.5)

with CUDA 11.3, and you will see

Traceback (most recent call last):
  File "/home/gaoxiang/misc/nvrtc-failure.py", line 16, in <module>
    y = jit_relu_dropout(x, 0.5)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: Error in dlopen or dlsym: libnvrtc-8aa72235.so.11.3: cannot open shared object file: No such file or directory

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 28, 2021

💊 CI failures summary and remediations

As of commit 18b3b07 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@zasdfgbnm zasdfgbnm changed the title Fix NVRTC versioning for CUDA 11.3, CUDA 12 and later Fix NVRTC versioning for CUDA 11.X (X>=3), CUDA 12 and later Apr 28, 2021
@zasdfgbnm zasdfgbnm marked this pull request as ready for review April 29, 2021 00:12
@zasdfgbnm zasdfgbnm requested review from malfet and ngimel April 29, 2021 00:12
@zasdfgbnm
Copy link
Collaborator Author

zasdfgbnm commented Apr 29, 2021

cc: @ptrblck @mcarilli

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Thank you for the fix, but can you please rework it (using preprocessor or metaprogramming) to keep libname static for performance reasons? (otherwise libname would be computed every time this function is called)
Or initialize explicitly using std::once construct

@zasdfgbnm
Copy link
Collaborator Author

@malfet Done

@codecov
Copy link

codecov bot commented Apr 29, 2021

Codecov Report

Merging #57204 (18b3b07) into master (4cb534f) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master   #57204      +/-   ##
==========================================
- Coverage   77.58%   77.56%   -0.02%     
==========================================
  Files        1952     1952              
  Lines      194466   194468       +2     
==========================================
- Hits       150868   150831      -37     
- Misses      43598    43637      +39     

@gchanan gchanan added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Apr 29, 2021
@facebook-github-bot
Copy link
Contributor

@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@malfet merged this pull request in 42b3fc2.

@zasdfgbnm zasdfgbnm deleted the fix-nvrtc-versioning branch April 30, 2021 20:30
krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
…#57204)

Summary:
NVRTC versioning has changed starting 11.3, and will change again for CUDA 12.X. See comment in code for detail. As a result, jit on CUDA 11.3 is broken.

Also, the error message is misleading: When both `libname` and `alt_libname` are non-empty, the error message is only reporting `alt_libname`, it should report both.

To reproduce the error, you can use:

```python
import torch

torch._C._jit_set_profiling_mode(False)
torch._C._jit_set_profiling_executor(False)
torch._C._jit_override_can_fuse_on_cpu(True)
torch._C._jit_override_can_fuse_on_gpu(True)

torch.jit.script
def jit_relu_dropout(x, prob) :
    # type: (Tensor, float) -> Tensor
    x = torch.nn.functional.relu(x)
    x = torch.nn.functional.dropout(x, p=prob, training=True)
    return x

x = torch.randn((64, 40, 12, 1024), device="cuda:0", dtype=torch.float16, requires_grad=True)
y = jit_relu_dropout(x, 0.5)
```
with CUDA 11.3, and you will see
```
Traceback (most recent call last):
  File "/home/gaoxiang/misc/nvrtc-failure.py", line 16, in <module>
    y = jit_relu_dropout(x, 0.5)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: Error in dlopen or dlsym: libnvrtc-8aa72235.so.11.3: cannot open shared object file: No such file or directory
```

Pull Request resolved: pytorch#57204

Reviewed By: ngimel

Differential Revision: D28122083

Pulled By: malfet

fbshipit-source-id: fd387cf79f33a6d5a5b93d54c9f21e9c23731045
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants