-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Torch 1.12.0 and Taichi cannot use CUDA at the same time. #5502
Comments
Taichi can work with PyTorch 1.10.0. |
I reproduced the error too. @erizmr Can you look into this error? |
I am looking into it. |
Hi, I have also met the same error. |
Made some inspection inspired by this pytorch issue Full code with cuda driver helpers:
This is the proper code that can work. What we see from the log: Taichi ignored the PyTorch CUDA context and created its own. ti.init(arch=ti.gpu, log_level=ti.TRACE)
print("===AFTER TI INIT===")
print_existing_contexts()
device = torch.device("cuda:0")
print("===AFTER TORCH DEVICE INIT===")
print_existing_contexts()
print(torch._C._cuda_hasPrimaryContext(0))
x = torch.tensor([1.], requires_grad=True, device=device)
print("===AFTER TORCH TENSOR INIT===")
print_existing_contexts()
# print("TAICHI "ti._lib.core.get_primary_ctx_state())
print("Torch has primary context", torch._C._cuda_hasPrimaryContext(0))
loss = x**2
loss.backward()
print(torch._C._cuda_hasPrimaryContext(0)) Torch just fetches the CUcontext created by Taichi, and that CUDA context is not synced. That said, to work with PyTorch, we should pop out Taichi's CUDA context at the end of |
Describe the bug
If taichi is initialized with GPU, Torch cannot execute backward.
PyTorch version: 1.12.0
To Reproduce
Log/Screenshots
Additional comments
ti diagnose
:The text was updated successfully, but these errors were encountered: