pytorch/torch/csrc/jit/python
Aidyn-A 69eef5a4be [CUDA12] set_device change (#94864)
This PR adds workaround for CUDA 12 [`cudaSetDevice` change](https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g159587909ffa0791bbe4b40187a4c6bb) which will always create primary context on target device. So operations like this:
```Python
import torch
x = torch.randn(1, device="cuda:1")
```
would always create primary context on on device `cuda:1` because it is creating a tensor on it and on device `cuda:0` because the destructor of CUDA Device guard calls `cudaSetDevice(0)`.
After this PR the CUDA Device guard will not call `cudaSetDevice(0)` if primary context does not exist on `cuda:0`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94864
Approved by: https://github.com/malfet, https://github.com/atalman, https://github.com/ezyang
2023-04-10 17:31:12 +00:00
..
init.cpp Optionally ignore utf-8 decoding error when converting std::string to python str. (#97282) 2023-03-23 01:19:08 +00:00
init.h
module_python.h
pybind_utils.cpp Optionally ignore utf-8 decoding error when converting std::string to python str. (#97282) 2023-03-23 01:19:08 +00:00
pybind_utils.h Revert "Reduce includes of CUDACachingAllocator.h (#97072)" 2023-04-07 06:15:11 +00:00
pybind.h
python_arg_flatten.cpp [BE] Use nested namespaces in .cpp/.cu files (#92100) 2023-01-13 16:32:34 +00:00
python_arg_flatten.h
python_custom_class.cpp [BE] Use nested namespaces in .cpp/.cu files (#92100) 2023-01-13 16:32:34 +00:00
python_custom_class.h
python_dict.cpp Apply Clang-Tidy readability-container-size-empty (#93236) 2023-01-29 23:28:19 +00:00
python_dict.h
python_interpreter.cpp [BE] Use nested namespaces in .cpp/.cu files (#92100) 2023-01-13 16:32:34 +00:00
python_ir.cpp [jit] Support Awaitable type (#90863) 2023-01-30 17:38:59 +00:00
python_ir.h
python_ivalue.h
python_list.cpp Apply Clang-Tidy readability-container-size-empty (#93236) 2023-01-29 23:28:19 +00:00
python_list.h
python_sugared_value.cpp [CUDA12] set_device change (#94864) 2023-04-10 17:31:12 +00:00
python_sugared_value.h [JIT] Partially support ForwardRef type annotations for NamedTuple attributes (#96933) 2023-03-22 15:20:38 +00:00
python_tracer.cpp do not need to check if element in dict input is Tensor. (#97866) 2023-03-31 19:39:00 +00:00
python_tracer.h
python_tree_views.cpp [BE] Use nested namespaces in .cpp/.cu files (#92100) 2023-01-13 16:32:34 +00:00
python_tree_views.h
script_init.cpp [BE] Move flatbuffer related python C bindings to script_init (#97476) 2023-03-28 17:56:32 +00:00
script_init.h
update_graph_executor_opt.cpp [BE] Use nested namespaces in .cpp/.cu files (#92100) 2023-01-13 16:32:34 +00:00
update_graph_executor_opt.h
utf8_decoding_ignore.cpp Optionally ignore utf-8 decoding error when converting std::string to python str. (#97282) 2023-03-23 01:19:08 +00:00
utf8_decoding_ignore.h Optionally ignore utf-8 decoding error when converting std::string to python str. (#97282) 2023-03-23 01:19:08 +00:00